Skip to content

Commit

Permalink
Merge pull request #494 from weaveworks/ng-alias
Browse files Browse the repository at this point in the history
ng alias for nodegroup resource
  • Loading branch information
errordeveloper authored Jan 31, 2019
2 parents 28f9984 + 91b18a2 commit 652a024
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 29 deletions.
19 changes: 7 additions & 12 deletions pkg/ctl/cmdutils/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,21 @@ const (

// AddCommonCreateNodeGroupFlags adds common flags for creating a node group
func AddCommonCreateNodeGroupFlags(cmd *cobra.Command, fs *pflag.FlagSet, p *api.ProviderConfig, cfg *api.ClusterConfig, ng *api.NodeGroup) {
var desiredCapacity int
var minSize int
var maxSize int

fs.StringVarP(&ng.InstanceType, "node-type", "t", defaultNodeType, "node instance type")
fs.IntVarP(&desiredCapacity, "nodes", "N", api.DefaultNodeCount, "total number of nodes (for a static ASG)")

// TODO: https://github.com/weaveworks/eksctl/issues/28
fs.IntVarP(&minSize, "nodes-min", "m", api.DefaultNodeCount, "minimum nodes in ASG")
fs.IntVarP(&maxSize, "nodes-max", "M", api.DefaultNodeCount, "maximum nodes in ASG")
desiredCapacity := fs.IntP("nodes", "N", api.DefaultNodeCount, "total number of nodes (for a static ASG)")
minSize := fs.IntP("nodes-min", "m", api.DefaultNodeCount, "minimum nodes in ASG")
maxSize := fs.IntP("nodes-max", "M", api.DefaultNodeCount, "maximum nodes in ASG")

cmd.PreRun = func(cmd *cobra.Command, args[] string) {
cmd.PreRun = func(cmd *cobra.Command, args []string) {
if f := cmd.Flag("nodes"); f.Changed {
ng.DesiredCapacity = &desiredCapacity
ng.DesiredCapacity = desiredCapacity
}
if f := cmd.Flag("nodes-min"); f.Changed {
ng.MinSize= &minSize
ng.MinSize = minSize
}
if f := cmd.Flag("nodes-max"); f.Changed {
ng.MaxSize= &maxSize
ng.MaxSize = maxSize
}
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/ctl/create/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ func createNodeGroupCmd(g *cmdutils.Grouping) *cobra.Command {
ng := cfg.NewNodeGroup()

cmd := &cobra.Command{
Use: "nodegroup",
Short: "Create a nodegroup",
Use: "nodegroup",
Short: "Create a nodegroup",
Aliases: []string{"ng"},
Run: func(_ *cobra.Command, args []string) {
if err := doCreateNodeGroup(p, cfg, ng, cmdutils.GetNameArg(args)); err != nil {
logger.Critical("%s\n", err.Error())
Expand Down
5 changes: 3 additions & 2 deletions pkg/ctl/delete/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func deleteNodeGroupCmd(g *cmdutils.Grouping) *cobra.Command {
ng := cfg.NewNodeGroup()

cmd := &cobra.Command{
Use: "nodegroup",
Short: "Delete a nodegroup",
Use: "nodegroup",
Short: "Delete a nodegroup",
Aliases: []string{"ng"},
Run: func(_ *cobra.Command, args []string) {
if err := doDeleteNodeGroup(p, cfg, ng, cmdutils.GetNameArg(args)); err != nil {
logger.Critical("%s\n", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/ctl/get/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func getNodegroupCmd(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "nodegroup",
Short: "Get nodegroups(s)",
Aliases: []string{"nodegroups"},
Aliases: []string{"ng"},
Run: func(_ *cobra.Command, args []string) {
if err := doGetNodegroups(p, cfg, ng, cmdutils.GetNameArg(args)); err != nil {
logger.Critical("%s\n", err.Error())
Expand Down
12 changes: 6 additions & 6 deletions pkg/ctl/scale/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func scaleNodeGroupCmd(g *cmdutils.Grouping) *cobra.Command {
ng := cfg.NewNodeGroup()

cmd := &cobra.Command{
Use: "nodegroup",
Short: "Scale a nodegroup",
Use: "nodegroup",
Short: "Scale a nodegroup",
Aliases: []string{"ng"},
Run: func(_ *cobra.Command, args []string) {
if err := doScaleNodeGroup(p, cfg, ng, cmdutils.GetNameArg(args)); err != nil {
logger.Critical("%s\n", err.Error())
Expand All @@ -35,11 +36,10 @@ func scaleNodeGroupCmd(g *cmdutils.Grouping) *cobra.Command {
fs.StringVar(&cfg.Metadata.Name, "cluster", "", "EKS cluster name")
fs.StringVarP(&ng.Name, "name", "n", "", "Name of the nodegroup to scale")

var desiredCapacity int
fs.IntVarP(&desiredCapacity, "nodes", "N", -1, "total number of nodes (scale to this number)")
cmd.PreRun = func(cmd *cobra.Command, args[] string) {
desiredCapacity := fs.IntP("nodes", "N", -1, "total number of nodes (scale to this number)")
cmd.PreRun = func(cmd *cobra.Command, args []string) {
if f := cmd.Flag("nodes"); f.Changed {
ng.DesiredCapacity = &desiredCapacity
ng.DesiredCapacity = desiredCapacity
}
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/ctl/utils/wait_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ func waitNodesCmd(g *cmdutils.Grouping) *cobra.Command {

group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVar(&waitNodesKubeconfigPath, "kubeconfig", "kubeconfig", "path to read kubeconfig")
var minSize int
fs.IntVarP(&minSize, "nodes-min", "m", api.DefaultNodeCount, "minimum number of nodes to wait for")
cmd.PreRun = func(cmd *cobra.Command, args[] string) {
minSize := fs.IntP("nodes-min", "m", api.DefaultNodeCount, "minimum number of nodes to wait for")
cmd.PreRun = func(cmd *cobra.Command, args []string) {
if f := cmd.Flag("nodes-min"); f.Changed {
ng.MinSize = &minSize
ng.MinSize = minSize
}
}
fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "how long to wait")
Expand Down
2 changes: 0 additions & 2 deletions pkg/eks/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ func (c *ClusterProvider) CheckAuth() error {

// EnsureAMI ensures that the node AMI is set and is available
func (c *ClusterProvider) EnsureAMI(version string, ng *api.NodeGroup) error {
// TODO: https://github.com/weaveworks/eksctl/issues/28
// - improve validation of parameter set overall, probably in another package
if ng.AMI == ami.ResolverAuto {
ami.DefaultResolvers = []ami.Resolver{ami.NewAutoResolver(c.Provider.EC2())}
}
Expand Down

0 comments on commit 652a024

Please sign in to comment.