From c5d0d67b2dcd64fe5fe29b536b78dac43d3b6e5e Mon Sep 17 00:00:00 2001 From: Andrew Suderman Date: Fri, 1 Apr 2022 15:54:27 -0600 Subject: [PATCH] Bugfixes. Add update-cli command (#562) --- cmd/root.go | 5 +++ cmd/update.go | 43 ++++++++++++++++++++ cmd/version.go | 3 +- end_to_end_testing/tests/07_good_hooks.yaml | 4 +- end_to_end_testing/tests/10_git_charts.yaml | 9 +++++ end_to_end_testing/tests/13_schema.yaml | 8 ++-- end_to_end_testing/tests/21_diff.yaml | 4 +- go.mod | 9 +++++ go.sum | 22 ++++++++++ pkg/course/course.go | 1 + pkg/helm/helm.go | 1 + pkg/reckoner/client.go | 4 +- pkg/reckoner/plot.go | 45 +++++++++++++-------- 13 files changed, 130 insertions(+), 28 deletions(-) create mode 100644 cmd/update.go diff --git a/cmd/root.go b/cmd/root.go index ae7434ec..95fc3f0a 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -20,6 +20,7 @@ import ( "os" "github.com/fatih/color" + "github.com/mattn/go-colorable" "github.com/spf13/cobra" "github.com/spf13/pflag" "gopkg.in/yaml.v3" @@ -87,10 +88,14 @@ func init() { getManifestsCmd, updateCmd, importCmd, + updateReckonerCmd, + versionCmd, ) klog.InitFlags(nil) pflag.CommandLine.AddGoFlag(flag.CommandLine.Lookup("v")) + + color.Output = colorable.NewColorableStderr() } var rootCmd = &cobra.Command{ diff --git a/cmd/update.go b/cmd/update.go new file mode 100644 index 00000000..c79d6fba --- /dev/null +++ b/cmd/update.go @@ -0,0 +1,43 @@ +package cmd + +import ( + "os" + + "github.com/blang/semver" + "github.com/gookit/color" + "github.com/rhysd/go-github-selfupdate/selfupdate" + "github.com/spf13/cobra" + "k8s.io/klog/v2" +) + +var updateReckonerCmd = &cobra.Command{ + Use: "update-cli", + Short: "Update reckoner.", + Long: "Updates the reckoner binary to the latest tagged release.", + Run: func(cmd *cobra.Command, args []string) { + klog.V(4).Infof("current version: %s", version) + v, err := semver.Parse(version) + if err != nil { + color.Red.Printf("Could not parse version: %s\n", err.Error()) + os.Exit(1) + } + color.Green.Printf("Checking for update. Current version: %s\n", version) + + up, err := selfupdate.NewUpdater(selfupdate.Config{}) + if err != nil { + color.Red.Println(err) + os.Exit(1) + } + latest, err := up.UpdateSelf(v, "fairwindsops/reckoner") + if err != nil { + color.Red.Println("Update failed:", err) + os.Exit(1) + } + if latest.Version.Equals(v) { + color.Green.Println("Current binary is the latest version", version) + } else { + color.Green.Println("Successfully updated to version", latest.Version) + color.Gray.Println("Release note:\n", latest.ReleaseNotes) + } + }, +} diff --git a/cmd/version.go b/cmd/version.go index 560d5409..1694945d 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -25,8 +25,7 @@ var ( ) func init() { - rootCmd.AddCommand(versionCmd) - rootCmd.PersistentFlags().BoolVar(&shortVersion, "short", false, "Display only the version. Useful for automation") + versionCmd.PersistentFlags().BoolVar(&shortVersion, "short", false, "Display only the version. Useful for automation") } var versionCmd = &cobra.Command{ diff --git a/end_to_end_testing/tests/07_good_hooks.yaml b/end_to_end_testing/tests/07_good_hooks.yaml index af106c99..f414d68c 100644 --- a/end_to_end_testing/tests/07_good_hooks.yaml +++ b/end_to_end_testing/tests/07_good_hooks.yaml @@ -11,8 +11,8 @@ testcases: reckoner plot -a {{.course}} assertions: - result.code ShouldEqual 0 - - result.systemout ShouldContainSubstring "Running release pre hook" - - result.systemout ShouldContainSubstring "Running release post hook" + - result.systemerr ShouldContainSubstring "Running release pre hook" + - result.systemerr ShouldContainSubstring "Running release post hook" - script: | helm -n {{.namespace}} get all {{.release}} assertions: diff --git a/end_to_end_testing/tests/10_git_charts.yaml b/end_to_end_testing/tests/10_git_charts.yaml index 231ddad9..95ddc151 100644 --- a/end_to_end_testing/tests/10_git_charts.yaml +++ b/end_to_end_testing/tests/10_git_charts.yaml @@ -18,6 +18,15 @@ testcases: - result.systemout ShouldContainSubstring 'another-polaris' - result.systemout ShouldContainSubstring '10-test' - result.systemout ShouldContainSubstring 'polaris-release' +- name: 10 - template course + steps: + - script: | + reckoner template -a {{.course}} + assertions: + - result.code ShouldEqual 0 + - result.systemout ShouldContainSubstring 'goldilocks' + - result.systemout ShouldContainSubstring 'polaris' + - result.systemout ShouldContainSubstring 'another-polaris' - name: 10 - cleanup namespace creation steps: - script: | diff --git a/end_to_end_testing/tests/13_schema.yaml b/end_to_end_testing/tests/13_schema.yaml index 254872a9..e035efd7 100644 --- a/end_to_end_testing/tests/13_schema.yaml +++ b/end_to_end_testing/tests/13_schema.yaml @@ -9,21 +9,21 @@ testcases: reckoner plot -a ../course_files/13_test_bad_schema_repository.yml assertions: - result.code ShouldEqual 1 - - result.systemout ShouldContainSubstring 'Course file has schema validation errors' + - result.systemerr ShouldContainSubstring 'Course file has schema validation errors' - name: 13 - plot 13_test_required_schema.yml steps: - script: | reckoner plot -a ../course_files/13_test_required_schema.yml assertions: - result.code ShouldEqual 1 - - result.systemout ShouldContainSubstring 'Course file has schema validation errors' + - result.systemerr ShouldContainSubstring 'Course file has schema validation errors' - name: 13 - lint 13_test_lint_bad_secret.yml steps: - script: | reckoner lint ../course_files/13_test_lint_bad_secret.yml assertions: - result.code ShouldEqual 1 - - result.systemout ShouldContainSubstring 'Course file has schema validation errors' + - result.systemerr ShouldContainSubstring 'Course file has schema validation errors' - name: 13 - lint 13_test_lint_good_secret.yml steps: @@ -31,4 +31,4 @@ testcases: reckoner lint ../course_files/13_test_lint_good_secret.yml assertions: - result.code ShouldEqual 0 - - result.systemout ShouldContainSubstring 'No schema validation errors found' + - result.systemerr ShouldContainSubstring 'No schema validation errors found' diff --git a/end_to_end_testing/tests/21_diff.yaml b/end_to_end_testing/tests/21_diff.yaml index b1f35c8b..72fa34b1 100644 --- a/end_to_end_testing/tests/21_diff.yaml +++ b/end_to_end_testing/tests/21_diff.yaml @@ -14,12 +14,12 @@ testcases: reckoner diff {{.course}} -o chart-with-namespace assertions: - result.code ShouldEqual 0 - - result.systemout ShouldContainSubstring "There are no differences in release" + - result.systemerr ShouldContainSubstring "There are no differences in release" - script: | reckoner diff {{.course}} -o chart-without-namespace assertions: - result.code ShouldEqual 0 - - result.systemout ShouldContainSubstring "There are no differences in release" + - result.systemerr ShouldContainSubstring "There are no differences in release" - name: 21 - cleanup steps: - script: | diff --git a/go.mod b/go.mod index 2f20da14..4aedc229 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,12 @@ go 1.17 require ( github.com/Masterminds/semver/v3 v3.1.1 + github.com/blang/semver v3.5.1+incompatible github.com/davecgh/go-spew v1.1.1 github.com/fatih/color v1.13.0 github.com/go-git/go-git/v5 v5.4.2 + github.com/gookit/color v1.5.0 + github.com/rhysd/go-github-selfupdate v1.2.3 github.com/sergi/go-diff v1.1.0 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 @@ -41,9 +44,12 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.6 // indirect + github.com/google/go-github/v30 v30.1.0 // indirect + github.com/google/go-querystring v1.0.0 // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/googleapis/gnostic v0.5.5 // indirect github.com/imdario/mergo v0.3.12 // indirect + github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -55,9 +61,12 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/tcnksm/go-gitconfig v0.1.2 // indirect + github.com/ulikunitz/xz v0.5.9 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect diff --git a/go.sum b/go.sum index 3cafe376..d8e50f21 100644 --- a/go.sum +++ b/go.sum @@ -101,6 +101,7 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= +github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= @@ -261,6 +262,10 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo= +github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8= +github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -291,6 +296,8 @@ github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0 github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= github.com/googleapis/gnostic v0.5.5 h1:9fHAtK0uDfpveeqqo1hkEZJcFvYXAiCN3UutL8F9xHw= github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= +github.com/gookit/color v1.5.0 h1:1Opow3+BWDwqor78DcJkJCIwnkviFi+rrOANki9BUFw= +github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -326,6 +333,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1: github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf h1:WfD7VjIE6z8dIvMsI4/s+1qr5EL+zoIGev1BQj1eoJ8= +github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -419,6 +428,7 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= @@ -458,6 +468,8 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rhysd/go-github-selfupdate v1.2.3 h1:iaa+J202f+Nc+A8zi75uccC8Wg3omaM7HDeimXA22Ag= +github.com/rhysd/go-github-selfupdate v1.2.3/go.mod h1:mp/N8zj6jFfBQy/XMYoWsmfzxazpPAODuqarmPDe2Rg= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 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= @@ -507,10 +519,14 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw= +github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= github.com/thoas/go-funk v0.9.2 h1:oKlNYv0AY5nyf9g+/GhMgS/UO2ces0QRdPKwkhY3VCk= github.com/thoas/go-funk v0.9.2/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ulikunitz/xz v0.5.9 h1:RsKRIA2MO8x56wkkcd3LbtcE/uMszhb6DpRf+3uwa3I= +github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -521,6 +537,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHgvgickp1Yw510KJOqX7H24mg8= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -579,6 +597,7 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= @@ -670,6 +689,7 @@ golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/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= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -776,6 +796,7 @@ golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d h1:FjkYO/PPp4Wi0EAUOVLxePm7qVW4r4ctbWpURyuOD0E= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -895,6 +916,7 @@ google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= diff --git a/pkg/course/course.go b/pkg/course/course.go index f2054fca..91726bc8 100644 --- a/pkg/course/course.go +++ b/pkg/course/course.go @@ -306,6 +306,7 @@ func OpenCourseFile(fileName string, schema []byte) (*FileV2, error) { if errConvert != nil { return nil, fmt.Errorf("could not unmarshal file from v1 or v2 schema:\n\t%s", errConvert.Error()) } + color.Yellow("WARNING: this course file was automatically converted from v1 to v2 at runtime - to convert the file permanently, run \"reckoner convert -i %s\"", fileName) courseFile = fileV2 } diff --git a/pkg/helm/helm.go b/pkg/helm/helm.go index 7e670b28..af056271 100644 --- a/pkg/helm/helm.go +++ b/pkg/helm/helm.go @@ -109,6 +109,7 @@ func (h Client) UpdateDependencies(path string) error { if stdErr != "" { return fmt.Errorf("error running helm dependency update: %s", stdErr) } + return nil } diff --git a/pkg/reckoner/client.go b/pkg/reckoner/client.go index a385126c..3ba259a5 100644 --- a/pkg/reckoner/client.go +++ b/pkg/reckoner/client.go @@ -103,8 +103,8 @@ func (c *Client) Init(fileName string, initKubeClient bool) error { c.KubeClient = getKubeClient(courseFile.Context) } - klog.V(5).Infof("successfully initialized client:") - if klog.V(5).Enabled() { + klog.V(10).Infof("successfully initialized client:") + if klog.V(10).Enabled() { spew.Dump(c) } diff --git a/pkg/reckoner/plot.go b/pkg/reckoner/plot.go index 5650134f..493f29e6 100644 --- a/pkg/reckoner/plot.go +++ b/pkg/reckoner/plot.go @@ -66,23 +66,15 @@ func (c *Client) Plot() error { defer os.Remove(tmpFile.Name()) } - if !c.DryRun { - if release.GitClonePath != nil { - if err := c.cloneGitRepository(release); err != nil { - if c.Continue() { - color.Red("error with release %s: %s, continuing.", release.Name, err.Error()) - continue - } - return err - } - if err := c.Helm.UpdateDependencies(fmt.Sprintf("%s/%s", *release.GitClonePath, *release.GitChartSubPath)); err != nil { - if c.Continue() { - color.Red("error with release %s: %s, continuing.", release.Name, err.Error()) - continue - } - return err - } + if err := c.cloneGitRepo(release); err != nil { + if c.Continue() { + color.Red(err.Error()) + continue } + return err + } + + if !c.DryRun { out, stdErr, err := c.Helm.Exec(args...) if err != nil { if c.Continue() { @@ -126,6 +118,11 @@ func (c Client) TemplateAll() (string, error) { var fullOutput string for _, release := range c.CourseFile.Releases { + + if err := c.cloneGitRepo(release); err != nil { + color.Red(err.Error()) + } + out, err := c.TemplateRelease(release.Name) if err != nil { color.Red(err.Error()) @@ -238,3 +235,19 @@ func makeTempValuesFile(values map[string]interface{}) (*os.File, error) { return tmpFile, nil } + +func (c *Client) cloneGitRepo(release *course.Release) error { + if release.GitClonePath != nil { + if err := c.cloneGitRepository(release); err != nil { + color.Red("error with release %s: %s, continuing.", release.Name, err.Error()) + return err + } + + if err := c.Helm.UpdateDependencies(fmt.Sprintf("%s/%s", *release.GitClonePath, *release.GitChartSubPath)); err != nil { + + color.Red("error with release %s: %s, continuing.", release.Name, err.Error()) + return err + } + } + return nil +}