Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Rework provider configuration fields #3152

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert changing case of boolean parser
sfc-gh-jmichalak committed Oct 28, 2024
commit 4c95204e83774e1396e0c92ef46b44987a2650cb
2 changes: 1 addition & 1 deletion pkg/resources/masking_policy.go
Original file line number Diff line number Diff line change
@@ -217,7 +217,7 @@ func CreateMaskingPolicy(ctx context.Context, d *schema.ResourceData, meta any)
opts.Comment = sdk.String(comment)
}
if v := d.Get("exempt_other_policies").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
16 changes: 8 additions & 8 deletions pkg/resources/oauth_integration_for_custom_clients.go
Original file line number Diff line number Diff line change
@@ -271,23 +271,23 @@ func CreateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem
req := sdk.NewCreateOauthForCustomClientsSecurityIntegrationRequest(id, oauthClientType, d.Get("oauth_redirect_uri").(string))

if v := d.Get("enabled").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
req.WithEnabled(parsedBool)
}

if v := d.Get("oauth_allow_non_tls_redirect_uri").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
req.WithOauthAllowNonTlsRedirectUri(parsedBool)
}

if v := d.Get("oauth_enforce_pkce").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -321,7 +321,7 @@ func CreateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem
}

if v := d.Get("oauth_issue_refresh_tokens").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -545,7 +545,7 @@ func UpdateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem

