From 4f67fd463bef80fc8586d37e5c56e03f9caf3330 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 26 Jul 2023 20:06:29 -0500 Subject: [PATCH 01/45] chore: fix local golang version (#1725) Co-authored-by: Claywd <6446939+Claywd@users.noreply.github.com> --- .tool-versions | 1 + 1 file changed, 1 insertion(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..e8249f49e --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +golang 1.20.5 From 9dd1e5f18d48f46f1a0810d14fcf5320dc03e221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Wed, 26 Jul 2023 20:32:17 -0500 Subject: [PATCH 02/45] feat: macrochart update 2.2.7 (#1726) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 7b23f40b4..47cd8d7db 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.6" + helmChartVersion = "2.2.7" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From f3606c0de12f9e75eda6b79d8905383305bb6143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Thu, 27 Jul 2023 10:23:03 -0400 Subject: [PATCH 03/45] fix: version upgrade commands with Homebrew (#1723) --- internal/common/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/common/common.go b/internal/common/common.go index 617b8c826..70967b227 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -23,7 +23,7 @@ func CheckForVersionUpdate() { if res.Outdated { switch runtime.GOOS { case "darwin": - fmt.Printf("A newer version (v%s) is available! Please upgrade with: \"brew upgrade kubefirst\"\n", res.Current) + fmt.Printf("A newer version (v%s) is available! Please upgrade with: \"brew update && brew upgrade kubefirst\"\n", res.Current) default: fmt.Printf("A newer version (v%s) is available! \"https://github.com/kubefirst/kubefirst/blob/main/build/README.md\"\n", res.Current) } From b75aafe852b0fd40cd471bff284631c1a66124d8 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Mon, 31 Jul 2023 10:23:12 -0500 Subject: [PATCH 04/45] chore: update runtime with fixes for gcp (#1733) Co-authored-by: Claywd <6446939+Claywd@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 147a7d143..efd5ba5ca 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/go-git/go-git/v5 v5.6.1 github.com/hashicorp/vault/api v1.9.0 - github.com/kubefirst/runtime v0.2.11 + github.com/kubefirst/runtime v0.3.0 github.com/rs/zerolog v1.29.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index 4ef7ef35c..8192ff187 100644 --- a/go.sum +++ b/go.sum @@ -714,8 +714,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/runtime v0.2.11 h1:xXVNV/PgbgnSLLhiaF8zGLUwtm6EOyYNQxaNp4R3nFg= -github.com/kubefirst/runtime v0.2.11/go.mod h1:YAww60f+GxyYZIBzJxuqpf8yzfmsRBS0Zr0QiTD7aTE= +github.com/kubefirst/runtime v0.3.0 h1:9t7lp/9uUYPx77dTZ5XQxUq5IY1Z6NQHLNKvT/+90gc= +github.com/kubefirst/runtime v0.3.0/go.mod h1:YAww60f+GxyYZIBzJxuqpf8yzfmsRBS0Zr0QiTD7aTE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= From db1dfa0e2651f40ea541d5935ce9e6265292c327 Mon Sep 17 00:00:00 2001 From: John Dietz Date: Mon, 31 Jul 2023 11:29:27 -0400 Subject: [PATCH 05/45] adjusting branch selection logic on gcp (#1731) --- cmd/gcp/create.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 1d1ad30d1..9bc1d776c 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -395,14 +395,19 @@ func createGCP(cmd *cobra.Command, args []string) error { if strings.Contains(gitopsTemplateURLFlag, "https://github.com/kubefirst/gitops-template.git") && gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = "main" } - case "default": + default: switch gitopsTemplateURLFlag { case "https://github.com/kubefirst/gitops-template.git": if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } + default: + if gitopsTemplateBranchFlag != "" { + return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") + } } } + log.Info().Msgf("kubefirst version configs.K1Version: %s ", configs.K1Version) log.Info().Msgf("cloning gitops-template repo url: %s ", gitopsTemplateURLFlag) log.Info().Msgf("cloning gitops-template repo branch: %s ", gitopsTemplateBranchFlag) From b772d56564f91a59445a1f2960b0a24a0e0397e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Tue, 1 Aug 2023 11:37:41 -0400 Subject: [PATCH 06/45] fix: 'launch up --helm-flag' flag help (#1737) --- cmd/launch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/launch.go b/cmd/launch.go index 85eefe202..53ff146ed 100644 --- a/cmd/launch.go +++ b/cmd/launch.go @@ -45,7 +45,7 @@ func launchUp() *cobra.Command { }, } - launchUpCmd.Flags().StringSliceVar(&additionalHelmFlags, "helm-flag", []string{}, "additional helm flag to pass to the `launch up` command - can be used any number of times") + launchUpCmd.Flags().StringSliceVar(&additionalHelmFlags, "helm-flag", []string{}, "additional helm flag to pass to the launch up command - can be used any number of times") return launchUpCmd } From ccb30891471bf502436c953678d63792ebb401c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Tue, 1 Aug 2023 11:37:50 -0400 Subject: [PATCH 07/45] ci: let codeql analysis be dispatched manually (#1738) --- .github/workflows/codeql-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2a63dcb64..0a38e04f1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,6 +23,7 @@ on: - '**.go' schedule: - cron: '0 0 * * 6' # Saturdays at midnight + workflow_dispatch: jobs: analyze: From 93d7c8b4d065d9f2527053485a60272cd543a99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Tue, 1 Aug 2023 12:20:01 -0400 Subject: [PATCH 08/45] ci: fix kubefirst build for CodeQL analysis (#1744) --- .github/workflows/codeql-analysis.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0a38e04f1..36b516a04 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -55,21 +55,9 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release + # Autobuild is now failing + - name: Build + run: go build . - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 From c466881679ff8ce0e287eda93a6e6ecadbc56984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Tue, 1 Aug 2023 16:31:33 -0400 Subject: [PATCH 09/45] chore: prevent people to create issue without the forms (#1742) --- .github/ISSUE_TEMPLATE/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5bec387be..f04015fcb 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,3 +1,4 @@ +blank_issues_enabled: false contact_links: - name: Documentations url: https://github.com/kubefirst/docs/issues/new?assignees=&labels=docs&template=docs.yml&title=%5BDocs%5D%3A+ From 473992aa84432acd080ee82a5f8851710bc50ab1 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 2 Aug 2023 17:29:33 -0500 Subject: [PATCH 10/45] Fix gcp gitops url (#1739) * fix: set https switch for github * fix: update urls for gitops repo * fix: lowercase the gitops vault secret cloudflare * chore: bump runtime version * fix: add comments and remove hardcoded https * fix: add comments for clarity * chore: bump runtime version * chore: cleanup commented code * fix: remove hardcoded https --------- Co-authored-by: Claywd <6446939+Claywd@users.noreply.github.com> --- cmd/aws/create.go | 22 +++++---- cmd/civo/create.go | 22 ++++++--- cmd/digitalocean/create.go | 22 ++++++--- cmd/gcp/create.go | 27 ++++++----- cmd/k3d/create.go | 4 +- cmd/vultr/create.go | 22 ++++++--- go.mod | 43 +++++++++-------- go.sum | 95 ++++++++++++++++++++++---------------- 8 files changed, 157 insertions(+), 100 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 6cc4300b2..3d2af13b7 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -300,9 +300,13 @@ func createAws(cmd *cobra.Command, args []string) error { case "https": config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } } @@ -601,7 +605,7 @@ func createAws(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", awsinternal.CloudProvider) } - gitopsDirectoryTokens := providerConfigs.GitOpsDirectoryValues{ + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), AwsIamArnAccountRoot: fmt.Sprintf("arn:aws:iam::%s:root", *iamCaller.Account), @@ -655,8 +659,8 @@ func createAws(cmd *cobra.Command, args []string) error { GitlabOwnerGroupID: viper.GetInt("flags.gitlab-owner-group-id"), GitlabUser: cGitUser, - GitOpsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), - GitOpsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), + GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, AtlantisWebhookURL: atlantisWebhookURL, @@ -673,7 +677,7 @@ func createAws(cmd *cobra.Command, args []string) error { MetaphorProductionIngressURL: fmt.Sprintf("metaphor-production.%s", domainNameFlag), } - config.GitOpsDirectoryValues = &gitopsDirectoryTokens + config.GitopsDirectoryValues = &gitopsDirectoryTokens config.MetaphorDirectoryValues = &metaphorDirectoryTokens //* git clone and detokenize the gitops repository @@ -686,18 +690,18 @@ func createAws(cmd *cobra.Command, args []string) error { // These need to be set for reference elsewhere viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoGitURL) viper.WriteConfig() - gitopsDirectoryTokens.GitOpsRepoGitURL = config.DestinationGitopsRepoGitURL + gitopsDirectoryTokens.GitopsRepoGitURL = config.DestinationGitopsRepoGitURL err := providerConfigs.PrepareGitRepositories( awsinternal.CloudProvider, gitProviderFlag, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -1308,9 +1312,9 @@ func createAws(cmd *cobra.Command, args []string) error { } if viper.GetString("flags.dns-provider") == "cloudflare" { - tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareAPIToken + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareApiToken } else { - tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CivoToken + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = "AWS_Placeholder" } tfEnvs["TF_VAR_email_address"] = "your@email.com" diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 3023cd6aa..2ffd9d909 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -284,9 +284,13 @@ func createCivo(cmd *cobra.Command, args []string) error { case "https": config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } } @@ -321,7 +325,7 @@ func createCivo(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", civo.CloudProvider) } - gitopsDirectoryTokens := providerConfigs.GitOpsDirectoryValues{ + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), CloudProvider: civo.CloudProvider, @@ -371,15 +375,15 @@ func createCivo(cmd *cobra.Command, args []string) error { GitlabOwnerGroupID: cGitlabOwnerGroupID, GitlabUser: cGitUser, - GitOpsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), - GitOpsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), + GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, } viper.Set(fmt.Sprintf("%s.atlantis.webhook.url", config.GitProvider), fmt.Sprintf("https://atlantis.%s/events", domainNameFlag)) viper.WriteConfig() - config.GitOpsDirectoryValues = &gitopsDirectoryTokens + config.GitopsDirectoryValues = &gitopsDirectoryTokens // Segment Client segmentClient := &segment.SegmentClient{ @@ -705,11 +709,11 @@ func createCivo(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -1216,6 +1220,12 @@ func createCivo(cmd *cobra.Command, args []string) error { base64DockerAuth = base64.StdEncoding.EncodeToString([]byte(usernamePasswordString)) } + if viper.GetString("flags.dns-provider") == "cloudflare" { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareApiToken + } else { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = "AWS_Placeholder" + } + tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = civo.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = civo.GetCivoTerraformEnvs(config, tfEnvs) diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index c0b21e998..651f1bd87 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -283,9 +283,13 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { case "https": config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } } @@ -322,7 +326,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", digitalocean.CloudProvider) } - gitopsDirectoryTokens := providerConfigs.GitOpsDirectoryValues{ + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), CloudProvider: digitalocean.CloudProvider, @@ -372,8 +376,8 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { GitlabOwnerGroupID: cGitlabOwnerGroupID, GitlabUser: cGitUser, - GitOpsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), - GitOpsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), + GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, } @@ -670,7 +674,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { MetaphorProductionIngressURL: fmt.Sprintf("metaphor-production.%s", domainNameFlag), } - config.GitOpsDirectoryValues = &gitopsDirectoryTokens + config.GitopsDirectoryValues = &gitopsDirectoryTokens config.MetaphorDirectoryValues = &metaphorDirectoryTokens //* git clone and detokenize the gitops repository // todo improve this logic for removing `kubefirst clean` @@ -694,11 +698,11 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -1211,6 +1215,12 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { base64DockerAuth = base64.StdEncoding.EncodeToString([]byte(usernamePasswordString)) } + if viper.GetString("flags.dns-provider") == "cloudflare" { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareApiToken + } else { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = "AWS_Placeholder" + } + tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = digitalocean.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = digitalocean.GetDigitaloceanTerraformEnvs(config, tfEnvs) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 9bc1d776c..333777486 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -281,9 +281,13 @@ func createGCP(cmd *cobra.Command, args []string) error { case "https": config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } } @@ -305,7 +309,7 @@ func createGCP(cmd *cobra.Command, args []string) error { kubefirstTeam = "false" } - gitopsDirectoryTokens := providerConfigs.GitOpsDirectoryValues{ + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), CloudProvider: gcp.CloudProvider, @@ -339,6 +343,9 @@ func createGCP(cmd *cobra.Command, args []string) error { GitNamespace: "N/A", GitProvider: config.GitProvider, GitProtocol: config.GitProtocol, + GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, + GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, + GitopsRepoURL: config.DestinationGitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -353,8 +360,8 @@ func createGCP(cmd *cobra.Command, args []string) error { GitlabOwnerGroupID: cGitlabOwnerGroupID, GitlabUser: cGitUser, - GitOpsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), - GitOpsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), + GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, } @@ -643,7 +650,7 @@ func createGCP(cmd *cobra.Command, args []string) error { MetaphorProductionIngressURL: fmt.Sprintf("metaphor-production.%s", domainNameFlag), } - config.GitOpsDirectoryValues = &gitopsDirectoryTokens + config.GitopsDirectoryValues = &gitopsDirectoryTokens config.MetaphorDirectoryValues = &metaphorDirectoryTokens //* git clone and detokenize the gitops repository @@ -671,8 +678,6 @@ func createGCP(cmd *cobra.Command, args []string) error { gitopsDirectoryTokens.ExternalDNSProviderSecretName = fmt.Sprintf("%s-creds", gcp.CloudProvider) gitopsDirectoryTokens.ExternalDNSProviderSecretKey = externalDNSProviderSecretKey - gitopsDirectoryTokens.GitOpsRepoGitURL = config.DestinationGitopsRepoHttpsURL - // Determine if anything exists at domain apex apexContentExists := gcp.GetDomainApexContent(domainNameFlag) @@ -681,11 +686,11 @@ func createGCP(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -1077,7 +1082,7 @@ func createGCP(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoHttpsURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index d7edec3a2..266613024 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -564,11 +564,11 @@ func runK3d(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsTemplateTokens, config.MetaphorDir, diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 0f916143c..171b9b582 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -283,9 +283,13 @@ func createVultr(cmd *cobra.Command, args []string) error { case "https": config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } } @@ -315,7 +319,7 @@ func createVultr(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", vultr.CloudProvider) } - gitopsDirectoryTokens := providerConfigs.GitOpsDirectoryValues{ + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), CloudProvider: vultr.CloudProvider, @@ -365,8 +369,8 @@ func createVultr(cmd *cobra.Command, args []string) error { GitlabOwnerGroupID: cGitlabOwnerGroupID, GitlabUser: cGitUser, - GitOpsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), - GitOpsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), + GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), + GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, } @@ -667,7 +671,7 @@ func createVultr(cmd *cobra.Command, args []string) error { MetaphorProductionIngressURL: fmt.Sprintf("metaphor-production.%s", domainNameFlag), } - config.GitOpsDirectoryValues = &gitopsDirectoryTokens + config.GitopsDirectoryValues = &gitopsDirectoryTokens config.MetaphorDirectoryValues = &metaphorDirectoryTokens //* git clone and detokenize the gitops repository // todo improve this logic for removing `kubefirst clean` @@ -690,11 +694,11 @@ func createVultr(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, + config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, + config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -1204,6 +1208,12 @@ func createVultr(cmd *cobra.Command, args []string) error { base64DockerAuth = base64.StdEncoding.EncodeToString([]byte(usernamePasswordString)) } + if viper.GetString("flags.dns-provider") == "cloudflare" { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareApiToken + } else { + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = "AWS_Placeholder" + } + tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = vultr.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = vultr.GetVultrTerraformEnvs(config, tfEnvs) diff --git a/go.mod b/go.mod index efd5ba5ca..8b1c2c105 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/go-git/go-git/v5 v5.6.1 github.com/hashicorp/vault/api v1.9.0 - github.com/kubefirst/runtime v0.3.0 + github.com/kubefirst/runtime v0.3.4 github.com/rs/zerolog v1.29.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 @@ -33,12 +33,12 @@ replace ( ) require ( - cloud.google.com/go v0.110.0 // indirect - cloud.google.com/go/compute v1.18.0 // indirect + cloud.google.com/go v0.110.2 // indirect + cloud.google.com/go/compute v1.23.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/container v1.13.1 // indirect - cloud.google.com/go/iam v0.12.0 // indirect - cloud.google.com/go/storage v1.28.1 // indirect + cloud.google.com/go/container v1.24.0 // indirect + cloud.google.com/go/iam v0.13.0 // indirect + cloud.google.com/go/storage v1.29.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest v0.11.18 // indirect @@ -105,15 +105,16 @@ require ( github.com/gofrs/flock v0.7.0 // indirect github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/snappy v0.0.1 // indirect + github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/go-github v17.0.0+incompatible // indirect github.com/google/go-github/v45 v45.2.0 // indirect + github.com/google/s2a-go v0.1.4 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect - github.com/googleapis/gax-go/v2 v2.7.0 // indirect + github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect github.com/hashicorp/go-version v1.2.1 // indirect github.com/jedib0t/go-pretty/v6 v6.4.6 // indirect @@ -169,15 +170,17 @@ require ( go.mongodb.org/mongo-driver v1.10.0 // indirect go.opencensus.io v0.24.0 // indirect go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect - golang.org/x/crypto v0.7.0 // indirect + golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20221012211006-4de253d81b95 // indirect golang.org/x/mod v0.9.0 // indirect - golang.org/x/sync v0.1.0 // indirect + golang.org/x/sync v0.2.0 // indirect golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.110.0 // indirect - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect - google.golang.org/grpc v1.53.0 // indirect + google.golang.org/api v0.126.0 // indirect + google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect + google.golang.org/grpc v1.55.0 // indirect k8s.io/apiextensions-apiserver v0.26.0 // indirect k8s.io/apiserver v0.26.2 // indirect k8s.io/cli-runtime v0.24.2 // indirect @@ -225,7 +228,7 @@ require ( github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.2 // indirect + github.com/hashicorp/go-retryablehttp v0.7.4 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect @@ -261,14 +264,14 @@ require ( github.com/spf13/pflag v1.0.5 github.com/subosito/gotenv v1.4.2 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/term v0.6.0 - golang.org/x/text v0.8.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/oauth2 v0.8.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/term v0.10.0 + golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.29.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/square/go-jose.v2 v2.6.0 // indirect diff --git a/go.sum b/go.sum index 8192ff187..e7da64546 100644 --- a/go.sum +++ b/go.sum @@ -22,26 +22,25 @@ cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPT cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= -cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= +cloud.google.com/go v0.110.2 h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA= +cloud.google.com/go v0.110.2/go.mod h1:k04UEeEtb6ZBRTv3dZz4CeJC3jKGxyhl0sAiVVquxiw= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.18.0 h1:FEigFqoDbys2cvFkZ9Fjq4gnHBP55anJ0yQyau2f9oY= -cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= +cloud.google.com/go/compute v1.23.0 h1:tP41Zoavr8ptEqaW6j+LQOnyBBhO7OkOMAGrgLopTwY= +cloud.google.com/go/compute v1.23.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/container v1.13.1 h1:q8lTpyAsjcJZQCjGI8JJfcOG4ixl998vwe6TAgQROcM= -cloud.google.com/go/container v1.13.1/go.mod h1:6wgbMPeQRw9rSnKBCAJXnds3Pzj03C4JHamr8asWKy4= +cloud.google.com/go/container v1.24.0 h1:N51t/cgQJFqDD/W7Mb+IvmAPHrf8AbPx7Bb7aF4lROE= +cloud.google.com/go/container v1.24.0/go.mod h1:lTNExE2R7f+DLbAN+rJiKTisauFCaoDq6NURZ83eVH4= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/iam v0.12.0 h1:DRtTY29b75ciH6Ov1PHb4/iat2CLCvrOm40Q0a6DFpE= -cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= -cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= +cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k= +cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -52,8 +51,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.28.1 h1:F5QDG5ChchaAVQhINh24U99OWHURqrW8OmQcGKXcbgI= -cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5ogcBBKhU86Y= +cloud.google.com/go/storage v1.29.0 h1:6weCgzRvMg7lzuUurI4697AqIRPU1SvzHhynwpW31jI= +cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/azure-sdk-for-go v55.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= @@ -266,7 +265,11 @@ github.com/clusterhq/flocker-go v0.0.0-20160920122132-2b8b7259d313/go.mod h1:P1w github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= @@ -358,6 +361,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/euank/go-kmsg-parser v2.0.0+incompatible/go.mod h1:MhmAMZ8V4CYH4ybgdRwPr2TU5ThnS43puaKEMpja1uw= github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -498,8 +502,9 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -555,6 +560,8 @@ github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= +github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -566,8 +573,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9 github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.7.0 h1:IcsPKeInNvYi7eqSaDjiZqDDKu5rsmunY0Y1YupQSSQ= -github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= +github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= +github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -605,8 +612,8 @@ github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= -github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= +github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= @@ -714,8 +721,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/runtime v0.3.0 h1:9t7lp/9uUYPx77dTZ5XQxUq5IY1Z6NQHLNKvT/+90gc= -github.com/kubefirst/runtime v0.3.0/go.mod h1:YAww60f+GxyYZIBzJxuqpf8yzfmsRBS0Zr0QiTD7aTE= +github.com/kubefirst/runtime v0.3.4 h1:AM4FNVQnCHQWrXr/T87FzhAaz3XIfl/7xKLL8MUqXtY= +github.com/kubefirst/runtime v0.3.4/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= @@ -977,7 +984,7 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -1204,14 +1211,15 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1327,8 +1335,8 @@ golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1343,8 +1351,8 @@ golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= +golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1357,8 +1365,9 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1462,15 +1471,15 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1480,10 +1489,11 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1601,8 +1611,8 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= google.golang.org/api v0.46.0/go.mod h1:ceL4oozhkAiTID8XMmJBsIxID/9wMXJVVFXPg4ylg3I= -google.golang.org/api v0.110.0 h1:l+rh0KYUooe9JGbGVx71tbFo4SMbMTXK3I3ia2QSEeU= -google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= +google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= +google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1663,8 +1673,12 @@ google.golang.org/genproto v0.0.0-20210429181445-86c259c2b4ab/go.mod h1:P3QM42oQ google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc h1:8DyZCyvI8mE1IdLy/60bS+52xfymkE72wv1asokgtao= +google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= +google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1692,8 +1706,9 @@ google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= @@ -1703,8 +1718,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= -google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From d96dcc82ab05ea889c8563ec75ca64a1a27626ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Mon, 14 Aug 2023 11:12:37 -0400 Subject: [PATCH 11/45] fix: show CLI output on k3d destroy port used error (fix #1684) (#1749) --- cmd/k3d/destroy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/k3d/destroy.go b/cmd/k3d/destroy.go index 1a50f0571..d86319bb4 100644 --- a/cmd/k3d/destroy.go +++ b/cmd/k3d/destroy.go @@ -39,8 +39,8 @@ func destroyK3d(cmd *cobra.Command, args []string) error { // Check for existing port forwards before continuing err := k8s.CheckForExistingPortForwards(9000) if err != nil { - log.Fatal().Msgf("%s - this port is required to tear down your kubefirst environment - please close any existing port forwards before continuing", err.Error()) - return err + log.Error().Msgf("%s - this port is required to tear down your kubefirst environment - please close any existing port forwards before continuing", err.Error()) + return fmt.Errorf("%s (maybe the handoff screen is still open in another terminal) - this port is required to tear down your kubefirst environment - please close any existing port forwards before continuing", err.Error()) } progressPrinter.AddTracker("preflight-checks", "Running preflight checks", 1) From 48b9e94c7a221bab1fbee014b75ddffd1acc7c57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Tue, 15 Aug 2023 12:33:48 -0500 Subject: [PATCH 12/45] chore: chart update 2.2.9 (#1752) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 47cd8d7db..e917cce7e 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.7" + helmChartVersion = "2.2.9" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From 20aff96bc191cd2d8fa010992aa2eac61e835669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Wed, 16 Aug 2023 18:22:28 -0500 Subject: [PATCH 13/45] chore: chart update 2.2.10 (#1754) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index e917cce7e..9b90d5c3f 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.9" + helmChartVersion = "2.2.10" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From 14efdcf14b98d7be44b0c285f4c5fb3861e45d47 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Mon, 21 Aug 2023 18:05:31 -0500 Subject: [PATCH 14/45] Chore-cleanup_the_urls (#1755) * chore: refactor repo urls to use latest runtime * chore: update runtime * fix: replace the url * fix: gitlab case urls * fix: supplied variable * chore: update go mod and go sum * fix: always use https for pushing to remotes * fix: add error handling for upstream changes * fix: remove giturl references * fix: remove GitUrls * fix: move logic away from switching https/git * chore: update gitignore * fix: syntax error * chore: ignore vscode debugger file --------- Co-authored-by: Claywd <6446939+Claywd@users.noreply.github.com> --- .gitignore | 3 ++ cmd/aws/create.go | 90 ++++++++++++++++++++++++++------------ cmd/civo/create.go | 61 +++++++++++++++----------- cmd/digitalocean/create.go | 63 +++++++++++++++----------- cmd/gcp/create.go | 58 ++++++++++++++---------- cmd/k3d/create.go | 52 +++++++++++++++------- cmd/vultr/create.go | 40 +++++++++++------ go.mod | 2 +- go.sum | 4 +- 9 files changed, 236 insertions(+), 137 deletions(-) diff --git a/.gitignore b/.gitignore index 2d8c2aa75..9cbec5349 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ go.test kubefirst.yaml # kubefirst # <- this is causing files in docs to not commit, need a more explicit path ignored +__debug_* +kubefirst +launch.json diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 3d2af13b7..b7cb60d4c 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -10,6 +10,7 @@ import ( "context" "crypto/tls" "encoding/base64" + "errors" "fmt" "net/http" "os" @@ -296,18 +297,11 @@ func createAws(cmd *cobra.Command, args []string) error { return err } // Format git url based on full path to group - switch gitProtocolFlag { - case "https": - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - default: - config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - } + // Format git url based on full path to group + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } vaultClient := &vault.Conf @@ -605,6 +599,15 @@ func createAws(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", awsinternal.CloudProvider) } + // Swap tokens for git protocol + var gitopsRepoURL string + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), @@ -642,9 +645,7 @@ func createAws(cmd *cobra.Command, args []string) error { GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), GitNamespace: "N/A", GitProvider: config.GitProvider, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -688,7 +689,7 @@ func createAws(cmd *cobra.Command, args []string) error { log.Info().Msg("generating your new gitops repository") // These need to be set for reference elsewhere - viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoGitURL) + viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoURL) viper.WriteConfig() gitopsDirectoryTokens.GitopsRepoGitURL = config.DestinationGitopsRepoGitURL @@ -697,11 +698,11 @@ func createAws(cmd *cobra.Command, args []string) error { gitProviderFlag, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -727,8 +728,8 @@ func createAws(cmd *cobra.Command, args []string) error { // * handle git terraform apply progressPrinter.AddTracker("applying-git-terraform", fmt.Sprintf("Applying %s Terraform", config.GitProvider), 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) switch config.GitProvider { case "github": // //* create teams and repositories in github @@ -745,7 +746,12 @@ func createAws(cmd *cobra.Command, args []string) error { tfEnvs["GITHUB_OWNER"] = cGitOwner tfEnvs["TF_VAR_atlantis_repo_webhook_secret"] = viper.GetString("secrets.atlantis-webhook") tfEnvs["TF_VAR_atlantis_repo_webhook_url"] = atlantisWebhookURL - tfEnvs["TF_VAR_kbot_ssh_public_key"] = viper.GetString("kbot.public-key") + + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "ssh": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = viper.GetString("kbot.public-key") + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) @@ -777,9 +783,13 @@ func createAws(cmd *cobra.Command, args []string) error { tfEnvs["GITLAB_OWNER"] = cGitOwner tfEnvs["TF_VAR_atlantis_repo_webhook_secret"] = viper.GetString("secrets.atlantis-webhook") tfEnvs["TF_VAR_atlantis_repo_webhook_url"] = atlantisWebhookURL - tfEnvs["TF_VAR_kbot_ssh_public_key"] = viper.GetString("kbot.public-key") tfEnvs["TF_VAR_owner_group_id"] = strconv.Itoa(viper.GetInt("flags.gitlab-owner-group-id")) tfEnvs["TF_VAR_gitlab_owner"] = viper.GetString("flags.gitlab-owner") + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "ssh": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = viper.GetString("kbot.public-key") + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -802,8 +812,8 @@ func createAws(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -834,7 +844,7 @@ func createAws(cmd *cobra.Command, args []string) error { Auth: httpAuth, }) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -849,7 +859,7 @@ func createAws(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -926,10 +936,33 @@ func createAws(cmd *cobra.Command, args []string) error { return err } + w, err := gitopsRepo.Worktree() + if err != nil { + return err + } + + acceptableError := errors.New("already up-to-date") + + // Info("git pull origin") + err = w.Pull(&git.PullOptions{ + RemoteName: config.GitProvider, + Auth: httpAuth, + // If your local branch is not master,you will have to specify the branch + // ReferenceName: plumbing.NewBranchReferenceName(config.GitProvider), + }) + if err != nil { + if err.Error() != acceptableError.Error() { + return err + } + log.Info().Msg("Repo already up to date, nothing to push") + } + log.Info().Msgf("Pulled latest changes into gitops repo from %s", config.GitProvider) + err = gitClient.Commit(gitopsRepo, "committing detokenized kms key") if err != nil { return err } + log.Info().Msgf("Latest changes have been into gitops repo from %s", config.GitProvider) err = gitopsRepo.Push(&git.PushOptions{ RemoteName: config.GitProvider, @@ -1094,7 +1127,7 @@ func createAws(cmd *cobra.Command, args []string) error { config.GitProvider, cGitUser, os.Getenv("CF_API_TOKEN"), - config.DestinationGitopsRepoURL, + gitopsRepoURL, config.GitProtocol, clientset, ecrFlag, @@ -1187,7 +1220,8 @@ func createAws(cmd *cobra.Command, args []string) error { telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricCreateRegistryStarted, "") log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 2ffd9d909..b43f7bfb3 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -280,18 +280,11 @@ func createCivo(cmd *cobra.Command, args []string) error { return err } // Format git url based on full path to group - switch gitProtocolFlag { - case "https": - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - default: - config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - } + // Format git url based on full path to group + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } civoConf := civo.CivoConfiguration{ @@ -316,6 +309,7 @@ func createCivo(cmd *cobra.Command, args []string) error { kubefirstTeam = "false" } + // Swap tokens for cloudflare var externalDNSProviderTokenEnvName, externalDNSProviderSecretKey string if dnsProviderFlag == "cloudflare" { externalDNSProviderTokenEnvName = "CF_API_TOKEN" @@ -325,6 +319,15 @@ func createCivo(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", civo.CloudProvider) } + // Swap tokens for git protocol; used by tokens, argocd registry object, and secret bootstrapping for argo template credentials + var gitopsRepoURL string + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), @@ -358,9 +361,7 @@ func createCivo(cmd *cobra.Command, args []string) error { GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), GitNamespace: "N/A", GitProvider: config.GitProvider, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -709,11 +710,11 @@ func createCivo(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -737,8 +738,8 @@ func createCivo(cmd *cobra.Command, args []string) error { //* handle git terraform apply progressPrinter.AddTracker("applying-git-terraform", fmt.Sprintf("Applying %s Terraform", config.GitProvider), 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) switch config.GitProvider { case "github": // //* create teams and repositories in github @@ -751,6 +752,11 @@ func createCivo(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/github" tfEnvs := map[string]string{} tfEnvs = civo.GetGithubTerraformEnvs(config, tfEnvs) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) @@ -778,6 +784,11 @@ func createCivo(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/gitlab" tfEnvs := map[string]string{} tfEnvs = civo.GetGitlabTerraformEnvs(config, tfEnvs, cGitlabOwnerGroupID) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -800,8 +811,8 @@ func createCivo(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -832,7 +843,7 @@ func createCivo(cmd *cobra.Command, args []string) error { Auth: httpAuth, }) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -847,7 +858,7 @@ func createCivo(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -946,7 +957,7 @@ func createCivo(cmd *cobra.Command, args []string) error { config.GitProvider, cGitUser, os.Getenv("CF_API_TOKEN"), - config.DestinationGitopsRepoURL, + gitopsRepoURL, config.GitProtocol, ) if err != nil { @@ -1104,7 +1115,7 @@ func createCivo(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index 651f1bd87..beb39ce74 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -279,18 +279,11 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { return err } // Format git url based on full path to group - switch gitProtocolFlag { - case "https": - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - default: - config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - } + // Format git url based on full path to group + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } // Verify region compatibility @@ -326,6 +319,15 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", digitalocean.CloudProvider) } + // Swap tokens for git protocol + var gitopsRepoURL string + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), @@ -359,9 +361,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), GitNamespace: "N/A", GitProvider: config.GitProvider, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -687,7 +687,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { log.Info().Msg("generating your new gitops repository") // These need to be set for reference elsewhere - viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoHttpsURL) + viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoURL) viper.WriteConfig() // Determine if anything exists at domain apex @@ -698,11 +698,11 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -726,8 +726,8 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { //* handle git terraform apply progressPrinter.AddTracker("applying-git-terraform", fmt.Sprintf("Applying %s Terraform", config.GitProvider), 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) switch config.GitProvider { case "github": // //* create teams and repositories in github @@ -740,6 +740,11 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/github" tfEnvs := map[string]string{} tfEnvs = digitalocean.GetGithubTerraformEnvs(config, tfEnvs) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) @@ -767,6 +772,11 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/gitlab" tfEnvs := map[string]string{} tfEnvs = digitalocean.GetGitlabTerraformEnvs(config, tfEnvs, cGitlabOwnerGroupID) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -789,8 +799,8 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -825,7 +835,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -840,7 +850,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -941,7 +951,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { config.GitProvider, cGitUser, os.Getenv("CF_API_TOKEN"), - config.DestinationGitopsRepoURL, + gitopsRepoURL, config.GitProtocol, ) if err != nil { @@ -1099,7 +1109,8 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 333777486..5337ed87c 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -277,18 +277,10 @@ func createGCP(cmd *cobra.Command, args []string) error { return err } // Format git url based on full path to group - switch gitProtocolFlag { - case "https": - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) - default: - config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - config.DestinationGitopsRepoURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) - } + config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationGitopsRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/gitops.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoGitURL = fmt.Sprintf("git@gitlab.com:%s/metaphor.git", gitlabClient.ParentGroupPath) } var sshPrivateKey, sshPublicKey string @@ -309,6 +301,15 @@ func createGCP(cmd *cobra.Command, args []string) error { kubefirstTeam = "false" } + // Swap tokens for git protocol + var gitopsRepoURL string + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), @@ -343,9 +344,7 @@ func createGCP(cmd *cobra.Command, args []string) error { GitNamespace: "N/A", GitProvider: config.GitProvider, GitProtocol: config.GitProtocol, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -661,7 +660,7 @@ func createGCP(cmd *cobra.Command, args []string) error { log.Info().Msg("generating your new gitops repository") // These need to be set for reference elsewhere - viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoHttpsURL) + viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoURL) viper.WriteConfig() var externalDNSProviderTokenEnvName, externalDNSProviderSecretKey string @@ -686,11 +685,11 @@ func createGCP(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -728,6 +727,11 @@ func createGCP(cmd *cobra.Command, args []string) error { a, _ := os.ReadFile(config.GCPAuth) tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs = gcp.GetGithubTerraformEnvs(config, tfEnvs) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) @@ -757,6 +761,11 @@ func createGCP(cmd *cobra.Command, args []string) error { a, _ := os.ReadFile(config.GCPAuth) tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs = gcp.GetGitlabTerraformEnvs(config, tfEnvs, cGitlabOwnerGroupID) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -779,8 +788,8 @@ func createGCP(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -811,7 +820,7 @@ func createGCP(cmd *cobra.Command, args []string) error { Auth: httpAuth, }) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) log.Panic().Msg(msg) } @@ -824,7 +833,7 @@ func createGCP(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) log.Panic().Msg(msg) } @@ -921,7 +930,7 @@ func createGCP(cmd *cobra.Command, args []string) error { kcfg.Clientset, config.GitProvider, cGitUser, - config.DestinationGitopsRepoURL, + gitopsRepoURL, config.GitProtocol, os.Getenv("CF_API_TOKEN"), config.GCPAuth, @@ -1082,7 +1091,8 @@ func createGCP(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 266613024..646462421 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -442,7 +442,8 @@ func runK3d(cmd *cobra.Command, args []string) error { log.Info().Msg(fmt.Sprintf("already completed %s checks - continuing", config.GitProvider)) progressPrinter.IncrementTracker("preflight-checks", 1) } - + // Swap tokens for git protocol + var gitopsRepoURL string executionControl = viper.GetBool("kubefirst-checks.kbot-setup") if !executionControl { telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricKbotSetupStarted, "") @@ -479,7 +480,15 @@ func runK3d(cmd *cobra.Command, args []string) error { log.Info().Msgf("generate public keys failed: %s\n", err.Error()) } - gitopsTemplateTokens := k3d.GitopsTokenValues{ + // Swap tokens for git protocol + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + + gitopsDirectoryTokens := k3d.GitopsDirectoryValues{ GithubOwner: cGitOwner, GithubUser: cGitUser, GitlabOwner: cGitOwner, @@ -502,18 +511,16 @@ func runK3d(cmd *cobra.Command, args []string) error { KubefirstVersion: configs.K1Version, KubefirstTeam: kubefirstTeam, KubeconfigPath: config.Kubeconfig, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitProvider: config.GitProvider, ClusterId: clusterId, CloudProvider: k3d.CloudProvider, } if useTelemetryFlag { - gitopsTemplateTokens.UseTelemetry = "true" + gitopsDirectoryTokens.UseTelemetry = "true" } else { - gitopsTemplateTokens.UseTelemetry = "false" + gitopsDirectoryTokens.UseTelemetry = "false" } //* generate http credentials for git auth over https @@ -564,13 +571,13 @@ func runK3d(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, - &gitopsTemplateTokens, + &gitopsDirectoryTokens, config.MetaphorDir, &metaphorTemplateTokens, gitProtocolFlag, @@ -610,6 +617,11 @@ func runK3d(cmd *cobra.Command, args []string) error { tfEnvs["AWS_SECRET_ACCESS_KEY"] = pkg.MinioDefaultPassword tfEnvs["TF_VAR_aws_access_key_id"] = pkg.MinioDefaultUsername tfEnvs["TF_VAR_aws_secret_access_key"] = pkg.MinioDefaultPassword + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) @@ -644,6 +656,11 @@ func runK3d(cmd *cobra.Command, args []string) error { tfEnvs["AWS_SECRET_ACCESS_KEY"] = pkg.MinioDefaultPassword tfEnvs["TF_VAR_aws_access_key_id"] = pkg.MinioDefaultUsername tfEnvs["TF_VAR_aws_secret_access_key"] = pkg.MinioDefaultPassword + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -666,8 +683,8 @@ func runK3d(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoGitURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -701,7 +718,7 @@ func runK3d(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoGitURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -716,7 +733,7 @@ func runK3d(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -780,7 +797,7 @@ func runK3d(cmd *cobra.Command, args []string) error { err = k3d.AddK3DSecrets( atlantisWebhookSecret, viper.GetString("kbot.public-key"), - config.DestinationGitopsRepoURL, + gitopsRepoURL, viper.GetString("kbot.private-key"), config.GitProvider, cGitUser, @@ -1012,7 +1029,8 @@ func runK3d(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() @@ -1276,7 +1294,7 @@ func runK3d(cmd *cobra.Command, args []string) error { err = k3d.PostRunPrepareGitopsRepository(clusterNameFlag, config.GitopsDir, - &gitopsTemplateTokens, + &gitopsDirectoryTokens, ) if err != nil { log.Info().Msgf("Error detokenize post run: %s", err) diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 171b9b582..2857dd62d 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -281,8 +281,7 @@ func createVultr(cmd *cobra.Command, args []string) error { // Format git url based on full path to group switch gitProtocolFlag { case "https": - config.DestinationGitopsRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) - config.DestinationMetaphorRepoHttpsURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) + config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) config.DestinationGitopsRepoURL = fmt.Sprintf("https://gitlab.com/%s/gitops.git", gitlabClient.ParentGroupPath) config.DestinationMetaphorRepoURL = fmt.Sprintf("https://gitlab.com/%s/metaphor.git", gitlabClient.ParentGroupPath) default: @@ -319,6 +318,15 @@ func createVultr(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = fmt.Sprintf("%s-token", vultr.CloudProvider) } + // Swap tokens for git protocol + var gitopsRepoURL string + switch config.GitProtocol { + case "https": + gitopsRepoURL = config.DestinationGitopsRepoURL + default: + gitopsRepoURL = config.DestinationGitopsRepoGitURL + } + gitopsDirectoryTokens := providerConfigs.GitopsDirectoryValues{ AlertsEmail: alertsEmailFlag, AtlantisAllowList: fmt.Sprintf("%s/%s/*", cGitHost, cGitOwner), @@ -352,9 +360,7 @@ func createVultr(cmd *cobra.Command, args []string) error { GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), GitNamespace: "N/A", GitProvider: config.GitProvider, - GitopsRepoGitURL: config.DestinationGitopsRepoGitURL, - GitopsRepoHttpsURL: config.DestinationGitopsRepoHttpsURL, - GitopsRepoURL: config.DestinationGitopsRepoURL, + GitopsRepoURL: gitopsRepoURL, GitRunner: fmt.Sprintf("%s Runner", config.GitProvider), GitRunnerDescription: fmt.Sprintf("Self Hosted %s Runner", config.GitProvider), GitRunnerNS: fmt.Sprintf("%s-runner", config.GitProvider), @@ -683,7 +689,7 @@ func createVultr(cmd *cobra.Command, args []string) error { log.Info().Msg("generating your new gitops repository") // These need to be set for reference elsewhere - viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoHttpsURL) + viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoURL) viper.WriteConfig() // Determine if anything exists at domain apex @@ -694,11 +700,11 @@ func createVultr(cmd *cobra.Command, args []string) error { config.GitProvider, clusterNameFlag, clusterTypeFlag, - config.DestinationGitopsRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationGitopsRepoURL, //default to https for git interactions when creating remotes config.GitopsDir, gitopsTemplateBranchFlag, gitopsTemplateURLFlag, - config.DestinationMetaphorRepoHttpsURL, //default to https for git interactions when creating remotes + config.DestinationMetaphorRepoURL, //default to https for git interactions when creating remotes config.K1Dir, &gitopsDirectoryTokens, config.MetaphorDir, @@ -763,6 +769,11 @@ func createVultr(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/gitlab" tfEnvs := map[string]string{} tfEnvs = vultr.GetGitlabTerraformEnvs(config, tfEnvs, cGitlabOwnerGroupID) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating gitlab resources with terraform %s: %s", tfEntrypoint, err) @@ -785,8 +796,8 @@ func createVultr(cmd *cobra.Command, args []string) error { progressPrinter.AddTracker("pushing-gitops-repos-upstream", "Pushing git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) - log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoHttpsURL) - log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoHttpsURL) + log.Info().Msgf("referencing gitops repository: %s", config.DestinationGitopsRepoURL) + log.Info().Msgf("referencing metaphor repository: %s", config.DestinationMetaphorRepoURL) executionControl = viper.GetBool("kubefirst-checks.gitops-repo-pushed") if !executionControl { @@ -818,7 +829,7 @@ func createVultr(cmd *cobra.Command, args []string) error { Auth: httpAuth, }) if err != nil { - msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized gitops repository to remote %s: %s", config.DestinationGitopsRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -833,7 +844,7 @@ func createVultr(cmd *cobra.Command, args []string) error { }, ) if err != nil { - msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoHttpsURL, err) + msg := fmt.Sprintf("error pushing detokenized metaphor repository to remote %s: %s", config.DestinationMetaphorRepoURL, err) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricGitopsRepoPushFailed, msg) if !strings.Contains(msg, "already up-to-date") { log.Panic().Msg(msg) @@ -934,7 +945,7 @@ func createVultr(cmd *cobra.Command, args []string) error { config.GitProvider, cGitUser, os.Getenv("CF_API_TOKEN"), - config.DestinationGitopsRepoURL, + gitopsRepoURL, config.GitProtocol, ) if err != nil { @@ -1092,7 +1103,8 @@ func createVultr(cmd *cobra.Command, args []string) error { } log.Info().Msg("applying the registry application to argocd") - registryApplicationObject := argocd.GetArgoCDApplicationObject(config.DestinationGitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + registryApplicationObject := argocd.GetArgoCDApplicationObject(gitopsRepoURL, fmt.Sprintf("registry/%s", clusterNameFlag)) + _, _ = argocdClient.ArgoprojV1alpha1().Applications("argocd").Create(context.Background(), registryApplicationObject, metav1.CreateOptions{}) viper.Set("kubefirst-checks.argocd-create-registry", true) viper.WriteConfig() diff --git a/go.mod b/go.mod index 8b1c2c105..85b9e8868 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/go-git/go-git/v5 v5.6.1 github.com/hashicorp/vault/api v1.9.0 - github.com/kubefirst/runtime v0.3.4 + github.com/kubefirst/runtime v0.3.9 github.com/rs/zerolog v1.29.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index e7da64546..72f5d4eb4 100644 --- a/go.sum +++ b/go.sum @@ -721,8 +721,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/runtime v0.3.4 h1:AM4FNVQnCHQWrXr/T87FzhAaz3XIfl/7xKLL8MUqXtY= -github.com/kubefirst/runtime v0.3.4/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= +github.com/kubefirst/runtime v0.3.9 h1:Wl+gxradufEEyUAIDbQxp+4bLrnMxmQS+X6SlSJLQWw= +github.com/kubefirst/runtime v0.3.9/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= From 903bf0a7966a93a0c27b5045fa6c919356c90d50 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 10:02:01 -0500 Subject: [PATCH 15/45] fix: add container registry url into gitops tokens (#1761) --- cmd/gcp/create.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 5337ed87c..9fce5d9f5 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -362,6 +362,8 @@ func createGCP(cmd *cobra.Command, args []string) error { GitopsRepoAtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainNameFlag), GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, + + ContainerRegistryURL: fmt.Sprintf("%s/%s/metaphor", containerRegistryHost, cGitOwner), } viper.Set(fmt.Sprintf("%s.atlantis.webhook.url", config.GitProvider), fmt.Sprintf("https://atlantis.%s/events", domainNameFlag)) From a443a70a866acb8afa7ef099daa0074b3a81654d Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 10:26:46 -0500 Subject: [PATCH 16/45] fix: update secret key to align with runtime value (#1762) --- cmd/gcp/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 9fce5d9f5..e783fb431 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -671,7 +671,7 @@ func createGCP(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = "cf-api-token" } else { externalDNSProviderTokenEnvName = "GCP_AUTH" - externalDNSProviderSecretKey = fmt.Sprintf("%s-token", gcp.CloudProvider) + externalDNSProviderSecretKey = fmt.Sprintf("google_application_credentials") } gitopsDirectoryTokens.ExternalDNSProviderName = dnsProviderFlag From 2d22d0aa52b953128230341750fcddb145e39051 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 15:46:50 -0500 Subject: [PATCH 17/45] feat: add ability for force destroying buckets (#1763) * feat: add ability for force destroying buckets * fix: dns provider should be google --- cmd/gcp/command.go | 5 +++-- cmd/gcp/create.go | 7 +++++++ cmd/gcp/destroy.go | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/gcp/command.go b/cmd/gcp/command.go index e86304d59..8cb470acc 100644 --- a/cmd/gcp/command.go +++ b/cmd/gcp/command.go @@ -29,6 +29,7 @@ var ( gitopsTemplateURLFlag string gitopsTemplateBranchFlag string useTelemetryFlag bool + forceDestroyFlag bool // RootCredentials copyArgoCDPasswordToClipboardFlag bool @@ -74,7 +75,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&cloudRegionFlag, "cloud-region", "us-east1", "the GCP region to provision infrastructure in") createCmd.Flags().StringVar(&clusterNameFlag, "cluster-name", "kubefirst", "the name of the cluster to create") createCmd.Flags().StringVar(&clusterTypeFlag, "cluster-type", "mgmt", "the type of cluster to create (i.e. mgmt|workload)") - createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "gcp", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) + createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "google", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the GCP DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.MarkFlagRequired("domain-name") createCmd.Flags().StringVar(&gcpProjectFlag, "gcp-project", "", "gcp project id (required)") @@ -86,7 +87,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository") createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone") createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry") - + createCmd.Flags().BoolVar(&forceDestroyFlag, "force_destroy", false, "allows force destruction on objects (helpful for test environments, defaults to false)") return createCmd } diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index e783fb431..b160da8eb 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -13,6 +13,7 @@ import ( "io/ioutil" "net/http" "os" + "strconv" "strings" "time" @@ -86,6 +87,11 @@ func createGCP(cmd *cobra.Command, args []string) error { return err } + forceDestroy, err := cmd.Flags().GetBool("force_destroy") + if err != nil { + return err + } + gcpProjectFlag, err := cmd.Flags().GetString("gcp-project") if err != nil { return err @@ -865,6 +871,7 @@ func createGCP(cmd *cobra.Command, args []string) error { a, _ := os.ReadFile(config.GCPAuth) tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs["TF_VAR_project"] = gcpProjectFlag + tfEnvs["TF_VAR_force_destroy"] = strconv.FormatBool(forceDestroy) tfEntrypoint := config.GitopsDir + "/terraform/gcp/services" err = terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/gcp/destroy.go b/cmd/gcp/destroy.go index 2a2f40539..68ef24b9d 100644 --- a/cmd/gcp/destroy.go +++ b/cmd/gcp/destroy.go @@ -32,6 +32,7 @@ func destroyGCP(cmd *cobra.Command, args []string) error { // Determine if there are active installs gitProvider := viper.GetString("flags.git-provider") gitProtocol := viper.GetString("flags.git-protocol") + forceDestroy := viper.GetBool("flags.force_destroy") // _, err := helpers.EvalDestroy(gcp.CloudProvider, gitProvider) // if err != nil { // return err @@ -167,6 +168,7 @@ func destroyGCP(cmd *cobra.Command, args []string) error { tfEnvs["GITLAB_TOKEN"] = cGitToken tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs["TF_VAR_project"] = gcpProject + tfEnvs["TF_VAR_force_destroy"] = strconv.FormatBool(forceDestroy) err = terraform.InitDestroyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { log.Printf("error executing terraform destroy %s", tfEntrypoint) From 7683120efa6618dac7a9a73c3e082d61b706dbe1 Mon Sep 17 00:00:00 2001 From: John Dietz Date: Wed, 23 Aug 2023 18:55:42 -0400 Subject: [PATCH 18/45] adjust 2nd k3d create git push to https auth (#1766) --- cmd/k3d/create.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 646462421..778147114 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -23,7 +23,6 @@ import ( argocdapi "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" "github.com/go-git/go-git/v5" githttps "github.com/go-git/go-git/v5/plumbing/transport/http" - "github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/kubefirst/kubefirst/internal/gitShim" "github.com/kubefirst/kubefirst/internal/telemetryShim" "github.com/kubefirst/kubefirst/internal/utilities" @@ -474,11 +473,6 @@ func runK3d(cmd *cobra.Command, args []string) error { telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricInitCompleted, "") telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallStarted, "") - //* generate public keys for ssh - publicKeys, err := ssh.NewPublicKeys("git", []byte(viper.GetString("kbot.private-key")), "") - if err != nil { - log.Info().Msgf("generate public keys failed: %s\n", err.Error()) - } // Swap tokens for git protocol switch config.GitProtocol { @@ -1321,7 +1315,7 @@ func runK3d(cmd *cobra.Command, args []string) error { } err = gitopsRepo.Push(&git.PushOptions{ RemoteName: config.GitProvider, - Auth: publicKeys, + Auth: httpAuth, }) if err != nil { log.Info().Msgf("Error pushing repo: %s", err) From 10c6c74e988b6ef25912398b40666710c62f113c Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 23 Aug 2023 21:05:36 -0500 Subject: [PATCH 19/45] fix: adjust messaging to reflect argocd priority (#1767) --- cmd/aws/create.go | 4 ++-- cmd/civo/create.go | 4 ++-- cmd/digitalocean/create.go | 4 ++-- cmd/gcp/create.go | 4 ++-- cmd/vultr/create.go | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index b7cb60d4c..cac9ebbcd 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -1426,7 +1426,7 @@ func createAws(cmd *cobra.Command, args []string) error { } // Wait for console Deployment Pods to transition to Running - progressPrinter.AddTracker("deploying-kubefirst-console", "Deploying kubefirst console", 1) + progressPrinter.AddTracker("syncing-remaining-argocd-apps", "Syncing Remaining ArgoCD Apps", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) consoleDeployment, err := k8s.ReturnDeploymentObject( @@ -1447,7 +1447,7 @@ func createAws(cmd *cobra.Command, args []string) error { } //* console port-forward - progressPrinter.IncrementTracker("deploying-kubefirst-console", 1) + progressPrinter.IncrementTracker("syncing-remaining-argocd-apps", 1) consoleStopChannel := make(chan struct{}, 1) defer func() { close(consoleStopChannel) diff --git a/cmd/civo/create.go b/cmd/civo/create.go index b43f7bfb3..9caa938e1 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -1288,7 +1288,7 @@ func createCivo(cmd *cobra.Command, args []string) error { } // Wait for console Deployment Pods to transition to Running - progressPrinter.AddTracker("deploying-kubefirst-console", "Deploying kubefirst console", 1) + progressPrinter.AddTracker("syncing-remaining-argocd-apps", "Syncing Remaining ArgoCD Apps", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) consoleDeployment, err := k8s.ReturnDeploymentObject( @@ -1309,7 +1309,7 @@ func createCivo(cmd *cobra.Command, args []string) error { } //* console port-forward - progressPrinter.IncrementTracker("deploying-kubefirst-console", 1) + progressPrinter.IncrementTracker("syncing-remaining-argocd-apps", 1) consoleStopChannel := make(chan struct{}, 1) defer func() { close(consoleStopChannel) diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index beb39ce74..cb705a32d 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -1283,7 +1283,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { } // Wait for console Deployment Pods to transition to Running - progressPrinter.AddTracker("deploying-kubefirst-console", "Deploying kubefirst console", 1) + progressPrinter.AddTracker("syncing-remaining-argocd-apps", "Syncing Remaining ArgoCD Apps", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) consoleDeployment, err := k8s.ReturnDeploymentObject( @@ -1304,7 +1304,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { } //* console port-forward - progressPrinter.IncrementTracker("deploying-kubefirst-console", 1) + progressPrinter.IncrementTracker("syncing-remaining-argocd-apps", 1) consoleStopChannel := make(chan struct{}, 1) defer func() { close(consoleStopChannel) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index b160da8eb..f8b312693 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -1275,7 +1275,7 @@ func createGCP(cmd *cobra.Command, args []string) error { } // Wait for console Deployment Pods to transition to Running - progressPrinter.AddTracker("deploying-kubefirst-console", "Deploying kubefirst console", 1) + progressPrinter.AddTracker("syncing-remaining-argocd-apps", "Syncing Remaining ArgoCD Apps", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) consoleDeployment, err := k8s.ReturnDeploymentObject( @@ -1296,7 +1296,7 @@ func createGCP(cmd *cobra.Command, args []string) error { } //* console port-forward - progressPrinter.IncrementTracker("deploying-kubefirst-console", 1) + progressPrinter.IncrementTracker("syncing-remaining-argocd-apps", 1) consoleStopChannel := make(chan struct{}, 1) defer func() { diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 2857dd62d..4e67bf9d0 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -1277,7 +1277,7 @@ func createVultr(cmd *cobra.Command, args []string) error { } // Wait for console Deployment Pods to transition to Running - progressPrinter.AddTracker("deploying-kubefirst-console", "Deploying kubefirst console", 1) + progressPrinter.AddTracker("syncing-remaining-argocd-apps", "Syncing Remaining ArgoCD Apps", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) consoleDeployment, err := k8s.ReturnDeploymentObject( @@ -1298,7 +1298,7 @@ func createVultr(cmd *cobra.Command, args []string) error { } //* console port-forward - progressPrinter.IncrementTracker("deploying-kubefirst-console", 1) + progressPrinter.IncrementTracker("syncing-remaining-argocd-apps", 1) consoleStopChannel := make(chan struct{}, 1) defer func() { From fcfb2f33429105e3a48a1ac423dbbc2d79c5d8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Harper?= Date: Thu, 24 Aug 2023 14:54:07 -0400 Subject: [PATCH 20/45] fix: check new version from homebrew-core instead of k1 repo (fix #1746) (#1753) Co-authored-by: Clayton Dittman --- go.mod | 1 - go.sum | 2 -- internal/common/common.go | 61 ++++++++++++++++++++++++++++++++------- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 85b9e8868..59bd9c5dd 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.15.0 - github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e k8s.io/api v0.26.2 k8s.io/apimachinery v0.27.1 k8s.io/client-go v11.0.1-0.20190816222228-6d55c1b1f1ca+incompatible diff --git a/go.sum b/go.sum index 72f5d4eb4..a7d4275ed 100644 --- a/go.sum +++ b/go.sum @@ -1084,8 +1084,6 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e h1:IWllFTiDjjLIf2oeKxpIUmtiDV5sn71VgeQgg6vcE7k= -github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= diff --git a/internal/common/common.go b/internal/common/common.go index 70967b227..a444b492c 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -8,13 +8,29 @@ package common import ( "fmt" + "io" + "net/http" + "regexp" "runtime" "strings" - "github.com/kubefirst/runtime/configs" - "github.com/tcnksm/go-latest" + "github.com/kubefirst/kubefirst/configs" ) +type CheckResponse struct { + // Current is current latest version on source. + Current string + + // Outdate is true when target version is less than Curernt on source. + Outdated bool + + // Latest is true when target version is equal to Current on source. + Latest bool + + // New is true when target version is greater than Current on source. + New bool +} + // CheckForVersionUpdate determines whether or not there is a new cli version available func CheckForVersionUpdate() { if configs.K1Version != configs.DefaultK1Version { @@ -33,17 +49,42 @@ func CheckForVersionUpdate() { } // versionCheck compares local to remote version -func versionCheck() (res *latest.CheckResponse, skip bool) { - githubTag := &latest.GithubTag{ - Owner: "kubefirst", - Repository: "kubefirst", - FixVersionStrFunc: latest.DeleteFrontV(), +func versionCheck() (res *CheckResponse, skip bool) { + var latestVersion string + + resp, err := http.Get("https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/k/kubefirst.rb") + + if err != nil { + fmt.Printf("checking for a newer version failed (cannot get Homebrew formula) with: %s", err) + return nil, true } - res, err := latest.Check(githubTag, strings.Replace(configs.K1Version, "v", "", 1)) + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + fmt.Printf("checking for a newer version failed (HTTP error) with: %s", err) + return nil, true + } + + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { - fmt.Printf("checking for a newer version failed with: %s", err) + fmt.Printf("checking for a newer version failed (cannot read the file) with: %s", err) return nil, true } - return res, false + bodyString := string(bodyBytes) + if !strings.Contains(bodyString, "url \"https://github.com/kubefirst/kubefirst/archive/refs/tags/") { + fmt.Printf("checking for a newer version failed (no reference to kubefirst release) with: %s", err) + return nil, true + } + + re := regexp.MustCompile(`.*/v(.*).tar.gz"`) + matches := re.FindStringSubmatch(bodyString) + latestVersion = matches[1] + + return &CheckResponse{ + Current: configs.K1Version, + Outdated: latestVersion < configs.K1Version, + Latest: latestVersion == configs.K1Version, + New: configs.K1Version > latestVersion, + }, false } From 3a06c79af9502e13d2604fc95cdaed83dc86c812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Fri, 25 Aug 2023 12:25:56 -0500 Subject: [PATCH 21/45] feat: macrochart (#1751) * feat: civo initial implementation * feat: export civo, aws, k3d * feat: retry * test: chart name * chore: refactor repo urls to use latest runtime * chore: update runtime * fix: replace the url * fix: gitlab case urls * fix: supplied variable * chore: update go mod and go sum * feat: civo & aws deployments * feat: k3d export validation * chore: update runtime version * chore: merge * chore: update helm chart version --------- Co-authored-by: Claywd <6446939+Claywd@users.noreply.github.com> --- cmd/aws/create.go | 73 +++++++++++++++++---- cmd/civo/create.go | 63 ++++++++++++++---- cmd/k3d/create.go | 60 +++++++++++++---- cmd/vultr/create.go | 5 ++ go.mod | 6 +- go.sum | 8 +-- internal/launch/constants.go | 2 +- internal/utilities/utilities.go | 110 ++++++++++++++++++++++++++++++++ 8 files changed, 278 insertions(+), 49 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index cac9ebbcd..207f567fa 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -46,6 +46,8 @@ import ( "github.com/kubefirst/runtime/pkg/services" internalssh "github.com/kubefirst/runtime/pkg/ssh" "github.com/kubefirst/runtime/pkg/terraform" + runtimetypes "github.com/kubefirst/runtime/pkg/types" + utils "github.com/kubefirst/runtime/pkg/utils" "github.com/kubefirst/runtime/pkg/vault" "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -166,6 +168,16 @@ func createAws(cmd *cobra.Command, args []string) error { awsClient := &awsinternal.AWSConfiguration{ Config: awsinternal.NewAwsV2(cloudRegionFlag), } + creds, err := awsClient.Config.Credentials.Retrieve(aws.BackgroundContext()) + + if err != nil { + return err + } + + viper.Set("kubefirst.state-store-creds.access-key-id", creds.AccessKeyID) + viper.Set("kubefirst.state-store-creds.secret-access-key-id", creds.SecretAccessKey) + viper.Set("kubefirst.state-store-creds.token", creds.SessionToken) + viper.WriteConfig() _, err = awsClient.CheckAvailabilityZones(cloudRegionFlag) if err != nil { @@ -461,7 +473,9 @@ func createAws(cmd *cobra.Command, args []string) error { log.Info().Msgf("state store bucket is %s", *kubefirstStateStoreBucket.Location) log.Info().Msgf("artifacts bucket is %s", *kubefirstArtifactsBucket.Location) - viper.Set("kubefirst.state-store-bucket", strings.ReplaceAll(*kubefirstStateStoreBucket.Location, "/", "")) + viper.Set("kubefirst.state-store-bucket", kubefirstStateStoreBucketName) + viper.Set("kubefirst.state-store.name", kubefirstStateStoreBucketName) + viper.Set("kubefirst.state-store.hostname", "s3.amazonaws.com") viper.Set("kubefirst.artifacts-bucket", strings.ReplaceAll(*kubefirstArtifactsBucket.Location, "/", "")) viper.Set("kubefirst-checks.state-store-create", true) viper.WriteConfig() @@ -1432,7 +1446,7 @@ func createAws(cmd *cobra.Command, args []string) error { consoleDeployment, err := k8s.ReturnDeploymentObject( clientset, "app.kubernetes.io/instance", - "kubefirst-console", + "kubefirst", "kubefirst", 1200, ) @@ -1462,20 +1476,11 @@ func createAws(cmd *cobra.Command, args []string) error { consoleStopChannel, ) - log.Info().Msg("kubefirst installation complete") - log.Info().Msg("welcome to your new kubefirst platform powered by AWS") - time.Sleep(time.Second * 1) // allows progress bars to finish - err = pkg.IsConsoleUIAvailable(pkg.KubefirstConsoleLocalURLCloud) if err != nil { log.Error().Err(err).Msg("") } - err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLCloud) - if err != nil { - log.Error().Err(err).Msg("") - } - // Mark cluster install as complete telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallCompleted, "") viper.Set("kubefirst-checks.cluster-install-complete", true) @@ -1484,8 +1489,50 @@ func createAws(cmd *cobra.Command, args []string) error { // Set flags used to track status of active options helpers.SetClusterStatusFlags(awsinternal.CloudProvider, config.GitProvider) - if !ciFlag { - reports.AwsHandoffScreen(viper.GetString("components.argocd.password"), clusterNameFlag, domainNameFlag, cGitOwner, config, false) + //Export and Import Cluster + cl := utilities.CreateClusterRecordFromRaw(useTelemetryFlag, cGitOwner, cGitUser, cGitToken, cGitlabOwnerGroupID, gitopsTemplateURLFlag, gitopsTemplateBranchFlag) + + var localFilePath = fmt.Sprintf("%s/%s.json", "/tmp/api/cluster/export", clusterNameFlag) + var remoteFilePath = fmt.Sprintf("%s.json", clusterNameFlag) + utilities.CreateClusterRecordFile(clusterNameFlag, cl) + + pushObject := runtimetypes.PushBucketObject{ + LocalFilePath: localFilePath, + RemoteFilePath: remoteFilePath, + ContentType: "application/json", + } + + err = utils.PutClusterObject(&cl.StateStoreCredentials, &cl.StateStoreDetails, &pushObject) + if err != nil { + log.Error().Err(err).Msgf("error pushing cluster object, %s", cl.StateStoreDetails.Hostname) + return err + } + + kubernetesConfig := runtimetypes.KubernetesClient{ + Clientset: clientset, + KubeConfigPath: config.Kubeconfig, + RestConfig: restConfig, + } + err = utils.ExportCluster(kubernetesConfig, cl) + if err != nil { + log.Error().Err(err).Msg("error exporting cluster object") + viper.Set("kubefirst.setup-complete", false) + viper.Set("kubefirst-checks.cluster-install-complete", false) + viper.WriteConfig() + return err + } else { + err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLCloud) + if err != nil { + log.Error().Err(err).Msg("") + } + + log.Info().Msg("kubefirst installation complete") + log.Info().Msg("welcome to your new kubefirst platform running in K3d") + time.Sleep(time.Second * 1) // allows progress bars to finish + + if !ciFlag { + reports.AwsHandoffScreen(viper.GetString("components.argocd.password"), clusterNameFlag, domainNameFlag, cGitOwner, config, false) + } } defer func(c segment.SegmentClient) { diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 9caa938e1..9b38298c2 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -43,6 +43,8 @@ import ( internalssh "github.com/kubefirst/runtime/pkg/ssh" "github.com/kubefirst/runtime/pkg/ssl" "github.com/kubefirst/runtime/pkg/terraform" + runtimetypes "github.com/kubefirst/runtime/pkg/types" + utils "github.com/kubefirst/runtime/pkg/utils" "github.com/spf13/cobra" "github.com/spf13/viper" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -471,6 +473,7 @@ func createCivo(cmd *cobra.Command, args []string) error { log.Info().Msg(err.Error()) } + // StateStoreCredentials viper.Set("kubefirst.state-store-creds.access-key-id", creds.AccessKeyID) viper.Set("kubefirst.state-store-creds.secret-access-key-id", creds.SecretAccessKeyID) viper.Set("kubefirst.state-store-creds.name", creds.Name) @@ -549,6 +552,7 @@ func createCivo(cmd *cobra.Command, args []string) error { viper.Set("kubefirst.state-store.id", bucket.ID) viper.Set("kubefirst.state-store.name", bucket.Name) + viper.Set("kubefirst.state-store.hostname", bucket.BucketURL) viper.Set("kubefirst-checks.state-store-create", true) viper.WriteConfig() telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricStateStoreCreateCompleted, "") @@ -1294,7 +1298,7 @@ func createCivo(cmd *cobra.Command, args []string) error { consoleDeployment, err := k8s.ReturnDeploymentObject( kcfg.Clientset, "app.kubernetes.io/instance", - "kubefirst-console", + "kubefirst", "kubefirst", 1200, ) @@ -1324,20 +1328,11 @@ func createCivo(cmd *cobra.Command, args []string) error { consoleStopChannel, ) - log.Info().Msg("kubefirst installation complete") - log.Info().Msg("welcome to your new kubefirst platform powered by Civo cloud") - time.Sleep(time.Second * 1) // allows progress bars to finish - err = pkg.IsConsoleUIAvailable(pkg.KubefirstConsoleLocalURLCloud) if err != nil { log.Error().Err(err).Msg("") } - err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLCloud) - if err != nil { - log.Error().Err(err).Msg("") - } - // Mark cluster install as complete telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallCompleted, "") viper.Set("kubefirst-checks.cluster-install-complete", true) @@ -1346,8 +1341,51 @@ func createCivo(cmd *cobra.Command, args []string) error { // Set flags used to track status of active options helpers.SetClusterStatusFlags(civo.CloudProvider, config.GitProvider) - if !ciFlag { - reports.CivoHandoffScreen(viper.GetString("components.argocd.password"), clusterNameFlag, domainNameFlag, cGitOwner, config, false) + //Export and Import Cluster + cl := utilities.CreateClusterRecordFromRaw(useTelemetryFlag, cGitOwner, cGitUser, cGitToken, cGitlabOwnerGroupID, gitopsTemplateURLFlag, gitopsTemplateBranchFlag) + + var localFilePath = fmt.Sprintf("%s/%s.json", "/tmp/api/cluster/export", clusterNameFlag) + var remoteFilePath = fmt.Sprintf("%s.json", clusterNameFlag) + utilities.CreateClusterRecordFile(clusterNameFlag, cl) + + pushObject := runtimetypes.PushBucketObject{ + LocalFilePath: localFilePath, + RemoteFilePath: remoteFilePath, + ContentType: "application/json", + } + + err = utils.PutClusterObject(&cl.StateStoreCredentials, &cl.StateStoreDetails, &pushObject) + if err != nil { + log.Error().Err(err).Msgf("error pushing cluster object, %s", cl.StateStoreDetails.Hostname) + return err + } + + kubernetesConfig := runtimetypes.KubernetesClient{ + Clientset: kcfg.Clientset, + KubeConfigPath: kcfg.KubeConfigPath, + RestConfig: kcfg.RestConfig, + } + + err = utils.ExportCluster(kubernetesConfig, cl) + if err != nil { + log.Error().Err(err).Msg("error exporting cluster object") + viper.Set("kubefirst.setup-complete", false) + viper.Set("kubefirst-checks.cluster-install-complete", false) + viper.WriteConfig() + return err + } else { + err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLCloud) + if err != nil { + log.Error().Err(err).Msg("") + } + + log.Info().Msg("kubefirst installation complete") + log.Info().Msg("welcome to your new kubefirst platform running in K3d") + time.Sleep(time.Second * 1) // allows progress bars to finish + + if !ciFlag { + reports.CivoHandoffScreen(viper.GetString("components.argocd.password"), clusterNameFlag, domainNameFlag, cGitOwner, config, false) + } } defer func(c segment.SegmentClient) { @@ -1358,4 +1396,5 @@ func createCivo(cmd *cobra.Command, args []string) error { }(*segmentClient) return nil + } diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 778147114..8cf92430e 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -43,6 +43,8 @@ import ( "github.com/kubefirst/runtime/pkg/services" internalssh "github.com/kubefirst/runtime/pkg/ssh" "github.com/kubefirst/runtime/pkg/terraform" + runtimetypes "github.com/kubefirst/runtime/pkg/types" + utils "github.com/kubefirst/runtime/pkg/utils" "github.com/kubefirst/runtime/pkg/wrappers" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" @@ -1136,6 +1138,11 @@ func runK3d(cmd *cobra.Command, args []string) error { bucketName := "kubefirst-state-store" log.Info().Msgf("BucketName: %s", bucketName) + viper.Set("kubefirst.state-store.name", bucketName) + viper.Set("kubefirst.state-store.hostname", "minio-console.kubefirst.dev") + viper.Set("kubefirst.state-store-creds.access-key-id", pkg.MinioDefaultUsername) + viper.Set("kubefirst.state-store-creds.secret-access-key-id", pkg.MinioDefaultPassword) + // Upload the zip file with FPutObject info, err := minioClient.FPutObject(ctx, bucketName, objectName, filePath, minio.PutObjectOptions{ContentType: contentType}) if err != nil { @@ -1327,7 +1334,7 @@ func runK3d(cmd *cobra.Command, args []string) error { consoleDeployment, err := k8s.ReturnDeploymentObject( kcfg.Clientset, "app.kubernetes.io/instance", - "kubefirst-console", + "kubefirst", "kubefirst", 600, ) @@ -1341,7 +1348,7 @@ func runK3d(cmd *cobra.Command, args []string) error { return err } - //* console port-forward + // * console port-forward consoleStopChannel := make(chan struct{}, 1) defer func() { close(consoleStopChannel) @@ -1358,15 +1365,6 @@ func runK3d(cmd *cobra.Command, args []string) error { progressPrinter.IncrementTracker("wrapping-up", 1) - log.Info().Msg("kubefirst installation complete") - log.Info().Msg("welcome to your new kubefirst platform running in K3d") - time.Sleep(time.Second * 1) // allows progress bars to finish - - err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLTLS) - if err != nil { - log.Error().Err(err).Msg("") - } - // Mark cluster install as complete telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallCompleted, "") viper.Set("kubefirst-checks.cluster-install-complete", true) @@ -1375,8 +1373,44 @@ func runK3d(cmd *cobra.Command, args []string) error { // Set flags used to track status of active options helpers.SetClusterStatusFlags(k3d.CloudProvider, config.GitProvider) - if !ciFlag { - reports.LocalHandoffScreenV2(viper.GetString("components.argocd.password"), clusterNameFlag, gitDestDescriptor, cGitOwner, config, false) + //Export and Import Cluster + cl := utilities.CreateClusterRecordFromRaw(useTelemetryFlag, cGitOwner, cGitUser, cGitToken, cGitlabOwnerGroupID, gitopsTemplateURLFlag, gitopsTemplateBranchFlag) + + var localFilePath = fmt.Sprintf("%s/%s.json", "/tmp/api/cluster/export", clusterNameFlag) + utilities.CreateClusterRecordFile(clusterNameFlag, cl) + + // Upload the zip file with FPutObject + info, err = minioClient.FPutObject(ctx, bucketName, fmt.Sprintf("%s.json", clusterNameFlag), localFilePath, minio.PutObjectOptions{ContentType: "application/json"}) + if err != nil { + log.Info().Msgf("Error uploading to Minio bucket: %s", err) + } + + kubernetesConfig := runtimetypes.KubernetesClient{ + Clientset: kcfg.Clientset, + KubeConfigPath: kcfg.KubeConfigPath, + RestConfig: kcfg.RestConfig, + } + + err = utils.ExportCluster(kubernetesConfig, cl) + if err != nil { + log.Error().Err(err).Msg("error exporting cluster object") + viper.Set("kubefirst.setup-complete", false) + viper.Set("kubefirst-checks.cluster-install-complete", false) + viper.WriteConfig() + return err + } else { + err = pkg.OpenBrowser(pkg.KubefirstConsoleLocalURLCloud) + if err != nil { + log.Error().Err(err).Msg("") + } + + log.Info().Msg("kubefirst installation complete") + log.Info().Msg("welcome to your new kubefirst platform running in K3d") + time.Sleep(time.Second * 1) // allows progress bars to finish + + if !ciFlag { + reports.LocalHandoffScreenV2(viper.GetString("components.argocd.password"), clusterNameFlag, gitDestDescriptor, cGitOwner, config, false) + } } defer func(c segment.SegmentClient) { diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 4e67bf9d0..5ce933dce 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -742,6 +742,11 @@ func createVultr(cmd *cobra.Command, args []string) error { tfEntrypoint := config.GitopsDir + "/terraform/github" tfEnvs := map[string]string{} tfEnvs = vultr.GetGithubTerraformEnvs(config, tfEnvs) + // Erase public key to prevent it from being created if the git protocol argument is set to htps + switch config.GitProtocol { + case "https": + tfEnvs["TF_VAR_kbot_ssh_public_key"] = "" + } err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { msg := fmt.Sprintf("error creating github resources with terraform %s: %s", tfEntrypoint, err) diff --git a/go.mod b/go.mod index 59bd9c5dd..2368f8b8f 100644 --- a/go.mod +++ b/go.mod @@ -14,11 +14,12 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/go-git/go-git/v5 v5.6.1 github.com/hashicorp/vault/api v1.9.0 - github.com/kubefirst/runtime v0.3.9 + github.com/kubefirst/runtime v0.3.12 github.com/rs/zerolog v1.29.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.15.0 + go.mongodb.org/mongo-driver v1.10.0 k8s.io/api v0.26.2 k8s.io/apimachinery v0.27.1 k8s.io/client-go v11.0.1-0.20190816222228-6d55c1b1f1ca+incompatible @@ -107,7 +108,6 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/gnostic v0.6.9 // indirect - github.com/google/go-github v17.0.0+incompatible // indirect github.com/google/go-github/v45 v45.2.0 // indirect github.com/google/s2a-go v0.1.4 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect @@ -115,7 +115,6 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect - github.com/hashicorp/go-version v1.2.1 // indirect github.com/jedib0t/go-pretty/v6 v6.4.6 // indirect github.com/jonboulle/clockwork v0.2.2 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -166,7 +165,6 @@ require ( github.com/xlab/treeprint v1.1.0 // indirect github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect - go.mongodb.org/mongo-driver v1.10.0 // indirect go.opencensus.io v0.24.0 // indirect go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect golang.org/x/crypto v0.11.0 // indirect diff --git a/go.sum b/go.sum index a7d4275ed..db9ae3c5d 100644 --- a/go.sum +++ b/go.sum @@ -531,8 +531,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= -github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github/v45 v45.2.0 h1:5oRLszbrkvxDDqBCNj2hjDZMKmvexaZ1xw/FCD+K3FI= github.com/google/go-github/v45 v45.2.0/go.mod h1:FObaZJEDSTa/WGCzZ2Z3eoCDXWJKMenWWTrd8jrta28= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -629,8 +627,6 @@ github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdv github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= -github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -721,8 +717,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/runtime v0.3.9 h1:Wl+gxradufEEyUAIDbQxp+4bLrnMxmQS+X6SlSJLQWw= -github.com/kubefirst/runtime v0.3.9/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= +github.com/kubefirst/runtime v0.3.12 h1:C1k81WNQt59teLN6/CgQgaITz/Js2flOTkcyF8pYB1Y= +github.com/kubefirst/runtime v0.3.12/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 9b90d5c3f..26e7dd744 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.10" + helmChartVersion = "2.2.11" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) diff --git a/internal/utilities/utilities.go b/internal/utilities/utilities.go index 02f11ce66..35010447c 100644 --- a/internal/utilities/utilities.go +++ b/internal/utilities/utilities.go @@ -7,10 +7,15 @@ See the LICENSE file for more details. package utilities import ( + "encoding/json" "fmt" "os" + "time" + "github.com/kubefirst/runtime/pkg/types" "github.com/rs/zerolog/log" + "github.com/spf13/viper" + "go.mongodb.org/mongo-driver/bson/primitive" ) // CreateK1ClusterDirectory @@ -28,3 +33,108 @@ func CreateK1ClusterDirectory(clusterName string) { } } } + +const ( + exportFilePath = "/tmp/api/cluster/export" +) + +func CreateClusterRecordFromRaw(useTelemetry bool, gitOwner string, gitUser string, gitToken string, gitlabOwnerGroupID int, gitopsTemplateURL string, gitopsTemplateBranch string) types.Cluster { + // viper.Set("flags.dns-provider", dnsProviderFlag) + // viper.Set("flags.git-protocol", gitProtocolFlag) + + cloudProvider := viper.GetString("kubefirst.cloud-provider") + domainName := viper.GetString("flags.domain-name") + gitProvider := viper.GetString("flags.git-provider") + + kubefirstTeam := os.Getenv("KUBEFIRST_TEAM") + if kubefirstTeam == "" { + kubefirstTeam = "false" + } + + cl := types.Cluster{ + ID: primitive.NewObjectID(), + CreationTimestamp: fmt.Sprintf("%v", time.Now().UTC()), + UseTelemetry: useTelemetry, + Status: "provisioned", + AlertsEmail: viper.GetString("flags.alerts-email"), + ClusterName: viper.GetString("flags.cluster-name"), + CloudProvider: cloudProvider, + CloudRegion: viper.GetString("flags.cloud-region"), + DomainName: domainName, + ClusterID: viper.GetString("kubefirst.cluster-id"), + ClusterType: "mgmt", + GitopsTemplateURL: gitopsTemplateURL, + GitopsTemplateBranch: gitopsTemplateBranch, + GitProvider: gitProvider, + GitHost: fmt.Sprintf("%s.com", gitProvider), + GitProtocol: viper.GetString("flags.git-protocol"), + DnsProvider: viper.GetString("flags.dns-provider"), + GitlabOwnerGroupID: gitlabOwnerGroupID, + AtlantisWebhookSecret: viper.GetString("secrets.atlantis-webhook"), + AtlantisWebhookURL: fmt.Sprintf("https://atlantis.%s/events", domainName), + KubefirstTeam: kubefirstTeam, + ArgoCDAuthToken: viper.GetString("components.argocd.auth-token"), + ArgoCDPassword: viper.GetString("components.argocd.password"), + GitAuth: types.GitAuth{ + Token: gitToken, + User: gitUser, + Owner: gitOwner, + PublicKey: viper.GetString("kbot.public-key"), + PrivateKey: viper.GetString("kbot.private-key"), + }, + CloudflareAuth: types.CloudflareAuth{ + Token: os.Getenv("CF_API_TOKEN"), + }, + } + + switch cloudProvider { + case "civo": + cl.CivoAuth.Token = os.Getenv("CIVO_TOKEN") + case "aws": + //ToDo: where to get credentials? + cl.AWSAuth.AccessKeyID = viper.GetString("kubefirst.state-store-creds.access-key-id") + cl.AWSAuth.SecretAccessKey = viper.GetString("kubefirst.state-store-creds.secret-access-key-id") + cl.AWSAuth.SessionToken = viper.GetString("kubefirst.state-store-creds.token") + case "digitalocean": + cl.DigitaloceanAuth.Token = os.Getenv("DO_TOKEN") + cl.DigitaloceanAuth.SpacesKey = os.Getenv("DO_SPACES_KEY") + cl.DigitaloceanAuth.SpacesSecret = os.Getenv("DO_SPACES_SECRET") + case "vultr": + cl.VultrAuth.Token = os.Getenv("VULTR_API_KEY") + } + + cl.StateStoreCredentials.AccessKeyID = viper.GetString("kubefirst.state-store-creds.access-key-id") + cl.StateStoreCredentials.SecretAccessKey = viper.GetString("kubefirst.state-store-creds.secret-access-key-id") + cl.StateStoreCredentials.SessionToken = viper.GetString("kubefirst.state-store-creds.token") + cl.StateStoreCredentials.Name = viper.GetString("kubefirst.state-store-creds.name") + cl.StateStoreCredentials.ID = viper.GetString("kubefirst.state-store-creds.id") + + cl.StateStoreDetails.ID = viper.GetString("kubefirst.state-store.id") + cl.StateStoreDetails.Name = viper.GetString("kubefirst.state-store.name") + cl.StateStoreDetails.Hostname = viper.GetString("kubefirst.state-store.hostname") + cl.StateStoreDetails.AWSArtifactsBucket = viper.GetString("kubefirst.artifacts-bucket") + cl.StateStoreDetails.AWSStateStoreBucket = viper.GetString("kubefirst.state-store-bucket") + + return cl +} + +func CreateClusterRecordFile(clustername string, cluster types.Cluster) error { + var localFilePath = fmt.Sprintf("%s/%s.json", exportFilePath, clustername) + + log.Info().Msgf("creating export file %s", localFilePath) + + if _, err := os.Stat(exportFilePath); os.IsNotExist(err) { + log.Info().Msgf("cluster exports directory does not exist, creating") + err := os.MkdirAll(exportFilePath, 0777) + if err != nil { + return err + } + } + + file, _ := json.MarshalIndent(cluster, "", " ") + _ = os.WriteFile(localFilePath, file, 0644) + + log.Info().Msgf("file created %s", localFilePath) + + return nil +} From d2ce9c038384bc06fe0bf96b215547c57e0fc894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Fri, 25 Aug 2023 16:01:30 -0500 Subject: [PATCH 22/45] chore: update helm chart version (#1769) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 26e7dd744..aa271ef39 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.11" + helmChartVersion = "2.2.12" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From abacbbb4f110ad30b352ec7133ecc9b339aaf207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Fri, 25 Aug 2023 18:06:41 -0500 Subject: [PATCH 23/45] chore: update helm chart version (#1771) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index aa271ef39..15e2ecef1 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.12" + helmChartVersion = "2.2.13" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From 8c52248b09d415e5aa48ca7bb1af01ab1c1b7625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Mon, 28 Aug 2023 17:26:55 -0500 Subject: [PATCH 24/45] chore: update helm chart version 2.2.15 (#1775) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index 15e2ecef1..d80e33509 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.13" + helmChartVersion = "2.2.15" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From 23fb5bcf43ef9c7f62bfb6476b1d064cb0917660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Fern=C3=A1ndez?= Date: Mon, 28 Aug 2023 19:02:35 -0500 Subject: [PATCH 25/45] chore: update helm chart version 2.2.16 (#1780) --- internal/launch/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/launch/constants.go b/internal/launch/constants.go index d80e33509..92a1dce7d 100644 --- a/internal/launch/constants.go +++ b/internal/launch/constants.go @@ -11,7 +11,7 @@ const ( helmChartName = "kubefirst" helmChartRepoName = "kubefirst" helmChartRepoURL = "https://charts.kubefirst.com" - helmChartVersion = "2.2.15" + helmChartVersion = "2.2.16" namespace = "kubefirst" secretName = "kubefirst-initial-secrets" ) From 6cfe801121d4834530fd5385f604c42832866825 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 17:34:51 -0500 Subject: [PATCH 26/45] chore: update calls to secretbootstrapping --- cmd/aws/create.go | 2 ++ cmd/civo/create.go | 2 ++ cmd/digitalocean/create.go | 2 ++ cmd/gcp/create.go | 5 +++++ cmd/vultr/create.go | 2 ++ 5 files changed, 13 insertions(+) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 207f567fa..2c3707e5c 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -1146,6 +1146,8 @@ func createAws(cmd *cobra.Command, args []string) error { clientset, ecrFlag, containerRegistryURL, + dnsProviderFlag, + gitopsDirectoryTokens.CloudProvider, ) if err != nil { log.Info().Msg("Error adding kubernetes secrets for bootstrap") diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 9b38298c2..50fd5759d 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -963,6 +963,8 @@ func createCivo(cmd *cobra.Command, args []string) error { os.Getenv("CF_API_TOKEN"), gitopsRepoURL, config.GitProtocol, + dnsProviderFlag, + gitopsDirectoryTokens.CloudProvider, ) if err != nil { log.Info().Msg("Error adding kubernetes secrets for bootstrap") diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index cb705a32d..ef93fd80e 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -953,6 +953,8 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { os.Getenv("CF_API_TOKEN"), gitopsRepoURL, config.GitProtocol, + dnsProviderFlag, + gitopsDirectoryTokens.CloudProvider, ) if err != nil { log.Info().Msg("Error adding kubernetes secrets for bootstrap") diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index f8b312693..b2d2892d6 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -46,6 +46,7 @@ import ( "github.com/kubefirst/runtime/pkg/vault" "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/thanhpk/randstr" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" _ "k8s.io/client-go/plugin/pkg/client/auth" @@ -684,6 +685,7 @@ func createGCP(cmd *cobra.Command, args []string) error { gitopsDirectoryTokens.ExternalDNSProviderTokenEnvName = externalDNSProviderTokenEnvName gitopsDirectoryTokens.ExternalDNSProviderSecretName = fmt.Sprintf("%s-creds", gcp.CloudProvider) gitopsDirectoryTokens.ExternalDNSProviderSecretKey = externalDNSProviderSecretKey + gitopsDirectoryTokens.GoogleUniqueness = randstr.String(16) // Determine if anything exists at domain apex apexContentExists := gcp.GetDomainApexContent(domainNameFlag) @@ -872,6 +874,7 @@ func createGCP(cmd *cobra.Command, args []string) error { tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs["TF_VAR_project"] = gcpProjectFlag tfEnvs["TF_VAR_force_destroy"] = strconv.FormatBool(forceDestroy) + tfEnvs["TF_VAR_uniqueness"] = gitopsDirectoryTokens.GoogleUniqueness tfEntrypoint := config.GitopsDir + "/terraform/gcp/services" err = terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { @@ -943,6 +946,8 @@ func createGCP(cmd *cobra.Command, args []string) error { config.GitProtocol, os.Getenv("CF_API_TOKEN"), config.GCPAuth, + dnsProviderFlag, + gitopsDirectoryTokens.CloudProvider, ) if err != nil { diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 5ce933dce..79b23ad96 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -952,6 +952,8 @@ func createVultr(cmd *cobra.Command, args []string) error { os.Getenv("CF_API_TOKEN"), gitopsRepoURL, config.GitProtocol, + dnsProviderFlag, + gitopsDirectoryTokens.CloudProvider, ) if err != nil { log.Info().Msg("Error adding kubernetes secrets for bootstrap") From 487ed0ce231a3c92c1be55c3f175907cbb8e6267 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 18:14:40 -0500 Subject: [PATCH 27/45] fix: use autotvars file and detokenize it --- cmd/gcp/create.go | 9 ++++----- cmd/gcp/destroy.go | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index b2d2892d6..6fbeb0dbb 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -332,8 +332,10 @@ func createGCP(cmd *cobra.Command, args []string) error { KubefirstTeam: kubefirstTeam, KubefirstVersion: configs.K1Version, - GCPAuth: config.GCPAuth, - GCPProject: gcpProjectFlag, + GCPAuth: config.GCPAuth, + GCPProject: gcpProjectFlag, + GoogleUniqueness: randstr.String(5), + ForceDestroy: strconv.FormatBool(forceDestroy), ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), ArgoCDIngressNoHTTPSURL: fmt.Sprintf("argocd.%s", domainNameFlag), @@ -685,7 +687,6 @@ func createGCP(cmd *cobra.Command, args []string) error { gitopsDirectoryTokens.ExternalDNSProviderTokenEnvName = externalDNSProviderTokenEnvName gitopsDirectoryTokens.ExternalDNSProviderSecretName = fmt.Sprintf("%s-creds", gcp.CloudProvider) gitopsDirectoryTokens.ExternalDNSProviderSecretKey = externalDNSProviderSecretKey - gitopsDirectoryTokens.GoogleUniqueness = randstr.String(16) // Determine if anything exists at domain apex apexContentExists := gcp.GetDomainApexContent(domainNameFlag) @@ -873,8 +874,6 @@ func createGCP(cmd *cobra.Command, args []string) error { a, _ := os.ReadFile(config.GCPAuth) tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs["TF_VAR_project"] = gcpProjectFlag - tfEnvs["TF_VAR_force_destroy"] = strconv.FormatBool(forceDestroy) - tfEnvs["TF_VAR_uniqueness"] = gitopsDirectoryTokens.GoogleUniqueness tfEntrypoint := config.GitopsDir + "/terraform/gcp/services" err = terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/gcp/destroy.go b/cmd/gcp/destroy.go index 68ef24b9d..2a2f40539 100644 --- a/cmd/gcp/destroy.go +++ b/cmd/gcp/destroy.go @@ -32,7 +32,6 @@ func destroyGCP(cmd *cobra.Command, args []string) error { // Determine if there are active installs gitProvider := viper.GetString("flags.git-provider") gitProtocol := viper.GetString("flags.git-protocol") - forceDestroy := viper.GetBool("flags.force_destroy") // _, err := helpers.EvalDestroy(gcp.CloudProvider, gitProvider) // if err != nil { // return err @@ -168,7 +167,6 @@ func destroyGCP(cmd *cobra.Command, args []string) error { tfEnvs["GITLAB_TOKEN"] = cGitToken tfEnvs["GOOGLE_CLOUD_KEYFILE_JSON"] = string(a) tfEnvs["TF_VAR_project"] = gcpProject - tfEnvs["TF_VAR_force_destroy"] = strconv.FormatBool(forceDestroy) err = terraform.InitDestroyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { log.Printf("error executing terraform destroy %s", tfEntrypoint) From c8af2c87a00b52562891306acb5d0fba638dab3f Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 22:07:05 -0500 Subject: [PATCH 28/45] fix: external auth/creds references --- cmd/aws/create.go | 2 +- cmd/civo/create.go | 2 +- cmd/digitalocean/create.go | 2 +- cmd/gcp/create.go | 31 ++++++++++++++++--------------- cmd/k3d/create.go | 2 ++ cmd/vultr/create.go | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 2c3707e5c..730175235 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -642,7 +642,7 @@ func createAws(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-creds", awsinternal.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", awsinternal.CloudProvider), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 50fd5759d..c48b09a76 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -346,7 +346,7 @@ func createCivo(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-creds", civo.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", civo.CloudProvider), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index ef93fd80e..5066aeebc 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -344,7 +344,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-creds", digitalocean.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", digitalocean.CloudProvider), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 6fbeb0dbb..747fe8032 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -308,6 +308,15 @@ func createGCP(cmd *cobra.Command, args []string) error { kubefirstTeam = "false" } + var externalDNSProviderTokenEnvName, externalDNSProviderSecretKey string + if dnsProviderFlag == "cloudflare" { + externalDNSProviderTokenEnvName = "CF_API_TOKEN" + externalDNSProviderSecretKey = "cf-api-token" + } else { + externalDNSProviderTokenEnvName = "GCP_AUTH" + externalDNSProviderSecretKey = fmt.Sprintf("google_application_credentials") + } + // Swap tokens for git protocol var gitopsRepoURL string switch config.GitProtocol { @@ -349,6 +358,11 @@ func createGCP(cmd *cobra.Command, args []string) error { VaultDataBucketName: fmt.Sprintf("%s-vault-data-%s", gcpProjectFlag, clusterNameFlag), VouchIngressURL: fmt.Sprintf("https://vouch.%s", domainNameFlag), + ExternalDNSProviderName: dnsProviderFlag, + ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", gcp.CloudProvider), + ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, + GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), GitNamespace: "N/A", GitProvider: config.GitProvider, @@ -606,7 +620,8 @@ func createGCP(cmd *cobra.Command, args []string) error { } log.Info().Msg("validation and kubefirst cli environment check is complete") - + progressPrinter.IncrementTracker("preflight-checks", 1) + progressPrinter.IncrementTracker("preflight-checks", 1) telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricInitCompleted, "") telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallStarted, "") @@ -674,20 +689,6 @@ func createGCP(cmd *cobra.Command, args []string) error { viper.Set(fmt.Sprintf("%s.repos.gitops.git-url", config.GitProvider), config.DestinationGitopsRepoURL) viper.WriteConfig() - var externalDNSProviderTokenEnvName, externalDNSProviderSecretKey string - if dnsProviderFlag == "cloudflare" { - externalDNSProviderTokenEnvName = "CF_API_TOKEN" - externalDNSProviderSecretKey = "cf-api-token" - } else { - externalDNSProviderTokenEnvName = "GCP_AUTH" - externalDNSProviderSecretKey = fmt.Sprintf("google_application_credentials") - } - - gitopsDirectoryTokens.ExternalDNSProviderName = dnsProviderFlag - gitopsDirectoryTokens.ExternalDNSProviderTokenEnvName = externalDNSProviderTokenEnvName - gitopsDirectoryTokens.ExternalDNSProviderSecretName = fmt.Sprintf("%s-creds", gcp.CloudProvider) - gitopsDirectoryTokens.ExternalDNSProviderSecretKey = externalDNSProviderSecretKey - // Determine if anything exists at domain apex apexContentExists := gcp.GetDomainApexContent(domainNameFlag) diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 8cf92430e..19afe62ba 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -559,6 +559,8 @@ func runK3d(cmd *cobra.Command, args []string) error { //* git clone and detokenize the gitops repository // todo improve this logic for removing `kubefirst clean` // if !viper.GetBool("template-repo.gitops.cloned") || viper.GetBool("template-repo.gitops.removed") { + progressPrinter.IncrementTracker("preflight-checks", 1) + progressPrinter.IncrementTracker("preflight-checks", 1) progressPrinter.AddTracker("cloning-and-formatting-git-repositories", "Cloning and formatting git repositories", 1) progressPrinter.SetupProgress(progressPrinter.TotalOfTrackers(), false) if !viper.GetBool("kubefirst-checks.gitops-ready-to-push") { diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 79b23ad96..4323bd4f6 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -343,7 +343,7 @@ func createVultr(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-creds", vultr.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", vultr.CloudProvider), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), From 17292a8d961ec5d02298c778ec5cb96ba2564bdd Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Tue, 22 Aug 2023 22:58:00 -0500 Subject: [PATCH 29/45] fix: gcp/google reference for external-dns --- cmd/gcp/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 747fe8032..0852e631d 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -360,7 +360,7 @@ func createGCP(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", gcp.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("google-auth"), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), From 3e567656a62ea6295ce24e79121bfd3b2123abb0 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 23 Aug 2023 00:00:04 -0500 Subject: [PATCH 30/45] fix: change the useless google secret key --- cmd/gcp/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 0852e631d..1fbfb98db 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -314,7 +314,7 @@ func createGCP(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = "cf-api-token" } else { externalDNSProviderTokenEnvName = "GCP_AUTH" - externalDNSProviderSecretKey = fmt.Sprintf("google_application_credentials") + externalDNSProviderSecretKey = fmt.Sprintf("google-auth") } // Swap tokens for git protocol From c2a58337079ab20f29400a3ad54550ce5acd5d99 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 23 Aug 2023 19:52:57 -0500 Subject: [PATCH 31/45] fix: lower the uniqueness --- cmd/gcp/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 1fbfb98db..9ce15ff55 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -343,7 +343,7 @@ func createGCP(cmd *cobra.Command, args []string) error { GCPAuth: config.GCPAuth, GCPProject: gcpProjectFlag, - GoogleUniqueness: randstr.String(5), + GoogleUniqueness: strings.ToLower(randstr.String(5)), ForceDestroy: strconv.FormatBool(forceDestroy), ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), From 26c42aa9f59766bb9dd633fb502863479e9f396c Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 23 Aug 2023 20:26:27 -0500 Subject: [PATCH 32/45] fix: auth references --- cmd/aws/create.go | 6 +++--- cmd/civo/create.go | 2 +- cmd/digitalocean/create.go | 2 +- cmd/vultr/create.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 730175235..f0dd50fe4 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -609,8 +609,8 @@ func createAws(cmd *cobra.Command, args []string) error { externalDNSProviderTokenEnvName = "CF_API_TOKEN" externalDNSProviderSecretKey = "cf-api-token" } else { - externalDNSProviderTokenEnvName = "CIVO_TOKEN" - externalDNSProviderSecretKey = fmt.Sprintf("%s-token", awsinternal.CloudProvider) + externalDNSProviderTokenEnvName = "AWS_AUTH" + externalDNSProviderSecretKey = fmt.Sprintf("%s-auth", awsinternal.CloudProvider) } // Swap tokens for git protocol @@ -628,7 +628,7 @@ func createAws(cmd *cobra.Command, args []string) error { AwsIamArnAccountRoot: fmt.Sprintf("arn:aws:iam::%s:root", *iamCaller.Account), AwsNodeCapacityType: "ON_DEMAND", // todo adopt cli flag AwsAccountID: *iamCaller.Account, - CloudProvider: awsinternal.CloudProvider, + CloudProvider: awsinterEXTERNAL_DNS_PROVIDER_SECRET_NAMEnal.CloudProvider, CloudRegion: cloudRegionFlag, ClusterName: clusterNameFlag, ClusterType: clusterTypeFlag, diff --git a/cmd/civo/create.go b/cmd/civo/create.go index c48b09a76..96f376c91 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -318,7 +318,7 @@ func createCivo(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = "cf-api-token" } else { externalDNSProviderTokenEnvName = "CIVO_TOKEN" - externalDNSProviderSecretKey = fmt.Sprintf("%s-token", civo.CloudProvider) + externalDNSProviderSecretKey = fmt.Sprintf("%s-auth", civo.CloudProvider) } // Swap tokens for git protocol; used by tokens, argocd registry object, and secret bootstrapping for argo template credentials diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index 5066aeebc..e51cfc8a7 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -316,7 +316,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = "cf-api-token" } else { externalDNSProviderTokenEnvName = "DO_TOKEN" - externalDNSProviderSecretKey = fmt.Sprintf("%s-token", digitalocean.CloudProvider) + externalDNSProviderSecretKey = fmt.Sprintf("%s-auth", digitalocean.CloudProvider) } // Swap tokens for git protocol diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 4323bd4f6..e429bed02 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -315,7 +315,7 @@ func createVultr(cmd *cobra.Command, args []string) error { externalDNSProviderSecretKey = "cf-api-token" } else { externalDNSProviderTokenEnvName = "VULTR_API_KEY" - externalDNSProviderSecretKey = fmt.Sprintf("%s-token", vultr.CloudProvider) + externalDNSProviderSecretKey = fmt.Sprintf("%s-auth", vultr.CloudProvider) } // Swap tokens for git protocol From 6e2926f9a06e15d6b5fb6d29d6150b689fad6805 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Fri, 25 Aug 2023 11:44:51 -0500 Subject: [PATCH 33/45] fix: typo --- cmd/aws/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index f0dd50fe4..c5e95678d 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -628,7 +628,7 @@ func createAws(cmd *cobra.Command, args []string) error { AwsIamArnAccountRoot: fmt.Sprintf("arn:aws:iam::%s:root", *iamCaller.Account), AwsNodeCapacityType: "ON_DEMAND", // todo adopt cli flag AwsAccountID: *iamCaller.Account, - CloudProvider: awsinterEXTERNAL_DNS_PROVIDER_SECRET_NAMEnal.CloudProvider, + CloudProvider: awsinternal.CloudProvider, CloudRegion: cloudRegionFlag, ClusterName: clusterNameFlag, ClusterType: clusterTypeFlag, From cf928d53cc9d00de6b55a30efbc15d66bb9a0f8c Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Fri, 25 Aug 2023 11:45:05 -0500 Subject: [PATCH 34/45] fix: swap underscore for hyphen --- cmd/gcp/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gcp/command.go b/cmd/gcp/command.go index 8cb470acc..8710d6589 100644 --- a/cmd/gcp/command.go +++ b/cmd/gcp/command.go @@ -87,7 +87,7 @@ func Create() *cobra.Command { createCmd.Flags().StringVar(&gitopsTemplateBranchFlag, "gitops-template-branch", "", "the branch to clone for the gitops-template repository") createCmd.Flags().StringVar(&gitopsTemplateURLFlag, "gitops-template-url", "https://github.com/kubefirst/gitops-template.git", "the fully qualified url to the gitops-template repository to clone") createCmd.Flags().BoolVar(&useTelemetryFlag, "use-telemetry", true, "whether to emit telemetry") - createCmd.Flags().BoolVar(&forceDestroyFlag, "force_destroy", false, "allows force destruction on objects (helpful for test environments, defaults to false)") + createCmd.Flags().BoolVar(&forceDestroyFlag, "force-destroy", false, "allows force destruction on objects (helpful for test environments, defaults to false)") return createCmd } From 7837edd10753c9713fe62b0a910809f313d18af3 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Fri, 25 Aug 2023 12:11:36 -0500 Subject: [PATCH 35/45] fix: dns provider options and detokenization --- cmd/gcp/command.go | 2 +- cmd/gcp/create.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/gcp/command.go b/cmd/gcp/command.go index 8710d6589..e6455c7eb 100644 --- a/cmd/gcp/command.go +++ b/cmd/gcp/command.go @@ -37,7 +37,7 @@ var ( copyVaultPasswordToClipboardFlag bool // Supported providers - supportedDNSProviders = []string{"gcp", "cloudflare"} + supportedDNSProviders = []string{"google", "cloudflare"} supportedGitProviders = []string{"github", "gitlab"} // Supported git providers diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 9ce15ff55..984c4da98 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -313,8 +313,8 @@ func createGCP(cmd *cobra.Command, args []string) error { externalDNSProviderTokenEnvName = "CF_API_TOKEN" externalDNSProviderSecretKey = "cf-api-token" } else { - externalDNSProviderTokenEnvName = "GCP_AUTH" - externalDNSProviderSecretKey = fmt.Sprintf("google-auth") + externalDNSProviderTokenEnvName = "GOOGLE_AUTH" + externalDNSProviderSecretKey = fmt.Sprintf("%s-auth", dnsProviderFlag) } // Swap tokens for git protocol @@ -360,7 +360,7 @@ func createGCP(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("google-auth"), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", dnsProviderFlag), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, GitDescription: fmt.Sprintf("%s hosted git", config.GitProvider), From d0c9121ac76f5b5ff08c13b74609313f21a499b5 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Mon, 28 Aug 2023 15:06:45 -0400 Subject: [PATCH 36/45] fix: `ContainerRegistryURL` to template `` in association with `-p containerRegistryURL` usage (#1774) --- cmd/gcp/create.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 984c4da98..82b0015bf 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -88,7 +88,7 @@ func createGCP(cmd *cobra.Command, args []string) error { return err } - forceDestroy, err := cmd.Flags().GetBool("force_destroy") + forceDestroy, err := cmd.Flags().GetBool("force-destroy") if err != nil { return err } @@ -386,7 +386,7 @@ func createGCP(cmd *cobra.Command, args []string) error { GitopsRepoNoHTTPSURL: fmt.Sprintf("%s.com/%s/gitops.git", cGitHost, cGitOwner), ClusterId: clusterId, - ContainerRegistryURL: fmt.Sprintf("%s/%s/metaphor", containerRegistryHost, cGitOwner), + ContainerRegistryURL: fmt.Sprintf("%s/%s", containerRegistryHost, cGitOwner), } viper.Set(fmt.Sprintf("%s.atlantis.webhook.url", config.GitProvider), fmt.Sprintf("https://atlantis.%s/events", domainNameFlag)) @@ -668,7 +668,7 @@ func createGCP(cmd *cobra.Command, args []string) error { metaphorDirectoryTokens := providerConfigs.MetaphorTokenValues{ ClusterName: clusterNameFlag, CloudRegion: cloudRegionFlag, - ContainerRegistryURL: fmt.Sprintf("%s/%s/metaphor", containerRegistryHost, cGitOwner), + ContainerRegistryURL: fmt.Sprintf("%s/%s", containerRegistryHost, cGitOwner), DomainName: domainNameFlag, MetaphorDevelopmentIngressURL: fmt.Sprintf("metaphor-development.%s", domainNameFlag), MetaphorStagingIngressURL: fmt.Sprintf("metaphor-staging.%s", domainNameFlag), From 75746b6588f3099a18d6d8b32519d9cb5d45e448 Mon Sep 17 00:00:00 2001 From: Claywd <6446939+Claywd@users.noreply.github.com> Date: Mon, 28 Aug 2023 22:26:25 -0500 Subject: [PATCH 37/45] fix: I forgot the mod and sum --- go.mod | 3 ++- go.sum | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2368f8b8f..589e4a2f8 100644 --- a/go.mod +++ b/go.mod @@ -14,11 +14,12 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/go-git/go-git/v5 v5.6.1 github.com/hashicorp/vault/api v1.9.0 - github.com/kubefirst/runtime v0.3.12 + github.com/kubefirst/runtime v0.3.13 github.com/rs/zerolog v1.29.0 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.15.0 + github.com/thanhpk/randstr v1.0.6 go.mongodb.org/mongo-driver v1.10.0 k8s.io/api v0.26.2 k8s.io/apimachinery v0.27.1 diff --git a/go.sum b/go.sum index db9ae3c5d..ffd4efbd0 100644 --- a/go.sum +++ b/go.sum @@ -717,8 +717,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 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/runtime v0.3.12 h1:C1k81WNQt59teLN6/CgQgaITz/Js2flOTkcyF8pYB1Y= -github.com/kubefirst/runtime v0.3.12/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= +github.com/kubefirst/runtime v0.3.13 h1:Efp1ZKz1QrQsvVm84lQjEOpDReJ07YBqDlNGF65AJA8= +github.com/kubefirst/runtime v0.3.13/go.mod h1:NUa8VcB99UKEwVUvhdCfiuEYQI44XfGFV2pBtX8YnVo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= @@ -1080,6 +1080,8 @@ github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69 github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= +github.com/thanhpk/randstr v1.0.6 h1:psAOktJFD4vV9NEVb3qkhRSMvYh4ORRaj1+w/hn4B+o= +github.com/thanhpk/randstr v1.0.6/go.mod h1:M/H2P1eNLZzlDwAzpkkkUvoyNNMbzRGhESZuEQk3r0U= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= From 8573d2f67c9399c8ea969b11f1eaa8ac3e2f3a49 Mon Sep 17 00:00:00 2001 From: Claywd <6446939+Claywd@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:01:38 -0500 Subject: [PATCH 38/45] fix: capture edge case on gitops repo/ branch flag --- cmd/aws/create.go | 10 +++++++--- cmd/civo/create.go | 10 +++++++--- cmd/digitalocean/create.go | 10 +++++++--- cmd/gcp/create.go | 10 +++++++--- cmd/k3d/create.go | 11 +++++++---- cmd/vultr/create.go | 10 +++++++--- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index c5e95678d..f15788e8f 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -375,12 +375,16 @@ func createAws(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 96f376c91..babdd09ae 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -424,12 +424,16 @@ func createCivo(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index e51cfc8a7..de604a2e2 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -420,12 +420,16 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 82b0015bf..d27bb6cb5 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -428,12 +428,16 @@ func createGCP(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } diff --git a/cmd/k3d/create.go b/cmd/k3d/create.go index 19afe62ba..e548814fc 100644 --- a/cmd/k3d/create.go +++ b/cmd/k3d/create.go @@ -365,12 +365,16 @@ func runK3d(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } @@ -475,7 +479,6 @@ func runK3d(cmd *cobra.Command, args []string) error { telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricInitCompleted, "") telemetryShim.Transmit(useTelemetryFlag, segmentClient, segment.MetricClusterInstallStarted, "") - // Swap tokens for git protocol switch config.GitProtocol { case "https": diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index e429bed02..849c15575 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -419,12 +419,16 @@ func createVultr(cmd *cobra.Command, args []string) error { } default: switch gitopsTemplateURLFlag { - case "https://github.com/kubefirst/gitops-template.git": + case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { gitopsTemplateBranchFlag = configs.K1Version } - default: - if gitopsTemplateBranchFlag != "" { + case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url + if gitopsTemplateBranchFlag == "" { + gitopsTemplateBranchFlag = configs.K1Version + } + default: // not equal to our defaults + if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } } From fff9d4c59a6bbd66c261c1d0597c969a0b135376 Mon Sep 17 00:00:00 2001 From: Claywd <6446939+Claywd@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:21:06 -0500 Subject: [PATCH 39/45] fix: write dnsprovider tokens via vault terraform --- cmd/aws/create.go | 8 ++++++++ cmd/civo/create.go | 9 +++++++++ cmd/digitalocean/create.go | 9 +++++++++ cmd/gcp/create.go | 9 +++++++++ cmd/vultr/create.go | 9 +++++++++ 5 files changed, 44 insertions(+) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index c5e95678d..6d3a6faa8 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -1385,6 +1385,14 @@ func createAws(cmd *cobra.Command, args []string) error { tfEnvs["TF_VAR_owner_group_id"] = strconv.Itoa(viper.GetInt("flags.gitlab-owner-group-id")) } + //dns provider secret to be stored in vault for external dns lifecycle + switch dnsProviderFlag { + case "cloudflare": + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CloudflareApiToken + default: + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = "This is not used, role used instead" //Not strictly used. We use a role in GCP but keeping this here for consistency + } + tfEntrypoint := config.GitopsDir + "/terraform/vault" err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 96f376c91..f7e812c01 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -1246,6 +1246,15 @@ func createCivo(cmd *cobra.Command, args []string) error { tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = civo.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = civo.GetCivoTerraformEnvs(config, tfEnvs) + + //dns provider secret to be stored in vault for external dns lifecycle + switch dnsProviderFlag { + case "cloudflare": + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CloudflareApiToken + default: + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CivoToken + } + tfEntrypoint := config.GitopsDir + "/terraform/vault" err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index e51cfc8a7..4ae4d5d85 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -1237,6 +1237,15 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = digitalocean.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = digitalocean.GetDigitaloceanTerraformEnvs(config, tfEnvs) + + //dns provider secret to be stored in vault for external dns lifecycle + switch dnsProviderFlag { + case "cloudflare": + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CloudflareApiToken + default: + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.DigitaloceanToken + } + tfEntrypoint := config.GitopsDir + "/terraform/vault" err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/gcp/create.go b/cmd/gcp/create.go index 82b0015bf..1aea282d4 100644 --- a/cmd/gcp/create.go +++ b/cmd/gcp/create.go @@ -1230,6 +1230,15 @@ func createGCP(cmd *cobra.Command, args []string) error { tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = gcp.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = gcp.GetGCPTerraformEnvs(config, tfEnvs) + + //dns provider secret to be stored in vault for external dns lifecycle + switch dnsProviderFlag { + case "cloudflare": + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CloudflareApiToken + default: + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = string(a) //Not strictly used. We use a role in GCP but keeping this here for consistency + } + tfEntrypoint := config.GitopsDir + "/terraform/vault" err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index e429bed02..5bf37025f 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -1236,6 +1236,15 @@ func createVultr(cmd *cobra.Command, args []string) error { tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth tfEnvs = vultr.GetVaultTerraformEnvs(kcfg.Clientset, config, tfEnvs) tfEnvs = vultr.GetVultrTerraformEnvs(config, tfEnvs) + + //dns provider secret to be stored in vault for external dns lifecycle + switch dnsProviderFlag { + case "cloudflare": + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.CloudflareApiToken + default: + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", strings.ToLower(dnsProviderFlag))] = config.VultrToken + } + tfEntrypoint := config.GitopsDir + "/terraform/vault" err := terraform.InitApplyAutoApprove(config.TerraformClient, tfEntrypoint, tfEnvs) if err != nil { From 8555ee890bfbf7d7bb11d0d8f14fb65444fa9886 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Wed, 30 Aug 2023 11:30:35 -0500 Subject: [PATCH 40/45] fix: add logging and hardening --- cmd/civo/create.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 25e161502..b21da1d6d 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -423,19 +423,23 @@ func createCivo(cmd *cobra.Command, args []string) error { gitopsTemplateBranchFlag = "main" } default: - switch gitopsTemplateURLFlag { + switch strings.ToLower(gitopsTemplateBranchFlag) { case "https://github.com/kubefirst/gitops-template.git": //default value if gitopsTemplateBranchFlag == "" { + log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied so setting branch name to main") gitopsTemplateBranchFlag = configs.K1Version } case "https://github.com/kubefirst/gitops-template": // edge case for valid but incomplete url if gitopsTemplateBranchFlag == "" { + log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied so setting branch name to main") gitopsTemplateBranchFlag = configs.K1Version } default: // not equal to our defaults - if gitopsTemplateBranchFlag == "" { //didn't supply the branch flag but they did supply the repo flag + if len(strings.TrimSpace(gitopsTemplateBranchFlag)) == 0 { //didn't supply the branch flag but they did supply the repo flag + log.Info().Msgf("--gitops-template-repo-url supplied and branch not supplied but if branch is not supplied then --gitops-template-url must be set to https://github.com/kubefirst/gitops-template or https://github.com/kubefirst/gitops-template.git ") return fmt.Errorf("must supply gitops-template-branch flag when gitops-template-url is overridden") } + log.Info().Msgf("--gitops-template-repo-url supplied and branch supplied so continuing on") } } From 886adb52c0b7857b7b1fa0ea08ee0efe2d8b1ebb Mon Sep 17 00:00:00 2001 From: Claywd <6446939+Claywd@users.noreply.github.com> Date: Wed, 30 Aug 2023 17:30:00 -0500 Subject: [PATCH 41/45] fix: reference civo token in tf var secret --- cmd/civo/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/civo/create.go b/cmd/civo/create.go index b21da1d6d..48932fba7 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -1248,7 +1248,7 @@ func createCivo(cmd *cobra.Command, args []string) error { if viper.GetString("flags.dns-provider") == "cloudflare" { tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CloudflareApiToken } else { - tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = "AWS_Placeholder" + tfEnvs[fmt.Sprintf("TF_VAR_%s_secret", gitopsDirectoryTokens.ExternalDNSProviderName)] = config.CivoToken } tfEnvs["TF_VAR_b64_docker_auth"] = base64DockerAuth From 86cf9fbee8579dba3ad5aea29eb757b4e5919881 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Thu, 31 Aug 2023 19:09:39 -0500 Subject: [PATCH 42/45] fix: reference dnsProviderFlag --- cmd/aws/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 74e140f04..caf316755 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -646,7 +646,7 @@ func createAws(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", awsinternal.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", dnsProviderFlag), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), From ac84165ba7ff359dd73d836d40f83c091b25797e Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Thu, 31 Aug 2023 19:17:04 -0500 Subject: [PATCH 43/45] Fix: external dns secret name auth for cloudflare --- cmd/civo/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/civo/create.go b/cmd/civo/create.go index 48932fba7..0085d4135 100644 --- a/cmd/civo/create.go +++ b/cmd/civo/create.go @@ -346,7 +346,7 @@ func createCivo(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", civo.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", dnsProviderFlag), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), From 464f8326cff141fc52c35d07f611f6bea8b88384 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Thu, 31 Aug 2023 19:18:20 -0500 Subject: [PATCH 44/45] Fix: digitalocean external dns secret auth --- cmd/digitalocean/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/digitalocean/create.go b/cmd/digitalocean/create.go index 8299ffd31..222ffb8de 100644 --- a/cmd/digitalocean/create.go +++ b/cmd/digitalocean/create.go @@ -344,7 +344,7 @@ func createDigitalocean(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", digitalocean.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", dnsProviderFlag), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag), From c61ba847b7c9a97b9b5d6e751223f888cd01f358 Mon Sep 17 00:00:00 2001 From: Clayton Dittman Date: Thu, 31 Aug 2023 19:19:21 -0500 Subject: [PATCH 45/45] Fix: vultr external dns auth secret --- cmd/vultr/create.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/vultr/create.go b/cmd/vultr/create.go index 2fa0ceaa4..2ab18e934 100644 --- a/cmd/vultr/create.go +++ b/cmd/vultr/create.go @@ -343,7 +343,7 @@ func createVultr(cmd *cobra.Command, args []string) error { ExternalDNSProviderName: dnsProviderFlag, ExternalDNSProviderTokenEnvName: externalDNSProviderTokenEnvName, - ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", vultr.CloudProvider), + ExternalDNSProviderSecretName: fmt.Sprintf("%s-auth", dnsProviderFlag), ExternalDNSProviderSecretKey: externalDNSProviderSecretKey, ArgoCDIngressURL: fmt.Sprintf("https://argocd.%s", domainNameFlag),