fix: pipeline fixes
[skip ci]
This commit is contained in:
parent
eecf98f4b1
commit
8c490da5ce
6 changed files with 56 additions and 47 deletions
|
|
@ -136,5 +136,5 @@ func (d *userDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
|
|||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "SQLServer Flex beta instance read")
|
||||
tflog.Info(ctx, "SQLServer Flex Alpha instance read")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,18 +80,18 @@ func mapFields(userResp *v3alpha1api.GetUserResponse, model *resourceModel, regi
|
|||
user := userResp
|
||||
|
||||
// Handle user ID
|
||||
var userId int64
|
||||
var userID int64
|
||||
if model.UserId.ValueInt64() != 0 {
|
||||
userId = model.UserId.ValueInt64()
|
||||
userID = model.UserId.ValueInt64()
|
||||
} else if user.Id != 0 {
|
||||
userId = user.Id
|
||||
userID = user.Id
|
||||
} else {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
|
||||
// Set main attributes
|
||||
model.Id = types.Int64Value(userId)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
model.Id = types.Int64Value(userID)
|
||||
model.UserId = types.Int64Value(userID)
|
||||
model.Username = types.StringValue(user.Username)
|
||||
|
||||
// Map roles
|
||||
|
|
@ -135,9 +135,9 @@ func mapFieldsCreate(userResp *v3alpha1api.CreateUserResponse, model *resourceMo
|
|||
if user.Id == 0 {
|
||||
return fmt.Errorf("user id not present")
|
||||
}
|
||||
userId := user.Id
|
||||
model.Id = types.Int64Value(userId)
|
||||
model.UserId = types.Int64Value(userId)
|
||||
userID := user.Id
|
||||
model.Id = types.Int64Value(userID)
|
||||
model.UserId = types.Int64Value(userID)
|
||||
model.Username = types.StringValue(user.Username)
|
||||
|
||||
if user.Password == "" {
|
||||
|
|
@ -185,9 +185,13 @@ func toCreatePayload(
|
|||
return nil, fmt.Errorf("nil model")
|
||||
}
|
||||
|
||||
return &v3alpha1api.CreateUserRequestPayload{
|
||||
res := v3alpha1api.CreateUserRequestPayload{
|
||||
Username: model.Username.ValueString(),
|
||||
DefaultDatabase: model.DefaultDatabase.ValueStringPointer(),
|
||||
DefaultDatabase: nil,
|
||||
Roles: roles,
|
||||
}, nil
|
||||
}
|
||||
if !model.DefaultDatabase.IsUnknown() && !model.DefaultDatabase.IsNull() {
|
||||
res.DefaultDatabase = model.DefaultDatabase.ValueStringPointer()
|
||||
}
|
||||
return &res, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func (r *userResource) Configure(ctx context.Context, req resource.ConfigureRequ
|
|||
return
|
||||
}
|
||||
r.client = apiClient
|
||||
tflog.Info(ctx, "SQLServer Beta Flex user client configured")
|
||||
tflog.Info(ctx, "SQLServer Alpha Flex user client configured")
|
||||
}
|
||||
|
||||
// ModifyPlan implements resource.ResourceWithModifyPlan.
|
||||
|
|
@ -206,12 +206,12 @@ func (r *userResource) Create(
|
|||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
projectID := model.ProjectId.ValueString()
|
||||
instanceID := model.InstanceId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectID)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceID)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
var roles []string
|
||||
|
|
@ -234,9 +234,9 @@ func (r *userResource) Create(
|
|||
// Create new user
|
||||
userResp, err := r.client.DefaultAPI.CreateUserRequest(
|
||||
ctx,
|
||||
projectId,
|
||||
projectID,
|
||||
region,
|
||||
instanceId,
|
||||
instanceID,
|
||||
).CreateUserRequestPayload(*payload).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating user", fmt.Sprintf("Calling API: %v", err))
|
||||
|
|
@ -260,9 +260,9 @@ func (r *userResource) Create(
|
|||
|
||||
// Set data returned by API in identity
|
||||
identity := UserResourceIdentityModel{
|
||||
ProjectID: types.StringValue(projectId),
|
||||
ProjectID: types.StringValue(projectID),
|
||||
Region: types.StringValue(region),
|
||||
InstanceID: types.StringValue(instanceId),
|
||||
InstanceID: types.StringValue(instanceID),
|
||||
UserID: types.Int64Value(userId),
|
||||
}
|
||||
resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
|
||||
|
|
@ -284,8 +284,8 @@ func (r *userResource) Create(
|
|||
waitResp, err := sqlserverflexalphaWait.CreateUserWaitHandler(
|
||||
ctx,
|
||||
r.client.DefaultAPI,
|
||||
projectId,
|
||||
instanceId,
|
||||
projectID,
|
||||
instanceID,
|
||||
region,
|
||||
userId,
|
||||
).SetSleepBeforeWait(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue