Skip to content

Commit

Permalink
Update expand and flatten files for connection object
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnellis committed Dec 11, 2024
1 parent 5873bf5 commit ebe1824
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions internal/auth0/connection/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,43 @@ func expandConnectionOptionsGitHub(data *schema.ResourceData, config cty.Value)
return options, diag.FromErr(err)
}

func expandConnectionOptionsAuthenticationMethods(config cty.Value) *management.AuthenticationMethods {
var authMethods *management.AuthenticationMethods
config.ForEachElement(
func(_ cty.Value, attributes cty.Value) (stop bool) {
authMethods = &management.AuthenticationMethods{
Password: expandConnectionOptionsAuthenticationMethodsPassword(attributes),
Passkey: expandConnectionOptionsAuthenticationMethodsPasskey(attributes),
}
return stop
})
return authMethods
}

func expandConnectionOptionsAuthenticationMethodsPassword(config cty.Value) *management.PasswordAuthenticationMethod {
var passwordAuth *management.PasswordAuthenticationMethod
config.ForEachElement(
func(_ cty.Value, attributes cty.Value) (stop bool) {
passwordAuth = &management.PasswordAuthenticationMethod{
Enabled: value.Bool(config.GetAttr("enabled")),
}
return stop
})
return passwordAuth
}

func expandConnectionOptionsAuthenticationMethodsPasskey(config cty.Value) *management.PasskeyAuthenticationMethod {
var passwordAuth *management.PasskeyAuthenticationMethod
config.ForEachElement(
func(_ cty.Value, attributes cty.Value) (stop bool) {
passwordAuth = &management.PasskeyAuthenticationMethod{
Enabled: value.Bool(config.GetAttr("enabled")),
}
return stop
})
return passwordAuth
}

func expandConnectionOptionsAttributes(config cty.Value) *management.ConnectionOptionsAttributes {
var coa *management.ConnectionOptionsAttributes
config.ForEachElement(
Expand Down Expand Up @@ -330,6 +367,7 @@ func expandConnectionOptionsAuth0(_ *schema.ResourceData, config cty.Value) (int
Precedence: value.Strings(config.GetAttr("precedence")),
Attributes: expandConnectionOptionsAttributes(config.GetAttr("attributes")),
StrategyVersion: value.Int(config.GetAttr("strategy_version")),
AuthenticationMethods: expandConnectionOptionsAuthenticationMethods(config.GetAttr("authentication_methods")),
}

config.GetAttr("validation").ForEachElement(
Expand Down
1 change: 1 addition & 0 deletions internal/auth0/connection/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func flattenConnectionOptionsAuth0(
"upstream_params": upstreamParams,
"precedence": options.GetPrecedence(),
"strategy_version": options.GetStrategyVersion(),
"authentication_methods": options.GetAuthenticationMethods(),
}

if options.Attributes != nil {
Expand Down

0 comments on commit ebe1824

Please sign in to comment.