Skip to content

Commit

Permalink
Add --config-file/-f to eksctl update cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed Mar 13, 2019
1 parent 7438b7b commit 16cc5b1
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions pkg/ctl/update/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
var (
updateClusterDryRun = true
updateClusterWait = true
clusterConfigFile string
)

func updateClusterCmd(g *cmdutils.Grouping) *cobra.Command {
Expand All @@ -29,8 +30,8 @@ func updateClusterCmd(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "cluster",
Short: "Update cluster",
Run: func(_ *cobra.Command, args []string) {
if err := doUpdateClusterCmd(p, cfg, cmdutils.GetNameArg(args)); err != nil {
Run: func(cmd *cobra.Command, args []string) {
if err := doUpdateClusterCmd(p, cfg, cmdutils.GetNameArg(args), cmd); err != nil {
logger.Critical("%s\n", err.Error())
os.Exit(1)
}
Expand All @@ -42,6 +43,8 @@ func updateClusterCmd(g *cmdutils.Grouping) *cobra.Command {
group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)")
cmdutils.AddRegionFlag(fs, p)
cmdutils.AddConfigFileFlag(&clusterConfigFile, fs)

// cmdutils.AddVersionFlag(fs, cfg.Metadata, `"next" and "latest" can be used to automatically increment version by one, or force latest`)
fs.BoolVar(&updateClusterDryRun, "dry-run", updateClusterDryRun, "do not apply any change, only show what resources would be added")
cmdutils.AddWaitFlag(&updateClusterWait, fs, "all update operations to complete")
Expand All @@ -53,31 +56,24 @@ func updateClusterCmd(g *cmdutils.Grouping) *cobra.Command {
return cmd
}

func doUpdateClusterCmd(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg string) error {
if cfg.Metadata.Name != "" && nameArg != "" {
return fmt.Errorf("--name=%s and argument %s cannot be used at the same time", cfg.Metadata.Name, nameArg)
}

if nameArg != "" {
cfg.Metadata.Name = nameArg
func doUpdateClusterCmd(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg string, cmd *cobra.Command) error {
if err := api.Register(); err != nil {
return err
}

if cfg.Metadata.Name == "" {
return fmt.Errorf("--name must be set")
if err := cmdutils.LoadMetadata(p, cfg, clusterConfigFile, nameArg, cmd); err != nil {
return err
}

ctl := eks.New(p, cfg)

if !ctl.IsSupportedRegion() {
return cmdutils.ErrUnsupportedRegion(p)
}
logger.Info("using region %s", cfg.Metadata.Region)
meta := cfg.Metadata

printer := printers.NewJSONPrinter()

if err := api.Register(); err != nil {
return err
if !ctl.IsSupportedRegion() {
return cmdutils.ErrUnsupportedRegion(p)
}
logger.Info("using region %s", meta.Region)

if err := ctl.CheckAuth(); err != nil {
return err
Expand All @@ -87,6 +83,10 @@ func doUpdateClusterCmd(p *api.ProviderConfig, cfg *api.ClusterConfig, nameArg s
return errors.Wrapf(err, "getting credentials for cluster %q", cfg.Metadata.Name)
}

if clusterConfigFile != "" {
logger.Warning("NOTE: config file is only used for finding cluster name and region, deep cluster configuration changes are not yet implemented")
}

currentVersion := ctl.ControlPlaneVersion()
// determine next version based on what's currently deployed
switch currentVersion {
Expand Down

0 comments on commit 16cc5b1

Please sign in to comment.