Skip to content

Commit 0dabc2d

Browse files
authored
Rename custom_import_state_id_funcs (#15935)
1 parent 8d7edf5 commit 0dabc2d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

mmv1/api/resource/iam_policy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ type IamPolicy struct {
8484
// CompareSelfLinkOrResourceName
8585
CustomDiffSuppress *string `yaml:"custom_diff_suppress,omitempty"`
8686

87-
// StateIDFuncs may use a custom template if default funcs don't work.
88-
CustomImportStateIDFuncs string `yaml:"custom_state_id_funcs"`
87+
// ImportStateIDFuncs may use a custom template if default funcs don't work.
88+
CustomImportStateIDFuncs string `yaml:"custom_import_state_id_funcs"`
8989

9090
// Some resources (IAP) use fields named differently from the parent resource.
9191
// We need to use the parent's attributes to create an IAM policy, but they may not be

mmv1/templates/terraform/iam/iap_web_appengine_state_id_funcs.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func generateIapWebTypeAppEngineIAMPolicyStateID(iamResourceAddr string) func(*t
1111
fmt.Printf("raw state %s\n", rawState)
1212
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
1313
appId := appIdShortName(rawState["app_id"])
14-
return fmt.Sprintf("projects/%s/iap_web/appengine-%s", project, appId) + acctest.ConditionTitleIfPresent(rawState), nil
14+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/iap_web/appengine-%s", project, appId), "", "", rawState["condition.0.title"]), nil
1515
}
1616
}
1717

@@ -28,7 +28,7 @@ func generateIapWebTypeAppEngineIAMBindingStateID(iamResourceAddr string) func(*
2828
fmt.Printf("raw state %s\n", rawState)
2929
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
3030
appId := appIdShortName(rawState["app_id"])
31-
return fmt.Sprintf("projects/%s/iap_web/appengine-%s %s", project, appId, rawState["role"]) + acctest.ConditionTitleIfPresent(rawState), nil
31+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/iap_web/appengine-%s", project, appId), rawState["role"], "", rawState["condition.0.title"]), nil
3232
}
3333
}
3434

@@ -45,7 +45,7 @@ func generateIapWebTypeAppEngineIAMMemberStateID(iamResourceAddr string) func(*t
4545
fmt.Printf("raw state %s\n", rawState)
4646
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
4747
appId := appIdShortName(rawState["app_id"])
48-
return fmt.Sprintf("projects/%s/iap_web/appengine-%s %s %s", project, appId, rawState["role"], rawState["member"]) + acctest.ConditionTitleIfPresent(rawState), nil
48+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/iap_web/appengine-%s", project, appId), rawState["role"], rawState["member"], rawState["condition.0.title"]), nil
4949
}
5050
}
5151

mmv1/templates/terraform/iam/sourcerepo_state_id_funcs.go.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func generateSourceRepoRepositoryIAMPolicyStateID(iamResourceAddr string) func(*
1111
fmt.Printf("raw state %s\n", rawState)
1212
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
1313
repository := repositoryShortName(rawState["repository"])
14-
return fmt.Sprintf("projects/%s/repos/%s", project, repository) + acctest.ConditionTitleIfPresent(rawState), nil
14+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/repos/%s", project, repository), "", "", rawState["condition.0.title"]), nil
1515
}
1616
}
1717

@@ -28,7 +28,7 @@ func generateSourceRepoRepositoryIAMBindingStateID(iamResourceAddr string) func(
2828
fmt.Printf("raw state %s\n", rawState)
2929
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
3030
repository := repositoryShortName(rawState["repository"])
31-
return fmt.Sprintf("projects/%s/repos/%s %s", project, repository, rawState["role"]) + acctest.ConditionTitleIfPresent(rawState), nil
31+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/repos/%s", project, repository), rawState["role"], "", rawState["condition.0.title"]), nil
3232
}
3333
}
3434

@@ -45,7 +45,7 @@ func generateSourceRepoRepositoryIAMMemberStateID(iamResourceAddr string) func(*
4545
fmt.Printf("raw state %s\n", rawState)
4646
project := tpgresource.GetResourceNameFromSelfLink(rawState["project"])
4747
repository := repositoryShortName(rawState["repository"])
48-
return fmt.Sprintf("projects/%s/repos/%s %s %s", project, repository, rawState["role"], rawState["member"]) + acctest.ConditionTitleIfPresent(rawState), nil
48+
return acctest.BuildIAMImportId(fmt.Sprintf("projects/%s/repos/%s", project, repository), rawState["role"], rawState["member"], rawState["condition.0.title"]), nil
4949
}
5050
}
5151

0 commit comments

Comments
 (0)