diff --git a/internal/services/oidcauths/type.go b/internal/services/oidcauths/type.go index ba2f14a..d2f9fe2 100644 --- a/internal/services/oidcauths/type.go +++ b/internal/services/oidcauths/type.go @@ -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": { @@ -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)) } diff --git a/internal/services/users/type.go b/internal/services/users/type.go index 0432146..f2f83fd 100644 --- a/internal/services/users/type.go +++ b/internal/services/users/type.go @@ -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}, }, @@ -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 } diff --git a/pkg/bluechip_client/bluechip_models/resources.go b/pkg/bluechip_client/bluechip_models/resources.go index ac495de..49663b9 100644 --- a/pkg/bluechip_client/bluechip_models/resources.go +++ b/pkg/bluechip_client/bluechip_models/resources.go @@ -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{} @@ -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"` }