From c3abbb54f487d06b1da83af6c3d34ba9669d4fd9 Mon Sep 17 00:00:00 2001 From: Jared Edwards Date: Wed, 29 Nov 2023 18:55:32 -0700 Subject: [PATCH] fix terraform workspace remote url (#250) --- go.mod | 2 +- go.sum | 4 ++-- internal/controller/cluster.go | 7 ++++--- pkg/providerConfigs/detokenize.go | 2 +- pkg/providerConfigs/types.go | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index a0833e53..2837284c 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/hashicorp/vault/api v1.9.0 github.com/joho/godotenv v1.5.1 github.com/kubefirst/metrics-client v0.2.8 - github.com/kubefirst/runtime v0.3.31 + github.com/kubefirst/runtime v0.3.32 github.com/minio/minio-go/v7 v7.0.49 github.com/otiai10/copy v1.7.0 github.com/rs/zerolog v1.29.1 diff --git a/go.sum b/go.sum index 6f32f1af..ec2ef163 100644 --- a/go.sum +++ b/go.sum @@ -740,8 +740,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubefirst/metrics-client v0.2.8 h1:JfaeiBifZD/DpyYW2QVHcrhH/KWA98OmM+7c7M12qMc= github.com/kubefirst/metrics-client v0.2.8/go.mod h1:GR7wsMcyYhd+EU67PeuMCBYFE6OJ7P/j5OI5BLOoRMc= -github.com/kubefirst/runtime v0.3.31 h1:8UT6nwrCqCYRc6rQWQsPsUo+EPd6xZULzkYamSIucWE= -github.com/kubefirst/runtime v0.3.31/go.mod h1:9egAgF5cF594mIzra5nTB1kfE57Hr/Nvl79tjLsAWCQ= +github.com/kubefirst/runtime v0.3.32 h1:xk58E+uu3KGLE3+ks/OqyIfNrPA5IUFh0h4IrhPCB+U= +github.com/kubefirst/runtime v0.3.32/go.mod h1:9egAgF5cF594mIzra5nTB1kfE57Hr/Nvl79tjLsAWCQ= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= diff --git a/internal/controller/cluster.go b/internal/controller/cluster.go index 8d64163f..b079a22b 100644 --- a/internal/controller/cluster.go +++ b/internal/controller/cluster.go @@ -208,9 +208,10 @@ func (clctrl *ClusterController) CreateTokens(kind string) interface{} { GitlabOwnerGroupID: clctrl.GitlabOwnerGroupID, GitlabUser: clctrl.GitAuth.User, - GitopsRepoAtlantisWebhookURL: clctrl.AtlantisWebhookURL, - GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", clctrl.GitHost, clctrl.GitAuth.Owner), - ClusterId: clctrl.ClusterID, + GitopsRepoAtlantisWebhookURL: clctrl.AtlantisWebhookURL, + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s/%s/gitops.git", clctrl.GitHost, clctrl.GitAuth.Owner), + WorkloadClusterTerraformModuleURL: fmt.Sprintf("git::https://%s/%s//terraform/%s/modules/workload-cluster?ref=main", clctrl.GitHost, clctrl.GitAuth.Owner, clctrl.CloudProvider), + ClusterId: clctrl.ClusterID, // external-dns optionality to provide cloudflare support regardless of cloud provider ExternalDNSProviderName: clctrl.DnsProvider, diff --git a/pkg/providerConfigs/detokenize.go b/pkg/providerConfigs/detokenize.go index 104c683b..2300b788 100644 --- a/pkg/providerConfigs/detokenize.go +++ b/pkg/providerConfigs/detokenize.go @@ -81,7 +81,7 @@ func detokenizeGitops(path string, tokens *GitopsDirectoryValues, gitProtocol st newContents = strings.Replace(newContents, "", os.Getenv("KUBEFIRST_TEAM_INFO"), -1) newContents = strings.Replace(newContents, "", tokens.KubefirstVersion, -1) newContents = strings.Replace(newContents, "", tokens.StateStoreBucketHostname, -1) - newContents = strings.Replace(newContents, "", "git::https:////terraform//modules/workload-cluster?ref=main", -1) + newContents = strings.Replace(newContents, "", tokens.WorkloadClusterTerraformModuleURL, -1) newContents = strings.Replace(newContents, "", tokens.NodeType, -1) newContents = strings.Replace(newContents, "", fmt.Sprint(tokens.NodeCount), -1) diff --git a/pkg/providerConfigs/types.go b/pkg/providerConfigs/types.go index 9a6d0f0f..41201304 100644 --- a/pkg/providerConfigs/types.go +++ b/pkg/providerConfigs/types.go @@ -71,8 +71,9 @@ type GitopsDirectoryValues struct { GitlabOwnerGroupID int GitlabUser string - GitopsRepoAtlantisWebhookURL string - GitopsRepoNoHTTPSURL string + GitopsRepoAtlantisWebhookURL string + GitopsRepoNoHTTPSURL string + WorkloadClusterTerraformModuleURL string ExternalDNSProviderName string ExternalDNSProviderTokenEnvName string