commands

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Generate = &cli.Command{
	Name:  "generate",
	Usage: "Generate AWS config",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "ssoURL",
			Aliases:  []string{"s"},
			Usage:    "AWS Single Sign On URL",
			Required: true,
		},
		&cli.StringFlag{
			Name:    "region",
			Aliases: []string{"r"},
			Usage:   "AWS Region used by SSO",
		},
	},
	Action: func(c *cli.Context) error {
		ssoURL := c.String("ssoURL")
		region := c.String("region")

		if c.String("region") == "" {
			region = "us-east-1"
		}

		var o string
		fmt.Print("Overwrite current config(~/.aws/config)[y/N]? ")
		_, err := fmt.Scanf("%s", &o)
		if err != nil {
			fmt.Println("Default option")
		}
		switch {
		case o == "y" || o == "Y":
			err := aws.GenerateConfig(ssoURL, region, true)
			if err != nil {
				log.Fatalf("Error to generate config file: %v", err)
			}
		case o == "n" || o == "N":
			err := aws.GenerateConfig(ssoURL, region, false)
			fmt.Println("You can use this profile values to update your config file(~/.aws/config)")
			if err != nil {
				log.Fatalf("Error to print config: %v", err)
			}
		default:
			err := aws.GenerateConfig(ssoURL, region, false)
			fmt.Println("You can use this profile values to update your config file(~/.aws/config)")
			if err != nil {
				log.Fatalf("Error to print config: %v", err)
			}
		}
		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL