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

Fix plan for google_identity_platform_config always showing a change for phone_number.enabled=false and email.enabled=false #20244

Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .changelog/12255.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note: bug
identityplatform: Fixed perma-diff in `google_identity_platform_config`
```
Original file line number Diff line number Diff line change
Expand Up @@ -840,49 +840,47 @@ func flattenIdentityPlatformConfigSignIn(v interface{}, d *schema.ResourceData,
return []interface{}{transformed}
}
func flattenIdentityPlatformConfigSignInEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
transformed := make(map[string]interface{})

if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
transformed["enabled"] = false
} else {
original := v.(map[string]interface{})

if original["enabled"] == nil {
transformed["enabled"] = false
} else {
transformed["enabled"] = original["enabled"]
}

if original["passwordRequired"] != nil {
transformed["password_required"] = original["passwordRequired"]
}
}
transformed := make(map[string]interface{})
transformed["enabled"] =
flattenIdentityPlatformConfigSignInEmailEnabled(original["enabled"], d, config)
transformed["password_required"] =
flattenIdentityPlatformConfigSignInEmailPasswordRequired(original["passwordRequired"], d, config)
return []interface{}{transformed}
}
func flattenIdentityPlatformConfigSignInEmailEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenIdentityPlatformConfigSignInEmailPasswordRequired(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
return []interface{}{transformed}
}

func flattenIdentityPlatformConfigSignInPhoneNumber(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
transformed := make(map[string]interface{})

if v == nil {
return nil
}
original := v.(map[string]interface{})
if len(original) == 0 {
return nil
transformed["enabled"] = false
} else {
original := v.(map[string]interface{})

if original["enabled"] == nil {
transformed["enabled"] = false
} else {
transformed["enabled"] = original["enabled"]
}

if original["testPhoneNumbers"] != nil {
transformed["test_phone_numbers"] = original["testPhoneNumbers"]
}
}
transformed := make(map[string]interface{})
transformed["enabled"] =
flattenIdentityPlatformConfigSignInPhoneNumberEnabled(original["enabled"], d, config)
transformed["test_phone_numbers"] =
flattenIdentityPlatformConfigSignInPhoneNumberTestPhoneNumbers(original["testPhoneNumbers"], d, config)
return []interface{}{transformed}
}
func flattenIdentityPlatformConfigSignInPhoneNumberEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenIdentityPlatformConfigSignInPhoneNumberTestPhoneNumbers(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
return []interface{}{transformed}
}

func flattenIdentityPlatformConfigSignInAnonymous(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,66 @@ resource "google_identity_platform_config" "default" {
}
`, context)
}

func TestAccIdentityPlatformConfig_identityPlatformConfigWithFalseValuesExample(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"billing_acct": envvar.GetTestBillingAccountFromEnv(t),
"org_id": envvar.GetTestOrgFromEnv(t),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccIdentityPlatformConfig_identityPlatformConfigWithFalseValuesExample(context),
},
{
ResourceName: "google_identity_platform_config.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"client.0.api_key", "client.0.firebase_subdomain"},
},
},
})
}

func testAccIdentityPlatformConfig_identityPlatformConfigWithFalseValuesExample(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_project" "default" {
project_id = "tf-test-my-project-2%{random_suffix}"
name = "tf-test-my-project-2%{random_suffix}"
org_id = "%{org_id}"
billing_account = "%{billing_acct}"
deletion_policy = "DELETE"
labels = {
firebase = "enabled"
}
}

resource "google_project_service" "identitytoolkit" {
project = google_project.default.project_id
service = "identitytoolkit.googleapis.com"
}

resource "google_identity_platform_config" "default" {
project = google_project.default.project_id
autodelete_anonymous_users = false
sign_in {

anonymous {
enabled = false
}
email {
enabled = false
}
phone_number {
enabled = false
}
}
}
`, context)
}