Skip to content

Commit

Permalink
fix: Update not required filed to optional
Browse files Browse the repository at this point in the history
  • Loading branch information
uanid committed Jan 8, 2024
1 parent d176342 commit 6950a64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions internal/services/oidcauths/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t SpecType) Schema() *schema.Schema {
},
"groups_claim": {
Type: schema.TypeString,
Required: !t.Computed,
Optional: !t.Computed,
Computed: t.Computed,
},
"groups_prefix": {
Expand Down Expand Up @@ -91,7 +91,9 @@ func (t SpecType) Expand(ctx context.Context, d *schema.ResourceData, out *bluec
if attr["required_claims"] != nil {
out.RequiredClaims = fwflex.ExpandStringSet(attr["required_claims"].(*schema.Set))
}
out.GroupsClaim = attr["groups_claim"].(string)
if attr["groups_claim"] != nil {
out.GroupsClaim = fwtype.String(attr["groups_claim"].(string))
}
if attr["groups_prefix"] != nil {
out.GroupsPrefix = fwtype.String(attr["groups_prefix"].(string))
}
Expand Down
6 changes: 4 additions & 2 deletions internal/services/users/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (t SpecType) Schema() *schema.Schema {
},
"groups": {
Type: schema.TypeSet,
Required: !t.Computed,
Optional: !t.Computed,
Computed: t.Computed,
Elem: &schema.Schema{Type: schema.TypeString},
},
Expand All @@ -43,7 +43,9 @@ func (t SpecType) Schema() *schema.Schema {
func (t SpecType) Expand(ctx context.Context, d *schema.ResourceData, out *bluechip_models.UserSpec) diag.Diagnostics {
attr := d.Get("spec.0").(map[string]any)
out.Password = attr["password"].(string)
out.Groups = fwflex.ExpandStringSet(attr["groups"].(*schema.Set))
if attr["groups"] != nil {
out.Groups = fwflex.ExpandStringSet(attr["groups"].(*schema.Set))
}
out.Attributes = fwflex.ExpandMap(attr["attributes"].(map[string]any))
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/bluechip_client/bluechip_models/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ type UserSpec struct {
BaseSpec `json:"-"`

Password string `json:"password"`
Groups []string `json:"groups"`
Attributes map[string]string `json:"attributes"`
Groups []string `json:"groups,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
}

var _ ClusterApiResource[OidcAuthSpec] = &OidcAuth{}
Expand All @@ -171,7 +171,7 @@ type OidcAuthSpec struct {
Issuer string `json:"issuer"`
ClientId string `json:"clientId"`
RequiredClaims []string `json:"requiredClaims,omitempty"`
GroupsClaim string `json:"groupsClaim"`
GroupsClaim *string `json:"groupsClaim,omitempty"`
GroupsPrefix *string `json:"groupsPrefix,omitempty"`
AttributeMapping []AttributeMapping `json:"attributeMapping,omitempty"`
}
Expand Down

0 comments on commit 6950a64

Please sign in to comment.