mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 05:54:28 -04:00
cli: rename upgrade execute
to upgrade apply
This commit is contained in:
parent
109177880e
commit
91e27ac186
3 changed files with 20 additions and 20 deletions
|
@ -20,7 +20,7 @@ func NewUpgradeCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.AddCommand(newUpgradeCheckCmd())
|
cmd.AddCommand(newUpgradeCheckCmd())
|
||||||
cmd.AddCommand(newUpgradeExecuteCmd())
|
cmd.AddCommand(newUpgradeApplyCmd())
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newUpgradeExecuteCmd() *cobra.Command {
|
func newUpgradeApplyCmd() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "execute",
|
Use: "execute",
|
||||||
Short: "Execute an upgrade of a Constellation cluster",
|
Short: "Apply an upgrade to a Constellation cluster",
|
||||||
Long: "Execute an upgrade of a Constellation cluster by applying the chosen configuration.",
|
Long: "Apply an upgrade to a Constellation cluster by applying the chosen configuration.",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: runUpgradeExecute,
|
RunE: runUpgradeApply,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().Bool("helm", false, "execute helm upgrade\n"+
|
cmd.Flags().Bool("helm", false, "execute helm upgrade\n"+
|
||||||
|
@ -47,7 +47,7 @@ func newUpgradeExecuteCmd() *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func runUpgradeExecute(cmd *cobra.Command, args []string) error {
|
func runUpgradeApply(cmd *cobra.Command, args []string) error {
|
||||||
log, err := newCLILogger(cmd)
|
log, err := newCLILogger(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating logger: %w", err)
|
return fmt.Errorf("creating logger: %w", err)
|
||||||
|
@ -61,11 +61,11 @@ func runUpgradeExecute(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return upgradeExecute(cmd, imageFetcher, upgrader, fileHandler)
|
return upgradeApply(cmd, imageFetcher, upgrader, fileHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func upgradeExecute(cmd *cobra.Command, imageFetcher imageFetcher, upgrader cloudUpgrader, fileHandler file.Handler) error {
|
func upgradeApply(cmd *cobra.Command, imageFetcher imageFetcher, upgrader cloudUpgrader, fileHandler file.Handler) error {
|
||||||
flags, err := parseUpgradeExecuteFlags(cmd)
|
flags, err := parseUpgradeApplyFlags(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("parsing flags: %w", err)
|
return fmt.Errorf("parsing flags: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -110,36 +110,36 @@ func upgradeExecute(cmd *cobra.Command, imageFetcher imageFetcher, upgrader clou
|
||||||
return upgrader.Upgrade(cmd.Context(), imageReference, conf.Upgrade.Image, conf.Upgrade.Measurements)
|
return upgrader.Upgrade(cmd.Context(), imageReference, conf.Upgrade.Image, conf.Upgrade.Measurements)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseUpgradeExecuteFlags(cmd *cobra.Command) (upgradeExecuteFlags, error) {
|
func parseUpgradeApplyFlags(cmd *cobra.Command) (upgradeApplyFlags, error) {
|
||||||
configPath, err := cmd.Flags().GetString("config")
|
configPath, err := cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return upgradeExecuteFlags{}, err
|
return upgradeApplyFlags{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
helmFlag, err := cmd.Flags().GetBool("helm")
|
helmFlag, err := cmd.Flags().GetBool("helm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return upgradeExecuteFlags{}, err
|
return upgradeApplyFlags{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
yes, err := cmd.Flags().GetBool("yes")
|
yes, err := cmd.Flags().GetBool("yes")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return upgradeExecuteFlags{}, err
|
return upgradeApplyFlags{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout, err := cmd.Flags().GetDuration("timeout")
|
timeout, err := cmd.Flags().GetDuration("timeout")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return upgradeExecuteFlags{}, err
|
return upgradeApplyFlags{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
force, err := cmd.Flags().GetBool("force")
|
force, err := cmd.Flags().GetBool("force")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return upgradeExecuteFlags{}, fmt.Errorf("parsing force argument: %w", err)
|
return upgradeApplyFlags{}, fmt.Errorf("parsing force argument: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return upgradeExecuteFlags{configPath: configPath, helmFlag: helmFlag, yes: yes, upgradeTimeout: timeout, force: force}, nil
|
return upgradeApplyFlags{configPath: configPath, helmFlag: helmFlag, yes: yes, upgradeTimeout: timeout, force: force}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type upgradeExecuteFlags struct {
|
type upgradeApplyFlags struct {
|
||||||
configPath string
|
configPath string
|
||||||
helmFlag bool
|
helmFlag bool
|
||||||
yes bool
|
yes bool
|
|
@ -22,7 +22,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpgradeExecute(t *testing.T) {
|
func TestUpgradeApply(t *testing.T) {
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
upgrader stubUpgrader
|
upgrader stubUpgrader
|
||||||
imageFetcher stubImageFetcher
|
imageFetcher stubImageFetcher
|
||||||
|
@ -49,7 +49,7 @@ func TestUpgradeExecute(t *testing.T) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
cmd := newUpgradeExecuteCmd()
|
cmd := newUpgradeApplyCmd()
|
||||||
cmd.Flags().String("config", constants.ConfigFilename, "") // register persistent flag manually
|
cmd.Flags().String("config", constants.ConfigFilename, "") // register persistent flag manually
|
||||||
cmd.Flags().Bool("force", true, "") // register persistent flag manually
|
cmd.Flags().Bool("force", true, "") // register persistent flag manually
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ func TestUpgradeExecute(t *testing.T) {
|
||||||
cfg := defaultConfigWithExpectedMeasurements(t, config.Default(), cloudprovider.Azure)
|
cfg := defaultConfigWithExpectedMeasurements(t, config.Default(), cloudprovider.Azure)
|
||||||
require.NoError(handler.WriteYAML(constants.ConfigFilename, cfg))
|
require.NoError(handler.WriteYAML(constants.ConfigFilename, cfg))
|
||||||
|
|
||||||
err := upgradeExecute(cmd, &tc.imageFetcher, tc.upgrader, handler)
|
err := upgradeApply(cmd, &tc.imageFetcher, tc.upgrader, handler)
|
||||||
if tc.wantErr {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
} else {
|
} else {
|
Loading…
Add table
Add a link
Reference in a new issue