From dd1c97e9ae088c76a81eea06e22b285a1a59bab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Vanzuita?= Date: Fri, 11 Nov 2022 14:10:39 -0300 Subject: [PATCH] feat: make local use tagged templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Vanzuita --- cmd/local/local.go | 10 +++++++--- cmd/local/prerun.go | 13 +++++++++++++ configs/config.go | 4 +++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cmd/local/local.go b/cmd/local/local.go index c2373abaa..f41298712 100644 --- a/cmd/local/local.go +++ b/cmd/local/local.go @@ -34,12 +34,13 @@ var ( useTelemetry bool dryRun bool silentMode bool + enableConsole bool gitOpsBranch string gitOpsRepo string awsHostedZone string metaphorBranch string adminEmail string - enableConsole bool + templateTag string ) func NewCommand() *cobra.Command { @@ -56,13 +57,16 @@ func NewCommand() *cobra.Command { localCmd.Flags().BoolVar(&useTelemetry, "use-telemetry", true, "installer will not send telemetry about this installation") localCmd.Flags().BoolVar(&dryRun, "dry-run", false, "set to dry-run mode, no changes done on cloud provider selected") localCmd.Flags().BoolVar(&silentMode, "silent", false, "enable silentMode mode will make the UI return less content to the screen") + localCmd.Flags().BoolVar(&enableConsole, "enable-console", true, "If hand-off screen will be presented on a browser UI") + // todo: get it from GH token , use it for console localCmd.Flags().StringVar(&adminEmail, "admin-email", "", "the email address for the administrator as well as for lets-encrypt certificate emails") - localCmd.Flags().StringVar(&metaphorBranch, "metaphor-branch", "main", "metaphor application branch") localCmd.Flags().StringVar(&gitOpsBranch, "gitops-branch", "main", "version/branch used on git clone") localCmd.Flags().StringVar(&gitOpsRepo, "gitops-repo", "gitops", "") - localCmd.Flags().BoolVar(&enableConsole, "enable-console", true, "If hand-off screen will be presented on a browser UI") + localCmd.Flags().StringVar(&templateTag, "template-tag", "", + "when running a built version, and ldflag is set for the Kubefirst version, it will use this tag value to clone the templates (gitops and metaphor's)", + ) localCmd.AddCommand(NewCommandConnect()) diff --git a/cmd/local/prerun.go b/cmd/local/prerun.go index 696ad4fd6..1f6f4c3b8 100644 --- a/cmd/local/prerun.go +++ b/cmd/local/prerun.go @@ -78,6 +78,19 @@ func validateLocal(cmd *cobra.Command, args []string) error { ) } + // if non-development/built/released version, set template tag version to clone tagged templates, in that way + // the current built version, uses the same template version. + // example: kubefirst version 1.10.3, has template repositories (gitops and metaphor's) tags set as 1.10.3 + // when Kubefirst download the templates, it will download the tag version that matches Kubefirst version + if configs.K1Version != configs.DefaultK1Version { + log.Println("loading tag values for built version") + log.Printf("Kubefirst version %q, tags %q", configs.K1Version, config.K3dVersion) + // in order to make the fallback tags work, set gitops branch as empty + gitOpsBranch = "" + templateTag = configs.K1Version + viper.Set("template.tag", templateTag) + } + // set default values to kubefirst file viper.Set("gitops.repo", gitOpsRepo) viper.Set("gitops.owner", "kubefirst") diff --git a/configs/config.go b/configs/config.go index 81b5c586f..8eb1c7162 100644 --- a/configs/config.go +++ b/configs/config.go @@ -14,9 +14,11 @@ This is an initial implementation of Config. Please keep in mind we're still wor environment variables and general config data. */ +const DefaultK1Version = "development" + // K1Version is used on version command. The value is dynamically updated on build time via ldflag. Built Kubefirst // versions will follow semver value like 1.9.0, when not using the built version, "development" is used. -var K1Version = "development" +var K1Version = DefaultK1Version // Config host application configuration // todo: some of these values can be moved to the .env