Skip to content

Commit

Permalink
199 - Order of options in form field (#280)
Browse files Browse the repository at this point in the history
Fixes #199
Fixes #281

* * fixed issue with options order not being preserved for `form_field` object

* Update helpers.go

removed debug statement

* Update resource_fusionauth_application.go

* * converting `authorized_redirect_urls` to list instead of set
  • Loading branch information
zaalbarxx authored Jun 17, 2024
1 parent 5f6366c commit aee337f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions fusionauth/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ func handleStringSlice(key string, data *schema.ResourceData) []string {
return handleStringSliceFromSet(data.Get(key).(*schema.Set))
}

func handleStringSliceFromList(list []interface{}) []string {
s := make([]string, 0, len(list))

for _, x := range list {
s = append(s, x.(string))
}

return s
}

func handleStringSliceFromSet(set *schema.Set) []string {
l := set.List()
s := make([]string, 0, len(l))
Expand Down
4 changes: 2 additions & 2 deletions fusionauth/resource_fusionauth_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func newSamlv2Configuration() *schema.Resource {
Description: "The audience for the SAML response sent to back to the service provider from FusionAuth. Some service providers require different audience values than the issuer and this configuration option lets you change the audience in the response.",
},
"authorized_redirect_urls": {
Type: schema.TypeSet,
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
Description: "An array of URLs that are the authorized redirect URLs for FusionAuth OAuth.",
Expand Down Expand Up @@ -587,7 +587,7 @@ func newOAuthConfiguration() *schema.Resource {
Description: "An array of URLs that are the authorized origins for FusionAuth OAuth.",
},
"authorized_redirect_urls": {
Type: schema.TypeSet,
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "An array of URLs that are the authorized redirect URLs for FusionAuth OAuth.",
Expand Down
4 changes: 2 additions & 2 deletions fusionauth/resource_fusionauth_application_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func buildApplication(data *schema.ResourceData) fusionauth.Application {
Name: data.Get("name").(string),
OauthConfiguration: fusionauth.OAuth2Configuration{
AuthorizedOriginURLs: handleStringSlice("oauth_configuration.0.authorized_origin_urls", data),
AuthorizedRedirectURLs: handleStringSlice("oauth_configuration.0.authorized_redirect_urls", data),
AuthorizedRedirectURLs: handleStringSliceFromList(data.Get("oauth_configuration.0.authorized_redirect_urls").([]interface{})),
AuthorizedURLValidationPolicy: fusionauth.Oauth2AuthorizedURLValidationPolicy(data.Get("oauth_configuration.0.authorized_url_validation_policy").(string)),
ClientAuthenticationPolicy: fusionauth.ClientAuthenticationPolicy(data.Get("oauth_configuration.0.client_authentication_policy").(string)),
ClientSecret: data.Get("oauth_configuration.0.client_secret").(string),
Expand Down Expand Up @@ -109,7 +109,7 @@ func buildApplication(data *schema.ResourceData) fusionauth.Application {
Samlv2Configuration: fusionauth.SAMLv2Configuration{
Enableable: buildEnableable("samlv2_configuration.0.enabled", data),
Audience: data.Get("samlv2_configuration.0.audience").(string),
AuthorizedRedirectURLs: handleStringSlice("samlv2_configuration.0.authorized_redirect_urls", data),
AuthorizedRedirectURLs: handleStringSliceFromList(data.Get("samlv2_configuration.0.authorized_redirect_urls").([]interface{})),
CallbackURL: data.Get("samlv2_configuration.0.callback_url").(string),
Debug: data.Get("samlv2_configuration.0.debug").(bool),
DefaultVerificationKeyId: data.Get("samlv2_configuration.0.default_verification_key_id").(string),
Expand Down
4 changes: 2 additions & 2 deletions fusionauth/resource_fusionauth_form_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func resourceFormField() *schema.Resource {
Description: "The unique name of the Form Field.",
},
"options": {
Type: schema.TypeSet,
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Description: "A list of options that are applied to checkbox, radio, or select controls.",
Expand Down Expand Up @@ -208,7 +208,7 @@ func buildFormField(data *schema.ResourceData) fusionauth.FormField {
Description: data.Get("description").(string),
Key: data.Get("key").(string),
Name: data.Get("name").(string),
Options: handleStringSlice("options", data),
Options: handleStringSliceFromList(data.Get("options").([]interface{})),
Required: data.Get("required").(bool),
Type: fusionauth.FormDataType(data.Get("type").(string)),
Validator: fusionauth.FormFieldValidator{
Expand Down

0 comments on commit aee337f

Please sign in to comment.