From bdc9ede5ef1522a976c887317e4e9b7efae9b6b7 Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Fri, 10 May 2024 21:15:07 +0000 Subject: [PATCH 1/4] Presteps for correcting the useragent. Extract the KCC version into its own file. Make it available for embed to pull it in. Make sure that its available in the docker file. --- .gitignore | 2 ++ Makefile | 12 ++++++++++-- build/builder/Dockerfile | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ef41725764..e48044a421 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,8 @@ tmp/_test .tmp # build output +version.txt +third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt bin/ operator/bin diff --git a/Makefile b/Makefile index d2bace8a5c..41e48e6bd7 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ fmt: ./ .PHONY: lint -lint: +lint: third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt docker run --rm -v $(shell pwd):/app \ -v ${GOLANGCI_LINT_CACHE}:/root/.cache/golangci-lint \ -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine \ @@ -117,7 +117,7 @@ vet: # Generate code .PHONY: generate -generate: +generate: third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt # Don't run go generate on `pkg/clients/generated` in the normal development flow due to high latency. # This path will be covered by `generate-go-client` target specifically. go mod vendor -o temp-vendor # So we can load DCL resources @@ -248,6 +248,14 @@ deploy-controller: docker-build docker-push generate-go-client: ./scripts/generate-go-crd-clients/generate-clients.sh +# Generate the version.txt file +version.txt: operator/channels/stable + egrep version operator/channels/stable | head -1 | sed 's/[^0-9.]//g' > version.txt + +# Generate the version.txt file +third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt: version.txt + cp version.txt third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport + # Generate google3 docs .PHONY: resource-docs resource-docs: diff --git a/build/builder/Dockerfile b/build/builder/Dockerfile index 72a52919e0..94a4bb07a7 100644 --- a/build/builder/Dockerfile +++ b/build/builder/Dockerfile @@ -26,6 +26,7 @@ COPY operator/ operator/ COPY third_party/ third_party/ COPY scripts/generate-third-party-licenses scripts/generate-third-party-licenses COPY scripts/resource-autogen scripts/resource-autogen +COPY version.txt third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt COPY go.mod go.mod COPY go.sum go.sum From 5454190d955f65f927ca037dea18327fdf0c361d Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Fri, 10 May 2024 21:16:37 +0000 Subject: [PATCH 2/4] Fix the useragent to reflect kcc and the correct version. --- .../google-beta/fwtransport/framework_utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/framework_utils.go b/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/framework_utils.go index c8b599ee67..4df75fd8b9 100644 --- a/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/framework_utils.go +++ b/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/framework_utils.go @@ -4,6 +4,7 @@ package fwtransport import ( "context" + _ "embed" "fmt" "os" "strings" @@ -18,8 +19,11 @@ import ( const uaEnvVar = "TF_APPEND_USER_AGENT" +//go:embed version.txt +var kccVersion string + func CompileUserAgentString(ctx context.Context, name, tfVersion, provVersion string) string { - ua := fmt.Sprintf("Terraform/%s (+https://www.terraform.io) Terraform-Plugin-SDK/%s %s/%s", tfVersion, "terraform-plugin-framework", name, provVersion) + ua := fmt.Sprintf("kcc/%s (+https://github.com/GoogleCloudPlatform/k8s-config-connector) kcc/controller-manager/%s", kccVersion, provVersion) if add := os.Getenv(uaEnvVar); add != "" { add = strings.TrimSpace(add) From a914c32280145556f5e6b43c2312af2486716f20 Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Mon, 13 May 2024 06:46:47 +0000 Subject: [PATCH 3/4] Under third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e48044a421..d413c3974c 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,6 @@ tmp/_test # build output version.txt -third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt bin/ operator/bin From 3863ce7a4e8c0fa1f1593cae848031e0ea3588af Mon Sep 17 00:00:00 2001 From: Walter Fender Date: Mon, 13 May 2024 06:47:18 +0000 Subject: [PATCH 4/4] Add in version.txt for online testing. --- .../google-beta/fwtransport/version.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt diff --git a/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt b/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt new file mode 100644 index 0000000000..8de9ac240a --- /dev/null +++ b/third_party/github.com/hashicorp/terraform-provider-google-beta/google-beta/fwtransport/version.txt @@ -0,0 +1 @@ +1.117.0