From b0537879b3fb18d74913f4e176e25f9af0213b4d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 13:59:49 -0800 Subject: [PATCH 01/52] services diff gha --- .../teamcity-services-diff-check.yml | 47 +++++++++++ .../.teamcity/components/inputs/diff_check.go | 82 +++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 .github/workflows/teamcity-services-diff-check.yml create mode 100644 mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml new file mode 100644 index 000000000000..ad4eb032dbdd --- /dev/null +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -0,0 +1,47 @@ +name: TeamCity Services Diff Check +permissions: read-all + +on: + workflow_dispatch: + pull_request: + paths: + - '.github/workflows/teamcity-services-diff-check.yml' + - 'mmv1/third_party/terraform/!.teamcity' +jobs: + terraform-provider-google: + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google' + + teamcity-services-diff-check-ga: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '^1.20.1' + + - name: Cache Go modules and build cache + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-test-terraform-provider-google-${{hashFiles('go.sum','google-*/transport/**','google-*/tpgresource/**','google-*/acctest/**','google-*/envvar/**','google-*/sweeper/**','google-*/verify/**') }} + restore-keys: | + ${{ runner.os }}-test-terraform-provider-google-${{ hashFiles('go.sum') }} + ${{ runner.os }}-test-terraform-provider-google- + + - name: Build Provider + run: | + go build + + - name: Diff Check + run: | + cd mmv1/third_party/terraform/.teamcity/components/inputs + go run diff_check.go \ No newline at end of file diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go new file mode 100644 index 000000000000..987b8763a579 --- /dev/null +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -0,0 +1,82 @@ +// This file is controlled by MMv1, any changes made here will be overwritten + +package main + +import ( + "bufio" + "bytes" + "fmt" + "io" + "os" + "os/exec" + "regexp" +) + +func main() { + cmd := exec.Command("go", "list", "../../../google/services/...") + stdout, err := cmd.Output() + fmt.Println(stdout) + if err != nil { + fmt.Println(err.Error()) + return + } + + pattern := regexp.MustCompile(`github\.com\/hashicorp\/terraform-provider-google\/google\/services\/(?P\w+)`) + + // Template to convert "key: value" to "key=value" by + // referencing the values captured by the regex pattern. + template := []byte("$service\n") + + googleServices := []byte{} + + // For each match of the regex in the content. + for _, submatches := range pattern.FindAllSubmatchIndex(stdout, -1) { + // Apply the captured submatches to the template and append the output + // to the result. + googleServices = pattern.Expand(googleServices, template, stdout, submatches) + } + + //////////////////////////////////////////////////////////////////////////////// + + f, err := os.Open("services_ga.kt") + if err != nil { + panic(err) + } + + // Get the file size + stat, err := f.Stat() + if err != nil { + fmt.Println(err) + return + } + + // Read the file into a byte slice + bs := make([]byte, stat.Size()) + _, err = bufio.NewReader(f).Read(bs) + if err != nil && err != io.EOF { + fmt.Println(err) + return + } + + // Regex pattern captures "key: value" pair from the content. + pattern = regexp.MustCompile(`(?m)"(?P\w+)"\sto\s+mapOf`) + + // Template to convert "key: value" to "key=value" by + // referencing the values captured by the regex pattern. + template = []byte("$service\n") + + teamcityServices := []byte{} + + // For each match of the regex in the content. + for _, submatches := range pattern.FindAllSubmatchIndex(bs, -1) { + // Apply the captured submatches to the template and append the output + // to the result. + teamcityServices = pattern.Expand(teamcityServices, template, bs, submatches) + } + + if bytes.Equal(googleServices, teamcityServices) { + fmt.Println("No Changes!") + } else { + fmt.Println("Diff") + } +} From 15b29ce705053b4a32d87efdaa20ddb28150ffbc Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 14:30:08 -0800 Subject: [PATCH 02/52] add needs --- .github/workflows/teamcity-services-diff-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index ad4eb032dbdd..c62de51daecc 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -14,6 +14,7 @@ jobs: repo: 'terraform-provider-google' teamcity-services-diff-check-ga: + needs: terraform-provider-google runs-on: ubuntu-22.04 steps: - name: Checkout Repository From bf4d864c3b2fa2969f6e43f93633dcda99c89378 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 14:41:08 -0800 Subject: [PATCH 03/52] use setup-go@v3 --- .github/workflows/teamcity-services-diff-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index c62de51daecc..0570384bab13 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -23,9 +23,9 @@ jobs: fetch-depth: 0 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v3 with: - go-version: '^1.20.1' + go-version: '^1.20' - name: Cache Go modules and build cache uses: actions/cache@v3 From 1b02395503288d8eed1d7f063d195f12260a45f0 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 15:16:42 -0800 Subject: [PATCH 04/52] add artifacts --- .github/workflows/teamcity-services-diff-check.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 0570384bab13..317730b963a3 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -22,6 +22,17 @@ jobs: with: fetch-depth: 0 + - name: Download built artifacts + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip artifacts/output.zip -d ./ + rm artifacts/output.zip + - name: Setup Go uses: actions/setup-go@v3 with: From 2e46cd832d6b0647531b3bd8242e6480ab332eab Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 15:27:29 -0800 Subject: [PATCH 05/52] remove checkout --- .github/workflows/teamcity-services-diff-check.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 317730b963a3..2a5eca429bda 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -17,11 +17,6 @@ jobs: needs: terraform-provider-google runs-on: ubuntu-22.04 steps: - - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - fetch-depth: 0 - - name: Download built artifacts uses: actions/download-artifact@v2 with: From 39f413d3144d1c56b99a9cb7fef23e9bf622de2c Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 16:05:13 -0800 Subject: [PATCH 06/52] update directory --- .github/workflows/teamcity-services-diff-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 2a5eca429bda..a0a1cfb16082 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -50,5 +50,5 @@ jobs: - name: Diff Check run: | - cd mmv1/third_party/terraform/.teamcity/components/inputs + cd .teamcity/components/inputs go run diff_check.go \ No newline at end of file From 4f4fd37bdf9d9d2bb454a571842da751be4064b5 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 16:34:18 -0800 Subject: [PATCH 07/52] update common-copy.yaml --- mmv1/provider/terraform/common~copy.yaml | 4 ++++ .../terraform/.teamcity/components/inputs/diff_check.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/mmv1/provider/terraform/common~copy.yaml b/mmv1/provider/terraform/common~copy.yaml index 1409c612a3f6..7c93312a77c6 100644 --- a/mmv1/provider/terraform/common~copy.yaml +++ b/mmv1/provider/terraform/common~copy.yaml @@ -145,6 +145,10 @@ Dir["third_party/terraform/.teamcity/**/*.kt"].each do |file_path| fname = file_path.delete_prefix("third_party/terraform/") -%> +<% + Dir["third_party/terraform/.teamcity/**/*.go"].each do |file_path| + fname = file_path.delete_prefix("third_party/terraform/") +-%> '<%= fname -%>': '<%= file_path -%>' <% end -%> <% diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index 987b8763a579..c4715d126f60 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -1,3 +1,8 @@ +/* + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ + // This file is controlled by MMv1, any changes made here will be overwritten package main From ae84cde7a97b822ff0410a9f278e8f2d553706a7 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 16:39:33 -0800 Subject: [PATCH 08/52] update common-copy.yaml --- mmv1/provider/terraform/common~copy.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mmv1/provider/terraform/common~copy.yaml b/mmv1/provider/terraform/common~copy.yaml index 7c93312a77c6..6b7d551d2e2e 100644 --- a/mmv1/provider/terraform/common~copy.yaml +++ b/mmv1/provider/terraform/common~copy.yaml @@ -145,6 +145,8 @@ Dir["third_party/terraform/.teamcity/**/*.kt"].each do |file_path| fname = file_path.delete_prefix("third_party/terraform/") -%> +'<%= fname -%>': '<%= file_path -%>' +<% end -%> <% Dir["third_party/terraform/.teamcity/**/*.go"].each do |file_path| fname = file_path.delete_prefix("third_party/terraform/") From 4cbb81350ca916de4939884f3f719f4e0a05bfbd Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 16:47:26 -0800 Subject: [PATCH 09/52] remove data print --- .../terraform/.teamcity/components/inputs/diff_check.go | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index c4715d126f60..54d3ebba6bc4 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -20,7 +20,6 @@ import ( func main() { cmd := exec.Command("go", "list", "../../../google/services/...") stdout, err := cmd.Output() - fmt.Println(stdout) if err != nil { fmt.Println(err.Error()) return From e3114e8bb328be328d7bcaa08e6a7fb7f073140c Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 16:50:25 -0800 Subject: [PATCH 10/52] add pull-request check on teamcitydiff --- .github/workflows/teamcity-services-diff-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index a0a1cfb16082..80301137c74f 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -4,6 +4,7 @@ permissions: read-all on: workflow_dispatch: pull_request: + types: [opened, edited] paths: - '.github/workflows/teamcity-services-diff-check.yml' - 'mmv1/third_party/terraform/!.teamcity' From 205b5507d88ff86a35dde8710a02a9ac08aaf3c3 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 17:00:17 -0800 Subject: [PATCH 11/52] update paths in GHA --- .github/workflows/teamcity-services-diff-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index 80301137c74f..a76ad51306a6 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -7,7 +7,7 @@ on: types: [opened, edited] paths: - '.github/workflows/teamcity-services-diff-check.yml' - - 'mmv1/third_party/terraform/!.teamcity' + - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt' jobs: terraform-provider-google: uses: ./.github/workflows/build-downstream.yml From 3c16df3e1a4308a7327d0ca767fe95290935a626 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 18:07:53 -0800 Subject: [PATCH 12/52] add exit code in diff_check --- .../terraform/.teamcity/components/inputs/diff_check.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index 54d3ebba6bc4..8e6608e7664f 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -78,9 +78,8 @@ func main() { teamcityServices = pattern.Expand(teamcityServices, template, bs, submatches) } - if bytes.Equal(googleServices, teamcityServices) { - fmt.Println("No Changes!") - } else { - fmt.Println("Diff") + if !bytes.Equal(googleServices, teamcityServices) { + fmt.Fprintf(os.Stderr, "error: diff in services_ga.kt") + os.Exit(1) } } From b1cd675fe5c325f16792a670404b5a3052a3c0ba Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 18:18:02 -0800 Subject: [PATCH 13/52] update exit output --- .../terraform/.teamcity/components/inputs/diff_check.go | 1 - 1 file changed, 1 deletion(-) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index 8e6608e7664f..28da2c6c20b2 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -80,6 +80,5 @@ func main() { if !bytes.Equal(googleServices, teamcityServices) { fmt.Fprintf(os.Stderr, "error: diff in services_ga.kt") - os.Exit(1) } } From 5971c660d4a48908f254d1779c48163ba5e38bae Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 18:48:45 -0800 Subject: [PATCH 14/52] add exit code diff_check.go --- .../terraform/.teamcity/components/inputs/diff_check.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index 28da2c6c20b2..d93a093e008c 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -79,6 +79,7 @@ func main() { } if !bytes.Equal(googleServices, teamcityServices) { - fmt.Fprintf(os.Stderr, "error: diff in services_ga.kt") + fmt.Fprintf(os.Stderr, "error: diff in services_ga.kt\n") + os.Exit(1) } } From 38cfdb1778094bcdf8540c7583e3c3e062e4d21b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 19:18:01 -0800 Subject: [PATCH 15/52] services_beta diff check support --- .../teamcity-services-diff-check-beta.yml | 55 +++++++++++++++++++ ...ml => teamcity-services-diff-check-ga.yml} | 4 +- .../.teamcity/components/inputs/diff_check.go | 2 +- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/teamcity-services-diff-check-beta.yml rename .github/workflows/{teamcity-services-diff-check.yml => teamcity-services-diff-check-ga.yml} (93%) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml new file mode 100644 index 000000000000..d8c6a94954cb --- /dev/null +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -0,0 +1,55 @@ +name: TeamCity Services Diff Check Beta +permissions: read-all + +on: + workflow_dispatch: + pull_request: + types: [opened, edited] + paths: + - '.github/workflows/teamcity-services-diff-check-beta.yml' + - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt' +jobs: + terraform-provider-google-beta: + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google-beta' + + teamcity-services-diff-check-ga: + needs: terraform-provider-google-beta + runs-on: ubuntu-22.04 + steps: + - name: Download built artifacts + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google-beta + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip artifacts/output.zip -d ./ + rm artifacts/output.zip + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '^1.20' + + - name: Cache Go modules and build cache + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-test-terraform-provider-google-beta-${{hashFiles('go.sum','google-beta-*/transport/**','google-beta-*/tpgresource/**','google-beta-*/acctest/**','google-*/envvar/**','google-beta-*/sweeper/**','google-beta-*/verify/**') }} + restore-keys: | + ${{ runner.os }}-test-terraform-provider-google-beta-${{ hashFiles('go.sum') }} + ${{ runner.os }}-test-terraform-provider-google-beta + + - name: Build Provider + run: | + go build + + - name: Diff Check + run: | + cd .teamcity/components/inputs + go run diff_check.go \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check-ga.yml similarity index 93% rename from .github/workflows/teamcity-services-diff-check.yml rename to .github/workflows/teamcity-services-diff-check-ga.yml index a76ad51306a6..36e9bf1a338f 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -1,4 +1,4 @@ -name: TeamCity Services Diff Check +name: TeamCity Services Diff Check GA permissions: read-all on: @@ -6,7 +6,7 @@ on: pull_request: types: [opened, edited] paths: - - '.github/workflows/teamcity-services-diff-check.yml' + - '.github/workflows/teamcity-services-diff-check-ga.yml' - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt' jobs: terraform-provider-google: diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index d93a093e008c..c98637f86adf 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -25,7 +25,7 @@ func main() { return } - pattern := regexp.MustCompile(`github\.com\/hashicorp\/terraform-provider-google\/google\/services\/(?P\w+)`) + pattern := regexp.MustCompile(`github\.com\/hashicorp\/terraform-provider-(google|google-beta)\/(google|google-beta)\/services\/(?P\w+)`) // Template to convert "key: value" to "key=value" by // referencing the values captured by the regex pattern. From 3e0e56b4e9c08f71b3704633f8796bfae2035349 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 19:41:57 -0800 Subject: [PATCH 16/52] beta services support args --- .github/workflows/teamcity-services-diff-check-beta.yml | 2 +- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- .../terraform/.teamcity/components/inputs/diff_check.go | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index d8c6a94954cb..3a3b838ef98e 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -52,4 +52,4 @@ jobs: - name: Diff Check run: | cd .teamcity/components/inputs - go run diff_check.go \ No newline at end of file + go run diff_check.go google-beta \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 36e9bf1a338f..8449deec34cf 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -52,4 +52,4 @@ jobs: - name: Diff Check run: | cd .teamcity/components/inputs - go run diff_check.go \ No newline at end of file + go run diff_check.go google \ No newline at end of file diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index c98637f86adf..895398e21933 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -1,3 +1,5 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 /* * Copyright (c) HashiCorp, Inc. * SPDX-License-Identifier: MPL-2.0 @@ -18,7 +20,10 @@ import ( ) func main() { - cmd := exec.Command("go", "list", "../../../google/services/...") + repo := os.Args + services := fmt.Sprintf("../../../%v/services/...", repo[1]) + fmt.Println(services) + cmd := exec.Command("go", "list", services) stdout, err := cmd.Output() if err != nil { fmt.Println(err.Error()) From 590b54bdadd3dafc53f60c9d1c8bb93f2e870122 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 19:53:46 -0800 Subject: [PATCH 17/52] add arg for services kt file --- .github/workflows/teamcity-services-diff-check-beta.yml | 4 ++-- .../terraform/.teamcity/components/inputs/diff_check.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 3a3b838ef98e..2bc966427460 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -14,7 +14,7 @@ jobs: with: repo: 'terraform-provider-google-beta' - teamcity-services-diff-check-ga: + teamcity-services-diff-check-beta: needs: terraform-provider-google-beta runs-on: ubuntu-22.04 steps: @@ -52,4 +52,4 @@ jobs: - name: Diff Check run: | cd .teamcity/components/inputs - go run diff_check.go google-beta \ No newline at end of file + go run diff_check.go google-beta services_beta.kt \ No newline at end of file diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go index 895398e21933..eed74d6c43e2 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go @@ -47,7 +47,8 @@ func main() { //////////////////////////////////////////////////////////////////////////////// - f, err := os.Open("services_ga.kt") + service_file := os.Args[2] + f, err := os.Open(service_file) if err != nil { panic(err) } From a9e631f86d86fcd1c77cb53a508c2062721479d5 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Thu, 15 Feb 2024 20:03:40 -0800 Subject: [PATCH 18/52] services_ga.kt in gha --- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 8449deec34cf..66ec44d18555 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -52,4 +52,4 @@ jobs: - name: Diff Check run: | cd .teamcity/components/inputs - go run diff_check.go google \ No newline at end of file + go run diff_check.go google services_ga.kt \ No newline at end of file From 25819d845794a5a49ebbc85237ec6cc1549ea667 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 12:06:03 -0800 Subject: [PATCH 19/52] move diff_check to tools folder --- .../workflows/teamcity-services-diff-check-beta.yml | 2 ++ .../workflows/teamcity-services-diff-check-ga.yml | 10 ++++++++-- .../teamcity-diff-check/main.go | 13 ++++++++----- 3 files changed, 18 insertions(+), 7 deletions(-) rename mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go => tools/teamcity-diff-check/main.go (85%) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 2bc966427460..20121b4b29e8 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -18,6 +18,8 @@ jobs: needs: terraform-provider-google-beta runs-on: ubuntu-22.04 steps: + - uses: actions/checkout@v3 + - name: Download built artifacts uses: actions/download-artifact@v2 with: diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 66ec44d18555..fb4e5d85b4d8 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -18,6 +18,12 @@ jobs: needs: terraform-provider-google runs-on: ubuntu-22.04 steps: + - uses: actions/checkout@v3 + + - name: this + run: | + cd tools/teamcity-diff-check + go run main.go google services_ga.kt - name: Download built artifacts uses: actions/download-artifact@v2 with: @@ -51,5 +57,5 @@ jobs: - name: Diff Check run: | - cd .teamcity/components/inputs - go run diff_check.go google services_ga.kt \ No newline at end of file + cd tools/teamcity-diff-check + go run main.go google services_ga.kt \ No newline at end of file diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go b/tools/teamcity-diff-check/main.go similarity index 85% rename from mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go rename to tools/teamcity-diff-check/main.go index eed74d6c43e2..11a44f5785ec 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/diff_check.go +++ b/tools/teamcity-diff-check/main.go @@ -12,6 +12,7 @@ package main import ( "bufio" "bytes" + "flag" "fmt" "io" "os" @@ -19,9 +20,12 @@ import ( "regexp" ) +var serviceFile = flag.String("service_file", "services_ga.kt", "kotlin service file to be parsed") +var provider = flag.String("provider", "google", "Specify which provider to run diff_check on") + func main() { - repo := os.Args - services := fmt.Sprintf("../../../%v/services/...", repo[1]) + flag.Parse() + services := fmt.Sprintf("../%v/services/...", *provider) fmt.Println(services) cmd := exec.Command("go", "list", services) stdout, err := cmd.Output() @@ -47,8 +51,7 @@ func main() { //////////////////////////////////////////////////////////////////////////////// - service_file := os.Args[2] - f, err := os.Open(service_file) + f, err := os.Open(*serviceFile) if err != nil { panic(err) } @@ -85,7 +88,7 @@ func main() { } if !bytes.Equal(googleServices, teamcityServices) { - fmt.Fprintf(os.Stderr, "error: diff in services_ga.kt\n") + fmt.Fprintf(os.Stderr, "error: diff in %s\n", *serviceFile) os.Exit(1) } } From 860418831cee9a545e1bad93f81dcd899382d5a0 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 12:06:43 -0800 Subject: [PATCH 20/52] remove go command --- .github/workflows/teamcity-services-diff-check-ga.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index fb4e5d85b4d8..e86cfd06c84f 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -20,10 +20,6 @@ jobs: steps: - uses: actions/checkout@v3 - - name: this - run: | - cd tools/teamcity-diff-check - go run main.go google services_ga.kt - name: Download built artifacts uses: actions/download-artifact@v2 with: From fdcc36e3e9b3f771001e68cf7358072fe00f5f2b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 12:17:31 -0800 Subject: [PATCH 21/52] provide path for artifacts download --- .github/workflows/teamcity-services-diff-check-beta.yml | 4 ++-- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- tools/teamcity-diff-check/main.go | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 20121b4b29e8..a1c4e50eeaf6 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - + - name: Download built artifacts uses: actions/download-artifact@v2 with: @@ -28,7 +28,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./ + unzip artifacts/output.zip -d ./tgbp rm artifacts/output.zip - name: Setup Go diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index e86cfd06c84f..85c70e8b14a2 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -28,7 +28,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./ + unzip artifacts/output.zip -d ./tgp rm artifacts/output.zip - name: Setup Go diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 11a44f5785ec..fe2d66809450 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -25,7 +25,13 @@ var provider = flag.String("provider", "google", "Specify which provider to run func main() { flag.Parse() - services := fmt.Sprintf("../%v/services/...", *provider) + var providerPath string + if *provider == "google" { + providerPath = "tgp" + } else { + providerPath = "tgbp" + } + services := fmt.Sprintf("../%s/%s/services/...", providerPath, *provider) fmt.Println(services) cmd := exec.Command("go", "list", services) stdout, err := cmd.Output() From 96a8d3d1671cb5cc67a1d1cb810eb0230b461731 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 12:25:48 -0800 Subject: [PATCH 22/52] add cd in Build Provider --- .github/workflows/teamcity-services-diff-check-beta.yml | 1 + .github/workflows/teamcity-services-diff-check-ga.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index a1c4e50eeaf6..fc1e1efe5227 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -49,6 +49,7 @@ jobs: - name: Build Provider run: | + cd tgbp go build - name: Diff Check diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 85c70e8b14a2..97b5a546f33e 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -49,6 +49,7 @@ jobs: - name: Build Provider run: | + cd tgp go build - name: Diff Check From dcde4c7558a6171a9fe42003d5fe6c0625b0d8b8 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 12:44:26 -0800 Subject: [PATCH 23/52] update diff_check_beta.yml --- .github/workflows/teamcity-services-diff-check-beta.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index fc1e1efe5227..76dcecc4d37a 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -54,5 +54,5 @@ jobs: - name: Diff Check run: | - cd .teamcity/components/inputs - go run diff_check.go google-beta services_beta.kt \ No newline at end of file + cd tools/teamcity-diff-check + go run main.go google-beta services_beta.kt \ No newline at end of file From 71b79970e3dd6f7e5b8ddd7168e1049259d890bf Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 13:05:33 -0800 Subject: [PATCH 24/52] fix paths --- .github/workflows/teamcity-services-diff-check-beta.yml | 2 +- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- tools/teamcity-diff-check/main.go | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 76dcecc4d37a..93029172b485 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -55,4 +55,4 @@ jobs: - name: Diff Check run: | cd tools/teamcity-diff-check - go run main.go google-beta services_beta.kt \ No newline at end of file + go run main.go -provide=google-beta -service_file=services_beta.kt \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 97b5a546f33e..77aa20f849e6 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -55,4 +55,4 @@ jobs: - name: Diff Check run: | cd tools/teamcity-diff-check - go run main.go google services_ga.kt \ No newline at end of file + go run main.go \ No newline at end of file diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index fe2d66809450..0c7e669e4b30 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -31,8 +31,7 @@ func main() { } else { providerPath = "tgbp" } - services := fmt.Sprintf("../%s/%s/services/...", providerPath, *provider) - fmt.Println(services) + services := fmt.Sprintf("../../%s/%s/services/...", providerPath, *provider) cmd := exec.Command("go", "list", services) stdout, err := cmd.Output() if err != nil { @@ -57,7 +56,7 @@ func main() { //////////////////////////////////////////////////////////////////////////////// - f, err := os.Open(*serviceFile) + f, err := os.Open(fmt.Sprintf("../../%s/.teamcity/components/inputs/%s", providerPath, *serviceFile)) if err != nil { panic(err) } From 8d1a00351ec6db47c19b1acb8f9811cf005a41e4 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 13:11:24 -0800 Subject: [PATCH 25/52] yml typo beta --- .github/workflows/teamcity-services-diff-check-beta.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 93029172b485..dac36a3a32f3 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -55,4 +55,4 @@ jobs: - name: Diff Check run: | cd tools/teamcity-diff-check - go run main.go -provide=google-beta -service_file=services_beta.kt \ No newline at end of file + go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file From 95ad36466f8d2dfb62222a883aa3aa291cb48933 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 13:32:53 -0800 Subject: [PATCH 26/52] directory testing --- .github/workflows/teamcity-services-diff-check-beta.yml | 1 + .github/workflows/teamcity-services-diff-check-ga.yml | 1 + tools/teamcity-diff-check/main.go | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index dac36a3a32f3..1bcec14c364d 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -54,5 +54,6 @@ jobs: - name: Diff Check run: | + pwd cd tools/teamcity-diff-check go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 77aa20f849e6..0191e0e91430 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -54,5 +54,6 @@ jobs: - name: Diff Check run: | + pwd cd tools/teamcity-diff-check go run main.go \ No newline at end of file diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 0c7e669e4b30..c33b0f87913d 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -35,7 +35,7 @@ func main() { cmd := exec.Command("go", "list", services) stdout, err := cmd.Output() if err != nil { - fmt.Println(err.Error()) + fmt.Println(err) return } From af8422e705fede18c083d60a1e5eed01396f5d1e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 14:59:38 -0800 Subject: [PATCH 27/52] directory testing --- .github/workflows/teamcity-services-diff-check-ga.yml | 1 + tools/teamcity-diff-check/main.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 0191e0e91430..83ae44081532 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -50,6 +50,7 @@ jobs: - name: Build Provider run: | cd tgp + ls go build - name: Diff Check diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index c33b0f87913d..958de2116fe1 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -96,4 +96,6 @@ func main() { fmt.Fprintf(os.Stderr, "error: diff in %s\n", *serviceFile) os.Exit(1) } + + fmt.Println("No Diff") } From 8ef04c934f2b976ca472ff001cce033582f4f85d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 16:09:54 -0800 Subject: [PATCH 28/52] fix directory issues with commands --- .../teamcity-services-diff-check-beta.yml | 7 +------ .../teamcity-services-diff-check-ga.yml | 8 +------- tools/teamcity-diff-check/main.go | 20 ++++++++----------- 3 files changed, 10 insertions(+), 25 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml index 1bcec14c364d..0dbd91cc295a 100644 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ b/.github/workflows/teamcity-services-diff-check-beta.yml @@ -28,7 +28,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./tgbp + unzip artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Setup Go @@ -47,11 +47,6 @@ jobs: ${{ runner.os }}-test-terraform-provider-google-beta-${{ hashFiles('go.sum') }} ${{ runner.os }}-test-terraform-provider-google-beta - - name: Build Provider - run: | - cd tgbp - go build - - name: Diff Check run: | pwd diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 83ae44081532..f63aad0ae62e 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -28,7 +28,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./tgp + unzip artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Setup Go @@ -47,12 +47,6 @@ jobs: ${{ runner.os }}-test-terraform-provider-google-${{ hashFiles('go.sum') }} ${{ runner.os }}-test-terraform-provider-google- - - name: Build Provider - run: | - cd tgp - ls - go build - - name: Diff Check run: | pwd diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 958de2116fe1..7b01b6921b72 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -25,17 +25,13 @@ var provider = flag.String("provider", "google", "Specify which provider to run func main() { flag.Parse() - var providerPath string - if *provider == "google" { - providerPath = "tgp" - } else { - providerPath = "tgbp" - } - services := fmt.Sprintf("../../%s/%s/services/...", providerPath, *provider) - cmd := exec.Command("go", "list", services) + + servicesPath := fmt.Sprintf("../../provider/%s/services/", *provider) + cmd := exec.Command("go", "list", "./...") + cmd.Dir = servicesPath stdout, err := cmd.Output() if err != nil { - fmt.Println(err) + fmt.Println(err.Error()) return } @@ -43,7 +39,7 @@ func main() { // Template to convert "key: value" to "key=value" by // referencing the values captured by the regex pattern. - template := []byte("$service\n") + template := []byte("$service") googleServices := []byte{} @@ -56,7 +52,7 @@ func main() { //////////////////////////////////////////////////////////////////////////////// - f, err := os.Open(fmt.Sprintf("../../%s/.teamcity/components/inputs/%s", providerPath, *serviceFile)) + f, err := os.Open(fmt.Sprintf("../../provider/.teamcity/components/inputs/%s", *serviceFile)) if err != nil { panic(err) } @@ -81,7 +77,7 @@ func main() { // Template to convert "key: value" to "key=value" by // referencing the values captured by the regex pattern. - template = []byte("$service\n") + template = []byte("$service") teamcityServices := []byte{} From d1f73bae428cc17d9944a667005627a34b9fd188 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Fri, 16 Feb 2024 16:36:16 -0800 Subject: [PATCH 29/52] refactor tools/teamcity-diff-check/main.go --- tools/teamcity-diff-check/main.go | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 7b01b6921b72..02995cd53d1f 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -11,12 +11,12 @@ package main import ( "bufio" - "bytes" "flag" "fmt" "io" "os" "os/exec" + "reflect" "regexp" ) @@ -35,19 +35,18 @@ func main() { return } + // Regex pattern captures "services" from `go list ../../provider/{{*provider}}/services/..` pattern := regexp.MustCompile(`github\.com\/hashicorp\/terraform-provider-(google|google-beta)\/(google|google-beta)\/services\/(?P\w+)`) - // Template to convert "key: value" to "key=value" by - // referencing the values captured by the regex pattern. template := []byte("$service") + dst := []byte{} - googleServices := []byte{} + googleServices := []string{} // For each match of the regex in the content. for _, submatches := range pattern.FindAllSubmatchIndex(stdout, -1) { - // Apply the captured submatches to the template and append the output - // to the result. - googleServices = pattern.Expand(googleServices, template, stdout, submatches) + service := pattern.Expand(dst, template, stdout, submatches) + googleServices = append(googleServices, string(service)) } //////////////////////////////////////////////////////////////////////////////// @@ -72,23 +71,21 @@ func main() { return } - // Regex pattern captures "key: value" pair from the content. + // Regex pattern captures "services" from *serviceFile. pattern = regexp.MustCompile(`(?m)"(?P\w+)"\sto\s+mapOf`) - // Template to convert "key: value" to "key=value" by - // referencing the values captured by the regex pattern. template = []byte("$service") - teamcityServices := []byte{} + dst = []byte{} + teamcityServices := []string{} // For each match of the regex in the content. for _, submatches := range pattern.FindAllSubmatchIndex(bs, -1) { - // Apply the captured submatches to the template and append the output - // to the result. - teamcityServices = pattern.Expand(teamcityServices, template, bs, submatches) + service := pattern.Expand(dst, template, bs, submatches) + teamcityServices = append(teamcityServices, string(service)) } - if !bytes.Equal(googleServices, teamcityServices) { + if !reflect.DeepEqual(googleServices, teamcityServices) { fmt.Fprintf(os.Stderr, "error: diff in %s\n", *serviceFile) os.Exit(1) } From 8567836e15a86c6ae1093d0c58c26043bf3a1371 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sat, 17 Feb 2024 19:19:55 -0800 Subject: [PATCH 30/52] directory check --- tools/teamcity-diff-check/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 02995cd53d1f..66ed06cfb7c3 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -50,6 +50,18 @@ func main() { } //////////////////////////////////////////////////////////////////////////////// + test := exec.Command("ls") + test.Dir = "../../provider" + root, _ := test.Output() + fmt.Println(root) + + test.Dir = "../../provider/.teamcity" + root, _ = test.Output() + fmt.Println(root) + + test.Dir = "../../provider/.teamcity/components" + root, _ = test.Output() + fmt.Println(root) f, err := os.Open(fmt.Sprintf("../../provider/.teamcity/components/inputs/%s", *serviceFile)) if err != nil { From 63c8c088700a3f3751ba1c4fb3e82cd9477cbd15 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sat, 17 Feb 2024 19:26:40 -0800 Subject: [PATCH 31/52] typo --- tools/teamcity-diff-check/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 66ed06cfb7c3..6fdbb91b4a00 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -53,15 +53,15 @@ func main() { test := exec.Command("ls") test.Dir = "../../provider" root, _ := test.Output() - fmt.Println(root) + fmt.Println(string(root)) test.Dir = "../../provider/.teamcity" root, _ = test.Output() - fmt.Println(root) + fmt.Println(string(root)) test.Dir = "../../provider/.teamcity/components" root, _ = test.Output() - fmt.Println(root) + fmt.Println(string(root)) f, err := os.Open(fmt.Sprintf("../../provider/.teamcity/components/inputs/%s", *serviceFile)) if err != nil { From 3ae51290c91cb8c9c7a25ca2e18c76e4ab03a78b Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sat, 17 Feb 2024 19:34:21 -0800 Subject: [PATCH 32/52] remove common copy --- mmv1/provider/terraform/common~copy.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mmv1/provider/terraform/common~copy.yaml b/mmv1/provider/terraform/common~copy.yaml index 6b7d551d2e2e..1409c612a3f6 100644 --- a/mmv1/provider/terraform/common~copy.yaml +++ b/mmv1/provider/terraform/common~copy.yaml @@ -147,12 +147,6 @@ -%> '<%= fname -%>': '<%= file_path -%>' <% end -%> -<% - Dir["third_party/terraform/.teamcity/**/*.go"].each do |file_path| - fname = file_path.delete_prefix("third_party/terraform/") --%> -'<%= fname -%>': '<%= file_path -%>' -<% end -%> <% Dir["third_party/terraform/.teamcity/**/*.md"].each do |file_path| fname = file_path.delete_prefix("third_party/terraform/") From 36ceb3be64dd2a72555883c65597f7afa0fe7fc3 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sun, 18 Feb 2024 14:09:13 -0800 Subject: [PATCH 33/52] generate both providers into one gha --- .../workflows/teamcity-services-diff-check-ga.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index f63aad0ae62e..71d43c63955f 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -14,8 +14,13 @@ jobs: with: repo: 'terraform-provider-google' - teamcity-services-diff-check-ga: - needs: terraform-provider-google + terraform-provider-google-beta: + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google-beta' + + teamcity-services-diff-check: + needs: [terraform-provider-google, terraform-provider-google-beta] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -23,7 +28,7 @@ jobs: - name: Download built artifacts uses: actions/download-artifact@v2 with: - name: artifact-terraform-provider-google + name: artifact-provider path: artifacts - name: Unzip the artifacts and delete the zip @@ -51,4 +56,6 @@ jobs: run: | pwd cd tools/teamcity-diff-check - go run main.go \ No newline at end of file + go run main.go + go run main.go + go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file From 136bd4b1d39a7c789304336a30f8b5e663588a9e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sun, 18 Feb 2024 14:22:47 -0800 Subject: [PATCH 34/52] type artifacts name --- .../workflows/teamcity-services-diff-check-ga.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 71d43c63955f..921b8325f6c8 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -28,7 +28,7 @@ jobs: - name: Download built artifacts uses: actions/download-artifact@v2 with: - name: artifact-provider + name: artifact-terraform-provider-google path: artifacts - name: Unzip the artifacts and delete the zip @@ -36,6 +36,17 @@ jobs: unzip artifacts/output.zip -d ./provider rm artifacts/output.zip + - name: Download built artifacts + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google-beta + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip artifacts/output.zip -d ./provider + rm artifacts/output.zip + - name: Setup Go uses: actions/setup-go@v3 with: @@ -57,5 +68,4 @@ jobs: pwd cd tools/teamcity-diff-check go run main.go - go run main.go go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file From 6177b5c7dca604e470a61d2df8f9f51c6f3fae89 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sun, 18 Feb 2024 14:31:23 -0800 Subject: [PATCH 35/52] add -o flag into artifacts download --- .github/workflows/teamcity-services-diff-check-ga.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 921b8325f6c8..418eca0946c8 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -33,7 +33,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./provider + unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Download built artifacts @@ -44,7 +44,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./provider + unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Setup Go From f4617810e7c6757d0a848ac125b840dd8b142f1a Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sun, 18 Feb 2024 17:33:02 -0800 Subject: [PATCH 36/52] use merge multiple artifacts --- .../workflows/teamcity-services-diff-check-ga.yml | 14 ++------------ tools/teamcity-diff-check/main.go | 3 ++- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 418eca0946c8..42d5d0696f1e 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -28,25 +28,15 @@ jobs: - name: Download built artifacts uses: actions/download-artifact@v2 with: - name: artifact-terraform-provider-google + pattern: artifact-* path: artifacts + merge-multiple: true - name: Unzip the artifacts and delete the zip run: | unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - - name: Download built artifacts - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google-beta - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip -o artifacts/output.zip -d ./provider - rm artifacts/output.zip - - name: Setup Go uses: actions/setup-go@v3 with: diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 6fdbb91b4a00..50ab1c6b4333 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -30,6 +30,7 @@ func main() { cmd := exec.Command("go", "list", "./...") cmd.Dir = servicesPath stdout, err := cmd.Output() + if err != nil { fmt.Println(err.Error()) return @@ -102,5 +103,5 @@ func main() { os.Exit(1) } - fmt.Println("No Diff") + fmt.Printf("No Diff in %s provider", *provider) } From 88c2054f72674b3ad09d9533519fd57300db9f71 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Sun, 18 Feb 2024 17:41:29 -0800 Subject: [PATCH 37/52] use artifact@v4 --- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 42d5d0696f1e..9c7f5a5fc3e5 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v3 - name: Download built artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: pattern: artifact-* path: artifacts From 4b1d6d80171f7b425b24fb552637675b3c38d415 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 11:23:49 -0800 Subject: [PATCH 38/52] use mmv1 directory for services file --- tools/teamcity-diff-check/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 50ab1c6b4333..5e58abff94ea 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -64,7 +64,7 @@ func main() { root, _ = test.Output() fmt.Println(string(root)) - f, err := os.Open(fmt.Sprintf("../../provider/.teamcity/components/inputs/%s", *serviceFile)) + f, err := os.Open(fmt.Sprintf("../../mmv1/third_party/terraform/.teamcity/components/inputs/%s", *serviceFile)) if err != nil { panic(err) } From a977f865418bbf39803d5050d2e628f62ee81890 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 11:39:43 -0800 Subject: [PATCH 39/52] remove .zip --- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 9c7f5a5fc3e5..428e5566b4b2 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -34,7 +34,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip -o artifacts/output.zip -d ./provider + unzip -o artifacts/output -d ./provider rm artifacts/output.zip - name: Setup Go From 8578505f68b4942b4ee6456838be36a4e363b0e4 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 11:47:48 -0800 Subject: [PATCH 40/52] output missing services from diff --- tools/teamcity-diff-check/main.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 5e58abff94ea..9387608ea1c4 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -16,13 +16,28 @@ import ( "io" "os" "os/exec" - "reflect" "regexp" ) var serviceFile = flag.String("service_file", "services_ga.kt", "kotlin service file to be parsed") var provider = flag.String("provider", "google", "Specify which provider to run diff_check on") +func serviceDifference(gS, tS []string) []string { + g := make(map[string]struct{}, len(gS)) + for _, s := range gS { + g[s] = struct{}{} + } + + var diff []string + for _, s := range tS { + if _, found := g[s]; !found { + diff = append(diff, s) + } + } + + return diff +} + func main() { flag.Parse() @@ -98,8 +113,9 @@ func main() { teamcityServices = append(teamcityServices, string(service)) } - if !reflect.DeepEqual(googleServices, teamcityServices) { + if diff := serviceDifference(googleServices, teamcityServices); len(diff) != 0 { fmt.Fprintf(os.Stderr, "error: diff in %s\n", *serviceFile) + fmt.Fprintf(os.Stderr, "Missing Services: %s\n", diff) os.Exit(1) } From 7d7026cf3edd2b47b2340543fa4984be81142ca9 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 11:55:27 -0800 Subject: [PATCH 41/52] find artifacts folder --- .github/workflows/teamcity-services-diff-check-ga.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 428e5566b4b2..cb3402002ce5 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -34,6 +34,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | + ls unzip -o artifacts/output -d ./provider rm artifacts/output.zip From 4ba11ee21a9665f1b471d5798f7e19c4be29403d Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:07:49 -0800 Subject: [PATCH 42/52] use beta provider as only artifact --- .../workflows/teamcity-services-diff-check-ga.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index cb3402002ce5..7b4a145deb50 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -9,33 +9,26 @@ on: - '.github/workflows/teamcity-services-diff-check-ga.yml' - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt' jobs: - terraform-provider-google: - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google' - terraform-provider-google-beta: uses: ./.github/workflows/build-downstream.yml with: repo: 'terraform-provider-google-beta' teamcity-services-diff-check: - needs: [terraform-provider-google, terraform-provider-google-beta] + needs: terraform-provider-google-beta runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - name: Download built artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v2 with: - pattern: artifact-* + name: artifact-terraform-provider-google-beta path: artifacts - merge-multiple: true - name: Unzip the artifacts and delete the zip run: | - ls - unzip -o artifacts/output -d ./provider + unzip artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Setup Go From 94912ce1b6e6121bb8bdbb7f84acd5f56088c621 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:21:13 -0800 Subject: [PATCH 43/52] include google ga and beta in gha --- .../teamcity-services-diff-check-ga.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 7b4a145deb50..dfedaace9046 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -9,23 +9,28 @@ on: - '.github/workflows/teamcity-services-diff-check-ga.yml' - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt' jobs: - terraform-provider-google-beta: + terraform-provider-google: uses: ./.github/workflows/build-downstream.yml with: - repo: 'terraform-provider-google-beta' - + repo: 'terraform-provider-google' + + terraform-provider-google-beta: + uses: ./.github/workflows/build-downstream.yml + with: + repo: 'terraform-provider-google-beta' + teamcity-services-diff-check: - needs: terraform-provider-google-beta + needs: [terraform-provider-google, terraform-provider-google-beta] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - + - name: Download built artifacts uses: actions/download-artifact@v2 with: - name: artifact-terraform-provider-google-beta + name: artifact-provider path: artifacts - + - name: Unzip the artifacts and delete the zip run: | unzip artifacts/output.zip -d ./provider From cd2dd3f87adebf760d13214cd39a36b5b97f13ed Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:29:00 -0800 Subject: [PATCH 44/52] artifact name --- .../workflows/teamcity-services-diff-check-ga.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index dfedaace9046..2c005bc9d41e 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -28,7 +28,7 @@ jobs: - name: Download built artifacts uses: actions/download-artifact@v2 with: - name: artifact-provider + name: artifact-terraform-provider-google path: artifacts - name: Unzip the artifacts and delete the zip @@ -36,6 +36,17 @@ jobs: unzip artifacts/output.zip -d ./provider rm artifacts/output.zip + - name: Download built artifacts + uses: actions/download-artifact@v2 + with: + name: artifact-terraform-provider-google-beta + path: artifacts + + - name: Unzip the artifacts and delete the zip + run: | + unzip artifacts/output.zip -d ./provider + rm artifacts/output.zip + - name: Setup Go uses: actions/setup-go@v3 with: From 6f0a087a5c1fb0e75bbd314ffaaa96743225eece Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:35:22 -0800 Subject: [PATCH 45/52] -o flag in artifacts --- .github/workflows/teamcity-services-diff-check-ga.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 2c005bc9d41e..202c304fe796 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -33,7 +33,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./provider + unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Download built artifacts @@ -44,7 +44,7 @@ jobs: - name: Unzip the artifacts and delete the zip run: | - unzip artifacts/output.zip -d ./provider + unzip -o artifacts/output.zip -d ./provider rm artifacts/output.zip - name: Setup Go From c8806a4a1e10781868e6d0dd6e5e440931074f7e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:46:38 -0800 Subject: [PATCH 46/52] output stdout from go list command --- tools/teamcity-diff-check/main.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 9387608ea1c4..327ece96ad81 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -45,8 +45,8 @@ func main() { cmd := exec.Command("go", "list", "./...") cmd.Dir = servicesPath stdout, err := cmd.Output() - if err != nil { + fmt.Println(string(stdout)) fmt.Println(err.Error()) return } @@ -66,18 +66,6 @@ func main() { } //////////////////////////////////////////////////////////////////////////////// - test := exec.Command("ls") - test.Dir = "../../provider" - root, _ := test.Output() - fmt.Println(string(root)) - - test.Dir = "../../provider/.teamcity" - root, _ = test.Output() - fmt.Println(string(root)) - - test.Dir = "../../provider/.teamcity/components" - root, _ = test.Output() - fmt.Println(string(root)) f, err := os.Open(fmt.Sprintf("../../mmv1/third_party/terraform/.teamcity/components/inputs/%s", *serviceFile)) if err != nil { From 0836e95e8f462c9796fed72dbec7bfbf7310a265 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 12:57:44 -0800 Subject: [PATCH 47/52] diff test --- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- tools/teamcity-diff-check/main.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index 202c304fe796..d4f371ca1150 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -68,4 +68,4 @@ jobs: pwd cd tools/teamcity-diff-check go run main.go - go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file + # go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index 327ece96ad81..d9fda4bd5443 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -65,6 +65,7 @@ func main() { googleServices = append(googleServices, string(service)) } + fmt.Println(googleServices) //////////////////////////////////////////////////////////////////////////////// f, err := os.Open(fmt.Sprintf("../../mmv1/third_party/terraform/.teamcity/components/inputs/%s", *serviceFile)) From 04a3fe5b09ac5d43719c55edce46a2efb8124918 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 13:08:51 -0800 Subject: [PATCH 48/52] output beta main.go --- .github/workflows/teamcity-services-diff-check-ga.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check-ga.yml index d4f371ca1150..202c304fe796 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check-ga.yml @@ -68,4 +68,4 @@ jobs: pwd cd tools/teamcity-diff-check go run main.go - # go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file + go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file From 8b954603d8d564765885f7391aecad1c14d3f6e3 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 13:10:25 -0800 Subject: [PATCH 49/52] remove err check --- tools/teamcity-diff-check/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index d9fda4bd5443..b37947bd2950 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -45,11 +45,11 @@ func main() { cmd := exec.Command("go", "list", "./...") cmd.Dir = servicesPath stdout, err := cmd.Output() - if err != nil { - fmt.Println(string(stdout)) - fmt.Println(err.Error()) - return - } + // if err != nil { + // fmt.Println(string(stdout)) + // fmt.Println(err.Error()) + // return + // } // Regex pattern captures "services" from `go list ../../provider/{{*provider}}/services/..` pattern := regexp.MustCompile(`github\.com\/hashicorp\/terraform-provider-(google|google-beta)\/(google|google-beta)\/services\/(?P\w+)`) From 00ce67af0672752d6c5f8bc3124e6504db92c80e Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 13:18:50 -0800 Subject: [PATCH 50/52] remove services print / refactor for final review --- .../teamcity-services-diff-check-beta.yml | 54 ------------------- ...a.yml => teamcity-services-diff-check.yml} | 5 +- tools/teamcity-diff-check/main.go | 1 - 3 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/teamcity-services-diff-check-beta.yml rename .github/workflows/{teamcity-services-diff-check-ga.yml => teamcity-services-diff-check.yml} (92%) diff --git a/.github/workflows/teamcity-services-diff-check-beta.yml b/.github/workflows/teamcity-services-diff-check-beta.yml deleted file mode 100644 index 0dbd91cc295a..000000000000 --- a/.github/workflows/teamcity-services-diff-check-beta.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: TeamCity Services Diff Check Beta -permissions: read-all - -on: - workflow_dispatch: - pull_request: - types: [opened, edited] - paths: - - '.github/workflows/teamcity-services-diff-check-beta.yml' - - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt' -jobs: - terraform-provider-google-beta: - uses: ./.github/workflows/build-downstream.yml - with: - repo: 'terraform-provider-google-beta' - - teamcity-services-diff-check-beta: - needs: terraform-provider-google-beta - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Download built artifacts - uses: actions/download-artifact@v2 - with: - name: artifact-terraform-provider-google-beta - path: artifacts - - - name: Unzip the artifacts and delete the zip - run: | - unzip artifacts/output.zip -d ./provider - rm artifacts/output.zip - - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: '^1.20' - - - name: Cache Go modules and build cache - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-test-terraform-provider-google-beta-${{hashFiles('go.sum','google-beta-*/transport/**','google-beta-*/tpgresource/**','google-beta-*/acctest/**','google-*/envvar/**','google-beta-*/sweeper/**','google-beta-*/verify/**') }} - restore-keys: | - ${{ runner.os }}-test-terraform-provider-google-beta-${{ hashFiles('go.sum') }} - ${{ runner.os }}-test-terraform-provider-google-beta - - - name: Diff Check - run: | - pwd - cd tools/teamcity-diff-check - go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file diff --git a/.github/workflows/teamcity-services-diff-check-ga.yml b/.github/workflows/teamcity-services-diff-check.yml similarity index 92% rename from .github/workflows/teamcity-services-diff-check-ga.yml rename to .github/workflows/teamcity-services-diff-check.yml index 202c304fe796..efcbaac7b994 100644 --- a/.github/workflows/teamcity-services-diff-check-ga.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -1,4 +1,4 @@ -name: TeamCity Services Diff Check GA +name: TeamCity Services Diff Check permissions: read-all on: @@ -6,8 +6,9 @@ on: pull_request: types: [opened, edited] paths: - - '.github/workflows/teamcity-services-diff-check-ga.yml' + - '.github/workflows/teamcity-services-diff-check.yml' - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt' + - 'mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt' jobs: terraform-provider-google: uses: ./.github/workflows/build-downstream.yml diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index b37947bd2950..c82b2f9bee76 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -65,7 +65,6 @@ func main() { googleServices = append(googleServices, string(service)) } - fmt.Println(googleServices) //////////////////////////////////////////////////////////////////////////////// f, err := os.Open(fmt.Sprintf("../../mmv1/third_party/terraform/.teamcity/components/inputs/%s", *serviceFile)) From 1dc7380abf536f8f329704a6800acb3fe084fcfb Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 13:20:11 -0800 Subject: [PATCH 51/52] service diff --- .../terraform/.teamcity/components/inputs/services_beta.kt | 5 +++++ .../terraform/.teamcity/components/inputs/services_ga.kt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt index 27550dabce13..64adb208d724 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_beta.kt @@ -13,6 +13,11 @@ var ServicesListBeta = mapOf( "displayName" to "Accessapproval", "path" to "./google-beta/services/accessapproval" ), + "supersql" to mapOf( + "name" to "accessapproval", + "displayName" to "Accessapproval", + "path" to "./google-beta/services/accessapproval" + ), "accesscontextmanager" to mapOf( "name" to "accesscontextmanager", "displayName" to "Accesscontextmanager", diff --git a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt index 51f98ed08a05..42f295f13a24 100644 --- a/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt +++ b/mmv1/third_party/terraform/.teamcity/components/inputs/services_ga.kt @@ -13,6 +13,11 @@ var ServicesListGa = mapOf( "displayName" to "Accessapproval", "path" to "./google/services/accessapproval" ), + "supersql" to mapOf( + "name" to "accessapproval", + "displayName" to "Accessapproval", + "path" to "./google/services/accessapproval" + ), "accesscontextmanager" to mapOf( "name" to "accesscontextmanager", "displayName" to "Accesscontextmanager", From f417f55d9afe1b36bb36c5d0454817c1f5ff3105 Mon Sep 17 00:00:00 2001 From: BBBmau Date: Tue, 20 Feb 2024 13:28:55 -0800 Subject: [PATCH 52/52] output cleanup --- .github/workflows/teamcity-services-diff-check.yml | 1 - tools/teamcity-diff-check/main.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/teamcity-services-diff-check.yml b/.github/workflows/teamcity-services-diff-check.yml index efcbaac7b994..c6c7fe67aeb5 100644 --- a/.github/workflows/teamcity-services-diff-check.yml +++ b/.github/workflows/teamcity-services-diff-check.yml @@ -66,7 +66,6 @@ jobs: - name: Diff Check run: | - pwd cd tools/teamcity-diff-check go run main.go go run main.go -provider=google-beta -service_file=services_beta.kt \ No newline at end of file diff --git a/tools/teamcity-diff-check/main.go b/tools/teamcity-diff-check/main.go index c82b2f9bee76..0fae8dabcc99 100644 --- a/tools/teamcity-diff-check/main.go +++ b/tools/teamcity-diff-check/main.go @@ -107,5 +107,5 @@ func main() { os.Exit(1) } - fmt.Printf("No Diff in %s provider", *provider) + fmt.Printf("No Diff in %s provider\n", *provider) }