Skip to content

Commit

Permalink
Add force_destroy flag to CodeRepositoryIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
JumiDeluxe committed Jan 10, 2025
1 parent 2860880 commit b83073f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions mmv1/products/gemini/CodeRepositoryIndex.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ custom_code:
error_retry_predicates:
- 'transport_tpg.IsCodeRepositoryIndexUnreadyError'
- 'transport_tpg.IsRepositoryGroupQueueError'
virtual_fields:
- name: 'force_destroy'
description:
If set to true, any RepositoryGroups for this CodeRepositoryIndex will also be deleted.
type: Boolean
default_value: false
parameters:
- name: location
type: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{{- if ne $.TargetVersionName "ga" -}}
obj = make(map[string]interface{})
obj["force"] = true
{{- end }}
if v, ok := d.GetOk("force_destroy"); ok {
if v == true {
obj["force"] = true
}
}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TestAccGeminiCodeRepositoryIndex_delete(t *testing.T) {
ResourceName: "google_gemini_code_repository_index.example",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"code_repository_index_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"code_repository_index_id", "labels", "location", "terraform_labels", "force_destroy"},
},
{
Config: testAccGeminiCodeRepositoryIndex_withChildren_delete(context),
Expand All @@ -88,6 +88,7 @@ resource "google_gemini_code_repository_index" "example" {
labels = {"ccfe_debug_note": "terraform_e2e_should_be_deleted"}
location = "us-central1"
code_repository_index_id = "%{cri_id}"
force_destroy = true
}

resource "google_gemini_repository_group" "example" {
Expand All @@ -100,6 +101,9 @@ resource "google_gemini_repository_group" "example" {
branch_pattern = "main"
}
labels = {"label1": "value1"}
depends_on = [
google_gemini_code_repository_index.example
]
}

resource "google_developer_connect_git_repository_link" "conn" {
Expand Down Expand Up @@ -129,6 +133,7 @@ resource "google_developer_connect_connection" "github_conn" {
`, context)
}

// Removed depends_on to not break plan test
func testAccGeminiCodeRepositoryIndex_withChildren_delete(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_gemini_repository_group" "example" {
Expand Down

0 comments on commit b83073f

Please sign in to comment.