This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
EVEREST-793: upgrade command #297
Draft
ghost
wants to merge
11
commits into
main
Choose a base branch
from
EVEREST-793-upgrade
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cfb044c
EVEREST-793: upgrade
3714488
Merge branch 'main' into EVEREST-793-upgrade
70bbf28
Progress
75c0781
Merge branch 'main' into EVEREST-793-upgrade
134b47a
go mod tidy
8db3369
cleanup
c652985
Install proper versions
52a8044
Resolve a couple TODOs
ded2d9c
Merge branch 'main' into EVEREST-793-upgrade
9eeb4b9
Refactore test
66ce00b
Remove namespace flag
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,11 @@ import ( | |
"github.com/spf13/viper" | ||
"go.uber.org/zap" | ||
|
||
everestClient "github.com/percona/percona-everest-cli/pkg/everest/client" | ||
"github.com/percona/percona-everest-cli/pkg/output" | ||
"github.com/percona/percona-everest-cli/pkg/upgrade" | ||
) | ||
|
||
// newUpgradeCmd returns a new operators command. | ||
func newUpgradeCmd(l *zap.SugaredLogger) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "upgrade", | ||
recharte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -40,12 +40,17 @@ func newUpgradeCmd(l *zap.SugaredLogger) *cobra.Command { | |
Run: func(cmd *cobra.Command, args []string) { | ||
initUpgradeViperFlags(cmd) | ||
|
||
c, err := parseConfig() | ||
c, err := parseUpgradeConfig() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
|
||
op, err := upgrade.NewUpgrade(*c, l) | ||
everestClConnector, err := everestClient.NewEverestFromURL(c.Everest.Endpoint, c.Everest.Token) | ||
if err != nil { | ||
l.Error(err) | ||
os.Exit(1) | ||
} | ||
op, err := upgrade.NewUpgrade(c, everestClConnector, l) | ||
if err != nil { | ||
l.Error(err) | ||
os.Exit(1) | ||
|
@@ -64,22 +69,22 @@ func newUpgradeCmd(l *zap.SugaredLogger) *cobra.Command { | |
} | ||
|
||
func initUpgradeFlags(cmd *cobra.Command) { | ||
cmd.Flags().String("everest.endpoint", "http://127.0.0.1:8080", "Everest endpoint URL") | ||
cmd.Flags().String("everest.token", "", "Everest token to authenticate against Everest") | ||
cmd.Flags().StringP("kubeconfig", "k", "~/.kube/config", "Path to a kubeconfig") | ||
cmd.Flags().String("namespaces", "", "Comma-separated namespaces list Percona Everest can manage") | ||
cmd.Flags().Bool("upgrade-olm", false, "Upgrade OLM distribution") | ||
cmd.Flags().Bool("skip-wizard", false, "Skip installation wizard") | ||
cmd.Flags().String("version-metadata-url", "https://check.percona.com", "URL to retrieve version metadata information from") | ||
} | ||
|
||
func initUpgradeViperFlags(cmd *cobra.Command) { | ||
viper.BindEnv("kubeconfig") //nolint:errcheck,gosec | ||
viper.BindPFlag("kubeconfig", cmd.Flags().Lookup("kubeconfig")) //nolint:errcheck,gosec | ||
viper.BindPFlag("namespaces", cmd.Flags().Lookup("namespaces")) //nolint:errcheck,gosec | ||
viper.BindPFlag("upgrade-olm", cmd.Flags().Lookup("upgrade-olm")) //nolint:errcheck,gosec | ||
viper.BindPFlag("skip-wizard", cmd.Flags().Lookup("skip-wizard")) //nolint:errcheck,gosec | ||
viper.BindPFlag("everest.endpoint", cmd.Flags().Lookup("everest.endpoint")) //nolint:errcheck,gosec | ||
viper.BindPFlag("everest.token", cmd.Flags().Lookup("everest.token")) //nolint:errcheck,gosec | ||
viper.BindEnv("kubeconfig") //nolint:errcheck,gosec | ||
viper.BindPFlag("kubeconfig", cmd.Flags().Lookup("kubeconfig")) //nolint:errcheck,gosec | ||
viper.BindPFlag("version-metadata-url", cmd.Flags().Lookup("version-metadata-url")) //nolint:errcheck,gosec | ||
} | ||
|
||
func parseConfig() (*upgrade.Config, error) { | ||
c := &upgrade.Config{} | ||
func parseUpgradeConfig() (*upgrade.UpgradeConfig, error) { | ||
c := &upgrade.UpgradeConfig{} | ||
Comment on lines
-81
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will there config types other than the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, there could be, as we have with other commands. |
||
err := viper.Unmarshal(c) | ||
return c, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,22 +2,25 @@ module github.com/percona/percona-everest-cli | |
|
||
go 1.21 | ||
|
||
replace github.com/Percona-Lab/percona-version-service => ../percona-version-service | ||
|
||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving a comment so we don't forget about this. |
||
require ( | ||
github.com/AlecAivazis/survey/v2 v2.3.7 | ||
github.com/Percona-Lab/percona-version-service v0.0.0-20230404081016-ea25e30cdcbc | ||
github.com/dchest/uniuri v1.2.0 | ||
github.com/go-logr/zapr v1.3.0 | ||
github.com/hashicorp/go-version v1.6.0 | ||
github.com/operator-framework/api v0.22.0 | ||
github.com/operator-framework/operator-lifecycle-manager v0.26.0 | ||
github.com/percona/everest-operator v0.6.0-dev1.0.20240220114053-fae6111d9818 | ||
github.com/percona/percona-everest-backend v0.7.0 | ||
github.com/spf13/cobra v1.8.0 | ||
github.com/spf13/viper v1.18.2 | ||
github.com/stretchr/testify v1.8.4 | ||
go.uber.org/zap v1.26.0 | ||
golang.org/x/crypto v0.19.0 | ||
golang.org/x/sync v0.6.0 | ||
gopkg.in/yaml.v3 v3.0.1 | ||
gotest.tools v2.2.0+incompatible | ||
k8s.io/api v0.29.1 | ||
k8s.io/apiextensions-apiserver v0.29.1 | ||
k8s.io/apimachinery v0.29.1 | ||
|
@@ -31,7 +34,8 @@ require ( | |
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 // indirect | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect | ||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 // indirect | ||
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect | ||
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect | ||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect | ||
github.com/aws/aws-sdk-go v1.50.9 // indirect | ||
github.com/blang/semver/v4 v4.0.0 // indirect | ||
github.com/bshuster-repo/logrus-logstash-hook v1.0.0 // indirect | ||
|
@@ -43,31 +47,33 @@ require ( | |
github.com/evanphx/json-patch/v5 v5.8.0 // indirect | ||
github.com/flosch/pongo2/v6 v6.0.0 // indirect | ||
github.com/fsnotify/fsnotify v1.7.0 // indirect | ||
github.com/getkin/kin-openapi v0.122.0 // indirect | ||
github.com/go-errors/errors v1.5.0 // indirect | ||
github.com/go-ini/ini v1.67.0 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-openapi/jsonpointer v0.20.2 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.22.8 // indirect | ||
github.com/go-openapi/jsonreference v0.20.4 // indirect | ||
github.com/go-openapi/swag v0.22.9 // indirect | ||
github.com/go-sql-driver/mysql v1.7.1 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/google/cel-go v0.17.7 // indirect | ||
github.com/google/cel-go v0.19.0 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/gorilla/handlers v1.5.1 // indirect | ||
github.com/gorilla/mux v1.8.1 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect | ||
github.com/h2non/filetype v1.1.1 // indirect | ||
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect | ||
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect | ||
github.com/imdario/mergo v0.3.16 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/invopop/yaml v0.2.0 // indirect | ||
github.com/jessevdk/go-flags v1.5.0 // indirect | ||
github.com/jmespath/go-jmespath v0.4.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
|
@@ -86,18 +92,21 @@ require ( | |
github.com/moby/spdystream v0.2.0 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect | ||
github.com/mongodb/mongo-tools v0.0.0-20230720205640-fb74684da15f // indirect | ||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect | ||
github.com/montanaflynn/stats v0.6.6 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect | ||
github.com/oapi-codegen/runtime v1.1.0 // indirect | ||
github.com/onsi/gomega v1.30.0 // indirect | ||
github.com/operator-framework/operator-registry v1.30.1 // indirect | ||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect | ||
github.com/percona/percona-backup-mongodb v1.8.1-0.20230920143330-3b1c2e263901 // indirect | ||
github.com/percona/percona-postgresql-operator v0.0.0-20231220140959-ad5eef722609 // indirect | ||
github.com/percona/percona-server-mongodb-operator v1.15.0 // indirect | ||
github.com/percona/percona-xtradb-cluster-operator v1.13.0 // indirect | ||
github.com/perimeterx/marshmallow v1.1.5 // indirect | ||
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 // indirect | ||
github.com/pierrec/lz4 v2.6.1+incompatible // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
|
@@ -110,32 +119,34 @@ require ( | |
github.com/spf13/afero v1.11.0 // indirect | ||
github.com/spf13/cast v1.6.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/stoewer/go-strcase v1.2.0 // indirect | ||
github.com/stoewer/go-strcase v1.3.0 // indirect | ||
github.com/stretchr/objx v0.5.0 // indirect | ||
github.com/subosito/gotenv v1.6.0 // indirect | ||
github.com/ugorji/go/codec v1.2.12 // indirect | ||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect | ||
github.com/xdg-go/scram v1.1.2 // indirect | ||
github.com/xdg-go/stringprep v1.0.4 // indirect | ||
github.com/xlab/treeprint v1.2.0 // indirect | ||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect | ||
go.mongodb.org/mongo-driver v1.12.1 // indirect | ||
go.opentelemetry.io/otel v1.20.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.20.0 // indirect | ||
go.mongodb.org/mongo-driver v1.13.1 // indirect | ||
go.opentelemetry.io/otel v1.22.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.22.0 // indirect | ||
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect | ||
go.uber.org/multierr v1.11.0 // indirect | ||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect | ||
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect | ||
golang.org/x/mod v0.14.0 // indirect | ||
golang.org/x/net v0.19.0 // indirect | ||
golang.org/x/oauth2 v0.15.0 // indirect | ||
golang.org/x/net v0.20.0 // indirect | ||
golang.org/x/oauth2 v0.16.0 // indirect | ||
golang.org/x/sys v0.17.0 // indirect | ||
golang.org/x/term v0.17.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.5.0 // indirect | ||
google.golang.org/appengine v1.6.8 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect | ||
google.golang.org/grpc v1.59.0 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
google.golang.org/genproto v0.0.0-20240205150955-31a09d347014 // indirect | ||
google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect | ||
google.golang.org/grpc v1.61.0 // indirect | ||
google.golang.org/protobuf v1.32.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/ini.v1 v1.67.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking if we really need this as a cli flag. It's not something the end user would want to configure. Should we have it in build flags then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of this flag is to enable: