commands

package
v0.15.14 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateCommand = cli.Command{
	Name:        "create",
	Usage:       "Create a new Common Fate deployment by deploying CloudFormation",
	Description: "Create a new Common Fate deployment based on a deployment configuration file (deployment.yml by default). Deploys resources to AWS using CloudFormation.",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "confirm", Aliases: []string{"y"}, Usage: "If provided, will automatically deploy without asking for confirmation"},
	},
	Action: func(c *cli.Context) error {
		ctx := c.Context

		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}

		clio.Infof("Deploying Common Fate %s", dc.Deployment.Release)
		clio.Infof("Using template: %s", dc.CfnTemplateURL())
		clio.Warn("Your initial deployment will take approximately 5 minutes while CloudFront resources are created. (At worst this can take up to 25 minutes)\nSubsequent updates should take less time.")
		confirm := c.Bool("confirm")

		if os.Getenv("CI") == "true" {
			clio.Debug("CI env var is set to 'true', skipping confirmation prompt")
			confirm = true
		}

		status, err := dc.DeployCloudFormation(ctx, confirm)
		if err != nil {
			return err
		}
		o, err := dc.LoadOutput(ctx)

		if err != nil {
			return err
		}

		if status == "CREATE_COMPLETE" {
			clio.Success("Your Common Fate deployment has been created")
			o.PrintTable()

			clio.Info(`Here are your next steps to get started:

  1) create an admin user so you can log in: 'gdeploy identity users create --admin -u YOUR_EMAIL_ADDRESS'
  2) visit the web dashboard: 'gdeploy dashboard open'
  3) visit the Providers tab in the admin dashboard and setup your first Access Provider using the interactive workflows


Check out the next steps in our getting started guide for more information: https://docs.commonfate.io/granted-approvals/getting-started/deploying
`)
		} else {
			clio.Warnf("Creating your Common Fate deployment failed with a final status: %s", status)
			return nil
		}

		return nil
	},
}
View Source
var InitCommand = cli.Command{
	Name:        "init",
	Description: "Set up a new Common Fate deployment configuration file",
	Usage:       "Set up a new Common Fate deployment configuration file",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "overwrite", Usage: "Force an existing deployment configuration file to be overwritten"},
		&cli.StringFlag{Name: "name", Usage: "The name of the CloudFormation stack to create"},
		&cli.StringFlag{Name: "account", Usage: "The account ID to deploy to"},
		&cli.StringFlag{Name: "region", Usage: "The region to deploy to"},
		&cli.StringFlag{Name: "version", Usage: "The version to deploy"},
		&cli.StringFlag{Name: "cognito-domain-prefix", Usage: "The prefix for the Cognito Sign in URL"},
	},
	Action: func(c *cli.Context) error {
		err := ensureConfigDoesntExist(c)
		if err != nil {
			return err
		}

		err = internal.PrintAnalyticsNotice(true)
		if err != nil {
			clio.Debugf("error printing analytics notice: %s", err)
		}

		cfg, err := deploy.SetupReleaseConfig(c)
		if err != nil {
			return err
		}

		f := c.Path("file")

		err = cfg.Save(f)
		if err != nil {
			return err
		}

		clio.Successf("Wrote config to %s", f)
		clio.Warn("Nothing has been deployed yet. To finish deploying Common Fate, run 'gdeploy create' to create the CloudFormation stack in AWS.")
		return nil
	},
}
View Source
var Login = cli.Command{
	Name:  "login",
	Usage: "Log in to Common Fate",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "lazy", Usage: "the lazy flag lets granted decide whether a new login flow should be initiated based on the token expiry"},
	},
	Action: defaultLoginFlow.LoginAction,
}
View Source
var Logout = cli.Command{
	Name:  "logout",
	Usage: "Log out of Common Fate",
	Action: func(c *cli.Context) error {
		cfg, err := cliconfig.Load()
		if err != nil {
			return err
		}

		ts := tokenstore.New(cfg.CurrentContext)
		err = ts.Clear()
		if err != nil {
			return err
		}

		clio.Success("logged out")

		return nil
	},
}
View Source
var Output = cli.Command{
	Name:        "output",
	Aliases:     []string{"outputs"},
	Description: "Get an output value from your Common Fate deployment",
	Usage:       "Get an output value from your Common Fate deployment",
	ArgsUsage:   "<key>",
	Action: func(c *cli.Context) error {
		ctx := c.Context

		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}
		o, err := dc.LoadOutput(ctx)
		if err != nil {
			return err
		}

		key := c.Args().First()
		if key == "" {
			return errors.New("usage: gdeploy output <key>")
		}
		val, err := o.Get(key)
		if err != nil {
			return fmt.Errorf("%s. available keys: %s", err.Error(), strings.Join(o.Keys(), ", "))
		}
		fmt.Println(val)
		return nil
	},
}
View Source
var StatusCommand = cli.Command{
	Name:        "status",
	Description: "Check the status of a Common Fate deployment",
	Usage:       "Check the status of a Common Fate deployment",
	Action: func(c *cli.Context) error {
		ctx := c.Context

		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}

		o, err := dc.LoadOutput(ctx)
		if err != nil {
			return err
		}
		o.PrintTable()

		ss, err := dc.GetStackStatus(ctx)

		if err != nil {
			return err
		}

		clio.Infof("Cloudformation stack status: %s", ss)

		return nil
	},
}
View Source
var UpdateCommand = cli.Command{
	Name:        "update",
	Usage:       "Update a Common Fate deployment CloudFormation stack",
	Description: "Update Common Fate deployment based on a deployment configuration file (deployment.yml by default). Deploys resources to AWS using CloudFormation.",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "confirm", Aliases: []string{"y"}, Usage: "If provided, will automatically deploy without asking for confirmation"},
	},
	Action: func(c *cli.Context) error {
		ctx := c.Context
		dc, err := deploy.ConfigFromContext(ctx)
		if err != nil {
			return err
		}

		clio.Infof("Deploying Common Fate %s", dc.Deployment.Release)
		clio.Infof("Using template: %s", dc.CfnTemplateURL())
		confirm := c.Bool("confirm")

		if os.Getenv("CI") == "true" {
			clio.Debug("CI env var is set to 'true', skipping confirmation prompt")
			confirm = true
		}

		status, err := dc.DeployCloudFormation(ctx, confirm)
		if err != nil {
			return err
		}
		o, err := dc.LoadOutput(ctx)

		if err != nil {
			return err
		}

		if status == "UPDATE_COMPLETE" {
			o.PrintTable()
			clio.Success("Your Common Fate deployment has been updated")
		} else if status == "DEPLOY_SKIPPED" {

			return nil

		} else {
			clio.Warnf("Your Common Fate deployment update ended in status %s", status)
		}

		return nil
	},
}

Functions

This section is empty.

Types

type LoginFlow added in v0.15.11

type LoginFlow struct {
	// Keyring optionally overrides the keyring that auth tokens are saved to.
	Keyring keyring.Keyring
	// ForceInteractive forces the survey prompt to appear
	ForceInteractive bool
}

func (LoginFlow) LoginAction added in v0.15.11

func (lf LoginFlow) LoginAction(c *cli.Context) error

Jump to

Keyboard shortcuts

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