From 87359c363ec9165dacc7f2416329f0078dcd41ac Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 13:21:59 -0300 Subject: [PATCH 1/6] add config view command --- cmd/release/cmd/config.go | 3 +-- cmd/release/config/config.go | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cmd/release/cmd/config.go b/cmd/release/cmd/config.go index f65f0fe5..63a5b6b0 100644 --- a/cmd/release/cmd/config.go +++ b/cmd/release/cmd/config.go @@ -1,7 +1,6 @@ package cmd import ( - "errors" "fmt" "os" @@ -42,7 +41,7 @@ var viewConfigSubCmd = &cobra.Command{ Short: "view config", Long: ``, RunE: func(cmd *cobra.Command, args []string) error { - return errors.New("not implemented yet") + return config.View(rootConfig) }, } diff --git a/cmd/release/config/config.go b/cmd/release/config/config.go index ebd2dc99..71d950b7 100644 --- a/cmd/release/config/config.go +++ b/cmd/release/config/config.go @@ -8,6 +8,7 @@ import ( "os/exec" "path/filepath" "strings" + "text/template" ) const ( @@ -178,9 +179,35 @@ func exampleConfig() Config { } } -const configViewTemplate = `RKE2 Version +func View(config *Config) error { + tmp, err := template.New("ecm").Parse(configViewTemplate) + if err != nil { + return err + } + return tmp.Execute(os.Stdout, config) +} + +const configViewTemplate = `ECM distro tools config +------------ +User + Email: {{ .User.Email }} + Github Username: {{ .User.GithubUsername }} +------------ +K3s {{ range $version, $value := .K3s.Versions }} + {{ $version }}: + Old K8s Version: {{ $value.OldK8sVersion}} + New K8s Version: {{ $value.NewK8sVersion}} + Old K8s Client: {{ $value.OldK8sClient}} + New K8s Client: {{ $value.NewK8sClient}} + Old Suffix: {{ $value.OldSuffix}} + New Suffix: {{ $value.NewSuffix}} + Release Branch: {{ $value.ReleaseBranch}} + Dry Run: {{ $value.DryRun}} + K3s Repo Owner: {{ $value.K3sRepoOwner}} + K8s Rancher URL: {{ $value.K8sRancherURL}} + Workspace: {{ $value.Workspace}} + K3s Upstream URL: {{ $value.K3sUpstreamURL}}{{ end }} ------------ -{{- range .RKE2.Versions }} -{{ . -}}+rke2r1 -{{- end}} +RKE2{{ range .RKE2.Versions }} + {{ . }}{{ end}} ` From f7f5c379dd410485abe1b21fdc7a523c6ecd5c61 Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 13:36:10 -0300 Subject: [PATCH 2/6] add descriptions --- cmd/release/cmd/config.go | 11 ++++------- cmd/release/cmd/generate.go | 12 ++++++------ cmd/release/cmd/list.go | 2 -- cmd/release/cmd/push.go | 6 +++--- cmd/release/cmd/tag.go | 12 ++++-------- cmd/release/cmd/update.go | 6 +++--- 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/cmd/release/cmd/config.go b/cmd/release/cmd/config.go index 63a5b6b0..fbe39dcb 100644 --- a/cmd/release/cmd/config.go +++ b/cmd/release/cmd/config.go @@ -11,8 +11,7 @@ import ( // configCmd represents the config command var configCmd = &cobra.Command{ Use: "config", - Short: "", - Long: ``, + Short: "Manage the ecm distro tools cli config file", Run: func(cmd *cobra.Command, args []string) { if len(args) < 1 { rootCmd.Help() @@ -23,8 +22,7 @@ var configCmd = &cobra.Command{ var genConfigSubCmd = &cobra.Command{ Use: "gen", - Short: "generate config", - Long: `generates a new config in the default location if it doesn't exists`, + Short: "Generates a config file in the default location if it doesn't exists", RunE: func(cmd *cobra.Command, args []string) error { if err := config.Generate(); err != nil { return err @@ -38,8 +36,7 @@ var genConfigSubCmd = &cobra.Command{ var viewConfigSubCmd = &cobra.Command{ Use: "view", - Short: "view config", - Long: ``, + Short: "Print the parsed config to stdout", RunE: func(cmd *cobra.Command, args []string) error { return config.View(rootConfig) }, @@ -47,7 +44,7 @@ var viewConfigSubCmd = &cobra.Command{ var editConfigSubCmd = &cobra.Command{ Use: "edit", - Short: "edit config", + Short: "Open the config file in your default editor", Long: ``, RunE: func(cmd *cobra.Command, args []string) error { return config.OpenOnEditor() diff --git a/cmd/release/cmd/generate.go b/cmd/release/cmd/generate.go index 23306007..efb87618 100644 --- a/cmd/release/cmd/generate.go +++ b/cmd/release/cmd/generate.go @@ -23,7 +23,7 @@ var ( // generateCmd represents the generate command var generateCmd = &cobra.Command{ Use: "generate", - Short: "", + Short: "Various utilities to generate release artifacts", Run: func(cmd *cobra.Command, args []string) { if len(args) < 1 || len(args) > 2 { rootCmd.Help() @@ -34,12 +34,12 @@ var generateCmd = &cobra.Command{ var k3sGenerateSubCmd = &cobra.Command{ Use: "k3s", - Short: "", + Short: "Generate k3s related artifacts", } var k3sGenerateReleaseNotesSubCmd = &cobra.Command{ Use: "release-notes", - Short: "", + Short: "Generate k3s release notes", RunE: func(cmd *cobra.Command, args []string) error { ctx := context.Background() client := repository.NewGithub(ctx, rootConfig.Auth.GithubToken) @@ -57,7 +57,7 @@ var k3sGenerateReleaseNotesSubCmd = &cobra.Command{ var k3sGenerateTagsSubCmd = &cobra.Command{ Use: "tags [version]", - Short: "generate k8s tags for a given version", + Short: "Generate k8s tags for a given version", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("expected at least one argument: [version]") @@ -75,12 +75,12 @@ var k3sGenerateTagsSubCmd = &cobra.Command{ var rke2GenerateSubCmd = &cobra.Command{ Use: "rke2", - Short: "", + Short: "Generate rke2 related artifacts", } var rke2GenerateReleaseNotesSubCmd = &cobra.Command{ Use: "release-notes", - Short: "", + Short: "Generate rke2 release notes", RunE: func(cmd *cobra.Command, args []string) error { ctx := context.Background() client := repository.NewGithub(ctx, rootConfig.Auth.GithubToken) diff --git a/cmd/release/cmd/list.go b/cmd/release/cmd/list.go index 79e94f51..25225395 100644 --- a/cmd/release/cmd/list.go +++ b/cmd/release/cmd/list.go @@ -15,7 +15,6 @@ var rancherImageTag *string var listCmd = &cobra.Command{ Use: "list", Short: "List resources", - Long: ``, Run: func(cmd *cobra.Command, args []string) { // }, @@ -24,7 +23,6 @@ var listCmd = &cobra.Command{ var rancherListSubCmd = &cobra.Command{ Use: "rancher", Short: "List Rancher resources", - Long: ``, RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return errors.New("arguments required") diff --git a/cmd/release/cmd/push.go b/cmd/release/cmd/push.go index b7e6173d..61df3299 100644 --- a/cmd/release/cmd/push.go +++ b/cmd/release/cmd/push.go @@ -11,17 +11,17 @@ import ( var pushCmd = &cobra.Command{ Use: "push", - Short: "", + Short: "Push things from your local to a remote", } var pushK3sCmd = &cobra.Command{ Use: "k3s [version]", - Short: "", + Short: "Push k3s artifacts", } var pushK3sTagsCmd = &cobra.Command{ Use: "tags [version]", - Short: "push k8s tags to remote", + Short: "Push k3s-io/kubernetes tags to remote", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("expected at least one argument: [version]") diff --git a/cmd/release/cmd/tag.go b/cmd/release/cmd/tag.go index 33ce492a..015d9aea 100644 --- a/cmd/release/cmd/tag.go +++ b/cmd/release/cmd/tag.go @@ -36,8 +36,7 @@ var ( // tagCmd represents the tag command. var tagCmd = &cobra.Command{ Use: "tag", - Short: "", - Long: ``, + Short: "Tag releases", Run: func(cmd *cobra.Command, args []string) { if len(args) < 1 { rootCmd.Help() @@ -48,8 +47,7 @@ var tagCmd = &cobra.Command{ var k3sTagSubCmd = &cobra.Command{ Use: "k3s [ga,rc] [version]", - Short: "", - Long: ``, + Short: "Tag k3s releases", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 2 { return errors.New("expected at least two arguments: [ga,rc] [version]") @@ -71,8 +69,7 @@ var k3sTagSubCmd = &cobra.Command{ var rke2TagSubCmd = &cobra.Command{ Use: "rke2", - Short: "", - Long: ``, + Short: "Tag rke2 releases", RunE: func(cmd *cobra.Command, args []string) error { if len(*tagRKE2Flags.AlpineVersion) != 2 { return errors.New("invalid release version") @@ -152,8 +149,7 @@ var rke2TagSubCmd = &cobra.Command{ var rancherTagSubCmd = &cobra.Command{ Use: "rancher", - Short: "", - Long: ``, + Short: "Tag Rancher releases", RunE: func(cmd *cobra.Command, args []string) error { ctx := context.Background() ghClient := repository.NewGithub(ctx, rootConfig.Auth.GithubToken) diff --git a/cmd/release/cmd/update.go b/cmd/release/cmd/update.go index 143c66eb..557c8fe4 100644 --- a/cmd/release/cmd/update.go +++ b/cmd/release/cmd/update.go @@ -11,17 +11,17 @@ import ( var updateCmd = &cobra.Command{ Use: "update", - Short: "", + Short: "Update files and other utilities", } var updateK3sCmd = &cobra.Command{ Use: "k3s", - Short: "", + Short: "Update k3s files", } var updateK3sReferencesCmd = &cobra.Command{ Use: "references [version]", - Short: "update k8s and go references in a k3s repo and create a PR", + Short: "Update k8s and go references in a k3s repo and create a PR", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("expected at least one argument: [version]") From 2fc19e5ec8b8e05efd07c1983ef2e73d7e44a79b Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 15:00:13 -0300 Subject: [PATCH 3/6] Update cmd/release/cmd/config.go Co-authored-by: Brian Downs --- cmd/release/cmd/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/release/cmd/config.go b/cmd/release/cmd/config.go index fbe39dcb..740cfd53 100644 --- a/cmd/release/cmd/config.go +++ b/cmd/release/cmd/config.go @@ -11,7 +11,7 @@ import ( // configCmd represents the config command var configCmd = &cobra.Command{ Use: "config", - Short: "Manage the ecm distro tools cli config file", + Short: "Manage the release cli config file", Run: func(cmd *cobra.Command, args []string) { if len(args) < 1 { rootCmd.Help() From 78d55cede3c4224e6e8bcf3b1f737e107d261ed7 Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 15:00:20 -0300 Subject: [PATCH 4/6] Update cmd/release/config/config.go Co-authored-by: Brian Downs --- cmd/release/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/release/config/config.go b/cmd/release/config/config.go index 71d950b7..71b6f8a1 100644 --- a/cmd/release/config/config.go +++ b/cmd/release/config/config.go @@ -187,7 +187,7 @@ func View(config *Config) error { return tmp.Execute(os.Stdout, config) } -const configViewTemplate = `ECM distro tools config +const configViewTemplate = `Release config ------------ User Email: {{ .User.Email }} From a3d86331743407c98907e69abca989fba60ddb8d Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 15:00:31 -0300 Subject: [PATCH 5/6] Update cmd/release/cmd/update.go Co-authored-by: Brian Downs --- cmd/release/cmd/update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/release/cmd/update.go b/cmd/release/cmd/update.go index 557c8fe4..2253e51e 100644 --- a/cmd/release/cmd/update.go +++ b/cmd/release/cmd/update.go @@ -21,7 +21,7 @@ var updateK3sCmd = &cobra.Command{ var updateK3sReferencesCmd = &cobra.Command{ Use: "references [version]", - Short: "Update k8s and go references in a k3s repo and create a PR", + Short: "Update k8s and Go references in a k3s repo and create a PR", RunE: func(cmd *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("expected at least one argument: [version]") From 1a758fc7db1fe299db6cf67ccd90ff5289f41515 Mon Sep 17 00:00:00 2001 From: Pedro Tashima Date: Tue, 30 Jan 2024 18:55:32 -0300 Subject: [PATCH 6/6] use new line to separate config view --- cmd/release/config/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/release/config/config.go b/cmd/release/config/config.go index 71b6f8a1..45c3e6e7 100644 --- a/cmd/release/config/config.go +++ b/cmd/release/config/config.go @@ -188,11 +188,11 @@ func View(config *Config) error { } const configViewTemplate = `Release config ------------- + User Email: {{ .User.Email }} Github Username: {{ .User.GithubUsername }} ------------- + K3s {{ range $version, $value := .K3s.Versions }} {{ $version }}: Old K8s Version: {{ $value.OldK8sVersion}} @@ -207,7 +207,7 @@ K3s {{ range $version, $value := .K3s.Versions }} K8s Rancher URL: {{ $value.K8sRancherURL}} Workspace: {{ $value.Workspace}} K3s Upstream URL: {{ $value.K3sUpstreamURL}}{{ end }} ------------- + RKE2{{ range .RKE2.Versions }} {{ . }}{{ end}} `