Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#335: view config #352

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions cmd/release/cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cmd

import (
"errors"
"fmt"
"os"

Expand All @@ -12,8 +11,7 @@ import (
// configCmd represents the config command
var configCmd = &cobra.Command{
Use: "config",
Short: "",
Long: ``,
Short: "Manage the release cli config file",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
rootCmd.Help()
Expand All @@ -24,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
Expand All @@ -39,16 +36,15 @@ 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 errors.New("not implemented yet")
return config.View(rootConfig)
},
}

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()
Expand Down
12 changes: 6 additions & 6 deletions cmd/release/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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]")
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions cmd/release/cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var rancherImageTag *string
var listCmd = &cobra.Command{
Use: "list",
Short: "List resources",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
//
},
Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions cmd/release/cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down
12 changes: 4 additions & 8 deletions cmd/release/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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]")
Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/release/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]")
Expand Down
35 changes: 31 additions & 4 deletions cmd/release/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"text/template"
)

const (
Expand Down Expand Up @@ -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 = `Release 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}}
`
Loading