if d.HasChange("enabled") {
if v := d.Get("enabled").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -557,7 +557,7 @@ func UpdateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem

if d.HasChange("oauth_allow_non_tls_redirect_uri") {
if v := d.Get("oauth_allow_non_tls_redirect_uri").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -570,7 +570,7 @@ func UpdateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem

if d.HasChange("oauth_enforce_pkce") {
if v := d.Get("oauth_enforce_pkce").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -613,7 +613,7 @@ func UpdateContextOauthIntegrationForCustomClients(ctx context.Context, d *schem

if d.HasChange("oauth_issue_refresh_tokens") {
if v := d.Get("oauth_issue_refresh_tokens").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
8 changes: 4 additions & 4 deletions pkg/resources/oauth_integration_for_partner_applications.go
Original file line number Diff line number Diff line change
@@ -224,15 +224,15 @@ func CreateContextOauthIntegrationForPartnerApplications(ctx context.Context, d
}

if v := d.Get("enabled").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
req.WithEnabled(parsedBool)
}

if v := d.Get("oauth_issue_refresh_tokens").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -422,7 +422,7 @@ func UpdateContextOauthIntegrationForPartnerApplications(ctx context.Context, d

if d.HasChange("enabled") {
if v := d.Get("oauth_issue_refresh_tokens").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(d.Get("enabled").(string))
parsedBool, err := booleanStringToBool(d.Get("enabled").(string))
if err != nil {
return diag.FromErr(err)
}
@@ -434,7 +434,7 @@ func UpdateContextOauthIntegrationForPartnerApplications(ctx context.Context, d

if d.HasChange("oauth_issue_refresh_tokens") {
if v := d.Get("oauth_issue_refresh_tokens").(string); v != BooleanDefault {
parsedBool, err := BooleanStringToBool(v)
parsedBool, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
2 changes: 1 addition & 1 deletion pkg/resources/resource_helpers_create.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ func intAttributeWithSpecialDefaultCreate(d *schema.ResourceData, key string, cr

func booleanStringAttributeCreate(d *schema.ResourceData, key string, createField **bool) error {
if v := d.Get(key).(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return err
}
4 changes: 2 additions & 2 deletions pkg/resources/resource_helpers_update.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ func intAttributeWithSpecialDefaultUpdate(d *schema.ResourceData, key string, se
func booleanStringAttributeUpdate(d *schema.ResourceData, key string, setField **bool, unsetField **bool) error {
if d.HasChange(key) {
if v := d.Get(key).(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return err
}
@@ -56,7 +56,7 @@ func booleanStringAttributeUpdate(d *schema.ResourceData, key string, setField *
func booleanStringAttributeUnsetFallbackUpdate(d *schema.ResourceData, key string, setField **bool, fallbackValue bool) error {
if d.HasChange(key) {
if v := d.Get(key).(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return err
}
16 changes: 8 additions & 8 deletions pkg/resources/saml2_integration.go
Original file line number Diff line number Diff line change
@@ -369,7 +369,7 @@ func CreateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,
)

if v := d.Get("enabled").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -381,15 +381,15 @@ func CreateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,
}

if v := d.Get("saml2_enable_sp_initiated").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
req.WithSaml2EnableSpInitiated(parsed)
}

if v := d.Get("saml2_sign_request").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -409,7 +409,7 @@ func CreateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,
}

if v := d.Get("saml2_force_authn").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -657,7 +657,7 @@ func UpdateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,

if d.HasChange("enabled") {
if v := d.Get("enabled").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -696,7 +696,7 @@ func UpdateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,

if d.HasChange("saml2_enable_sp_initiated") {
if v := d.Get("saml2_enable_sp_initiated").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -709,7 +709,7 @@ func UpdateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,

if d.HasChange("saml2_sign_request") {
if v := d.Get("saml2_sign_request").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -742,7 +742,7 @@ func UpdateContextSAML2Integration(ctx context.Context, d *schema.ResourceData,

if d.HasChange("saml2_force_authn") {
if v := d.Get("saml2_force_authn").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
6 changes: 3 additions & 3 deletions pkg/resources/schema.go
Original file line number Diff line number Diff line change
@@ -187,14 +187,14 @@ func CreateContextSchema(ctx context.Context, d *schema.ResourceData, meta any)
}

if v := d.Get("is_transient").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
opts.Transient = sdk.Bool(parsed)
}
if v := d.Get("with_managed_access").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -330,7 +330,7 @@ func UpdateContextSchema(ctx context.Context, d *schema.ResourceData, meta any)
if d.HasChange("with_managed_access") {
if v := d.Get("with_managed_access").(string); v != BooleanDefault {
var err error
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
2 changes: 1 addition & 1 deletion pkg/resources/special_values.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ func booleanStringFromBool(value bool) string {
}
}

func BooleanStringToBool(value string) (bool, error) {
func booleanStringToBool(value string) (bool, error) {
switch value {
case BooleanTrue:
return true, nil
2 changes: 1 addition & 1 deletion pkg/resources/user.go
Original file line number Diff line number Diff line change
@@ -394,7 +394,7 @@ func GetCreateUserFunc(userType sdk.UserType) func(ctx context.Context, d *schem
if userType == sdk.UserTypePerson {
// disable mfa cannot be set in create, we need to alter if set in config
if disableMfa := d.Get("disable_mfa").(string); disableMfa != BooleanDefault {
parsed, err := BooleanStringToBool(disableMfa)
parsed, err := booleanStringToBool(disableMfa)
if err != nil {
diags = append(diags, diag.Diagnostic{
Severity: diag.Warning,
6 changes: 3 additions & 3 deletions pkg/resources/view.go
Original file line number Diff line number Diff line change
@@ -423,7 +423,7 @@ func CreateView(orReplace bool) schema.CreateContextFunc {
d.SetId(helpers.EncodeResourceIdentifier(id))

if v := d.Get("change_tracking").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -889,7 +889,7 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag

if d.HasChange("is_secure") {
if v := d.Get("is_secure").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -906,7 +906,7 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag
}
if d.HasChange("change_tracking") {
if v := d.Get("change_tracking").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
8 changes: 4 additions & 4 deletions pkg/resources/warehouse.go
Original file line number Diff line number Diff line change
@@ -320,7 +320,7 @@ func CreateWarehouse(ctx context.Context, d *schema.ResourceData, meta any) diag
createOptions.AutoSuspend = sdk.Int(v)
}
if v := d.Get("auto_resume").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -336,7 +336,7 @@ func CreateWarehouse(ctx context.Context, d *schema.ResourceData, meta any) diag
createOptions.Comment = sdk.String(v.(string))
}
if v := d.Get("enable_query_acceleration").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -527,7 +527,7 @@ func UpdateWarehouse(ctx context.Context, d *schema.ResourceData, meta any) diag
}
if d.HasChange("auto_resume") {
if v := d.Get("auto_resume").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}
@@ -554,7 +554,7 @@ func UpdateWarehouse(ctx context.Context, d *schema.ResourceData, meta any) diag
}
if d.HasChange("enable_query_acceleration") {
if v := d.Get("enable_query_acceleration").(string); v != BooleanDefault {
parsed, err := BooleanStringToBool(v)
parsed, err := booleanStringToBool(v)
if err != nil {
return diag.FromErr(err)
}