Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate flag grouping with and abstraction #342

Merged
merged 2 commits into from
Dec 17, 2018
Merged

Automate flag grouping with and abstraction #342

merged 2 commits into from
Dec 17, 2018

Conversation

errordeveloper
Copy link
Contributor

@errordeveloper errordeveloper commented Dec 8, 2018

Description

This is a follow-up to @mumoshu's change, allowing us to easily implement flag grouping for all commands. This is also changes the grouping itself (as discussed in #328), and introduces a custom function for rendering the usage text, so we are in full control of it.

Checklist

  • Code compiles correctly (i.e make build)
  • All tests passing (i.e. make test)

@errordeveloper
Copy link
Contributor Author

Sample output:

 [0] >> ./eksctl --help
a CLI for Amazon EKS

Usage: eksctl [command] [flags]

Commands:
  eksctl completion  Generates shell completion scripts
  eksctl create      Create resource(s)
  eksctl delete      Delete resource(s)
  eksctl get         Get resource(s)
  eksctl help        Help about any command
  eksctl scale       Scale resources(s)
  eksctl utils       Various utils
  eksctl version     Output the version of eksctl

Common flags:
  -C, --color         toggle colorized logs (default true)
  -h, --help          help for this command
  -v, --verbose int   set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl [command] --help' for more information about a command.
 [0] >> ./eksctl create --help
Create resource(s)

Usage: eksctl create [flags]

Commands:
  eksctl create cluster     Create a cluster

Common flags:
  -C, --color         toggle colorized logs (default true)
  -h, --help          help for this command
  -v, --verbose int   set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl create [command] --help' for more information about a command.
 [0] >> ./eksctl create cluster --help
Create a cluster

Usage: eksctl create cluster [flags]

General flags:
  -n, --name string           EKS cluster name (generated if unspecified, e.g. "amazing-painting-1544261926")
      --tags stringToString   A list of KV pairs used to tag the AWS resources (e.g. "Owner=John Doe,Team=Some Team") (default [])
      --zones strings         (auto-select if unspecified)
  -r, --region string         AWS region

Initial nodegroup flags:
  -t, --node-type string          node instance type (default "m5.large")
  -N, --nodes int                 total number of nodes (desired capacity of ASG) (default 2)
  -m, --nodes-min int             minimum nodes in ASG (leave unset for a static nodegroup)
  -M, --nodes-max int             maximum nodes in ASG (leave unset for a static nodegroup)
      --node-volume-size int      Node volume size (in GB)
      --max-pods-per-node int     maximum number of pods per node (set automatically if unspecified)
      --ssh-access                control SSH access for nodes
      --ssh-public-key string     SSH public key to use for nodes (import from local path, or use existing EC2 key pair) (default "~/.ssh/id_rsa.pub")
      --node-ami string           Advanced use cases only. If 'static' is supplied (default) then eksctl will use static AMIs; if 'auto' is supplied then eksctl will automatically set the AMI based on region/instance type; if any other value is supplied it will override the AMI to use for the nodes. Use with extreme care. (default "static")
      --node-ami-family string    Advanced use cases only. If 'AmazonLinux2' is supplied (default), then eksctl will use the offical AWS EKS AMIs (Amazon Linux 2); if 'Ubuntu1804' is supplied, then eksctl will use the offical Canonical EKS AMIs (Ubuntu 18.04). (default "AmazonLinux2")
  -P, --node-private-networking   whether to make initial nodegroup networking private

Cluster add-ons flags:
      --full-ecr-access   enable full access to ECR
      --asg-access        enable iam policy dependency for cluster-autoscaler
      --storage-class     if true (default) then a default StorageClass of type gp2 provisioned by EBS will be created (default true)

VPC networking flags:
      --vpc-from-kops-cluster string   re-use VPC from a given kops cluster
      --vpc-cidr ipNet                 global CIDR to use for VPC (default 192.168.0.0/16)
      --vpc-private-subnets strings    re-use private subnets of an existing VPC
      --vpc-public-subnets strings     re-use public subnets of an existing VPC

AWS client flags:
  -p, --profile string     AWS credentials profile to use (overrides the AWS_PROFILE environment variable)
      --timeout duration   max wait time in any polling operations (default 20m0s)

Output kubeconfig flags:
      --write-kubeconfig         toggle writing of kubeconfig (default true)
      --auto-kubeconfig          save kubeconfig file by cluster name, e.g. "/Users/ilya/.kube/eksctl/clusters/amazing-painting-1544261926"
      --kubeconfig string        path to write kubeconfig (incompatible with --auto-kubeconfig) (default "/Users/ilya/.kube/config")
      --set-kubeconfig-context   if true then current-context will be set in kubeconfig; if a context is already set then it will be overwritten (default true)

Common flags:
  -C, --color         toggle colorized logs (default true)
  -h, --help          help for this command
  -v, --verbose int   set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging (default 3)

Use 'eksctl create cluster [command] --help' for more information about a command.
 [0] >> 

rootCmd.PersistentFlags().IntVarP(&logger.Level, "verbose", "v", 3, "set log level, use 0 to silence, 4 for debugging and 5 for debugging with AWS debug logging")
rootCmd.PersistentFlags().BoolVarP(&logger.Color, "color", "C", true, "toggle colorized logs")

rootCmd.SetUsageFunc(g.Usage)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to set this here, setting it at each subcommand's level doesn't actually work, although it's not clear why from the implementation.

@errordeveloper errordeveloper force-pushed the fix-298 branch 3 times, most recently from ffd4fe3 to 9a81392 Compare December 10, 2018 13:26
@errordeveloper errordeveloper force-pushed the fix-298 branch 2 times, most recently from 3492179 to 8836783 Compare December 17, 2018 11:22
@errordeveloper errordeveloper changed the title WIP: Automate flag grouping with and abstraction Automate flag grouping with and abstraction Dec 17, 2018
stefanprodan
stefanprodan previously approved these changes Dec 17, 2018
Copy link
Contributor

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants