fix: try fix errors
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
This commit is contained in:
parent
1451273760
commit
f83fe3b30b
10 changed files with 137 additions and 243 deletions
|
|
@ -94,8 +94,8 @@ func mapFields(userResp *sqlserverflexbeta.GetUserResponse, model *resourceModel
|
|||
model.Username = types.StringPointerValue(user.Username)
|
||||
|
||||
// Map roles
|
||||
if user.Roles != nil {
|
||||
resRoles := *user.Roles
|
||||
if userResp.Roles != nil {
|
||||
resRoles := *userResp.Roles
|
||||
slices.Sort(resRoles)
|
||||
|
||||
var roles []attr.Value
|
||||
|
|
@ -103,11 +103,11 @@ func mapFields(userResp *sqlserverflexbeta.GetUserResponse, model *resourceModel
|
|||
roles = append(roles, types.StringValue(string(role)))
|
||||
}
|
||||
|
||||
rolesSet, diags := types.SetValue(types.StringType, roles)
|
||||
rolesSet, diags := types.ListValue(types.StringType, roles)
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
|
||||
}
|
||||
model.Roles = types.List(rolesSet)
|
||||
model.Roles = rolesSet
|
||||
}
|
||||
|
||||
// Ensure roles is not null
|
||||
|
|
@ -153,11 +153,11 @@ func mapFieldsCreate(userResp *sqlserverflexbeta.CreateUserResponse, model *reso
|
|||
for _, role := range resRoles {
|
||||
roles = append(roles, types.StringValue(string(role)))
|
||||
}
|
||||
rolesSet, diags := types.SetValue(types.StringType, roles)
|
||||
rolesList, diags := types.ListValue(types.StringType, roles)
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed to map roles: %w", core.DiagsToError(diags))
|
||||
}
|
||||
model.Roles = types.List(rolesSet)
|
||||
model.Roles = rolesList
|
||||
}
|
||||
|
||||
if model.Roles.IsNull() || model.Roles.IsUnknown() {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||
"github.com/hashicorp/terraform-plugin-framework/path"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource"
|
||||
"github.com/hashicorp/terraform-plugin-framework/resource/identityschema"
|
||||
|
|
@ -108,37 +107,25 @@ func (r *userResource) ModifyPlan(
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: verify if this is needed - START
|
||||
var configRoles []string
|
||||
diags := configModel.Roles.ElementsAs(ctx, &configRoles, false)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if diags.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
var planRoles []string
|
||||
diags = planModel.Roles.ElementsAs(ctx, &planRoles, false)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if diags.HasError() {
|
||||
return
|
||||
}
|
||||
|
||||
slices.Sort(configRoles)
|
||||
slices.Sort(planRoles)
|
||||
|
||||
if !slices.Equal(configRoles, planRoles) {
|
||||
var roles []attr.Value
|
||||
for _, role := range configRoles {
|
||||
roles = append(roles, types.StringValue(string(role)))
|
||||
}
|
||||
rolesSet, diags := types.SetValue(types.StringType, roles)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if diags.HasError() {
|
||||
return
|
||||
}
|
||||
planModel.Roles = types.List(rolesSet)
|
||||
}
|
||||
// TODO: verify if this is needed - END
|
||||
//// TODO: verify if this is needed - START
|
||||
//var planRoles []string
|
||||
//diags := planModel.Roles.ElementsAs(ctx, &planRoles, false)
|
||||
//resp.Diagnostics.Append(diags...)
|
||||
//if diags.HasError() {
|
||||
// return
|
||||
//}
|
||||
//slices.Sort(planRoles)
|
||||
//var roles []attr.Value
|
||||
//for _, role := range planRoles {
|
||||
// roles = append(roles, types.StringValue(string(role)))
|
||||
//}
|
||||
//rolesSet, diags := types.ListValue(types.StringType, roles)
|
||||
//resp.Diagnostics.Append(diags...)
|
||||
//if diags.HasError() {
|
||||
// return
|
||||
//}
|
||||
//planModel.Roles = rolesSet
|
||||
//// TODO: verify if this is needed - END
|
||||
|
||||
resp.Diagnostics.Append(resp.Plan.Set(ctx, planModel)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue