commands

package
v0.0.0-...-4eb781d Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UpdateCmd = &cobra.Command{
	Use:   "update [type] [env] [services ...]",
	Short: "Update the branch and commit for a selection of services, lambdas, or cloudfront distributions",
	Long:  "Please read the README.md file",
	Example: strings.Join([]string{
		"update service avocado sms email -b extra-logging",
		"update lambda basil ltm-proxy",
		"update service prod email --prod",
		"update cloudfront prod website --prod",
	}, "\n"),
	Aliases: []string{"u"},
	Args:    updateArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := context.Background()

		branch, err := cmd.Flags().GetString("branch")
		if err != nil {
			return err
		}

		useProd, err := cmd.Flags().GetBool("prod")
		if err != nil {
			return err
		}

		dryRun, err := cmd.Flags().GetBool("dry-run")
		if err != nil {
			return nil
		}

		message, err := cmd.Flags().GetString("message")
		if err != nil {
			return err
		}

		params, err := parsers.Parse(args, branch, useProd, message)
		if err != nil {
			return err
		}

		awsSession, err := session.NewSessionWithOptions(session.Options{
			Profile: "root",
			Config: aws.Config{
				Region:      ptr.String("eu-west-1"),
				Credentials: config.AWS{}.Credentials(),
			},
		})
		if err != nil {
			return errors.Wrap(err, "aws:")
		}

		sns := sns.New(awsSession)

		a := &app.App{
			DryRun: dryRun,
			SNS:    sns,
		}

		overruleChecks, err := cmd.Flags().GetStringSlice("overrule-checks")
		if err != nil {
			return err
		}

		return a.Update(ctx, params, overruleChecks)
	},
}

UpdateCmd is the initiator for the update command

View Source
var UpdateDefaultCmd = &cobra.Command{
	Use:   "update-default [type] [env]",
	Short: "Update the default commit for all services or lambdas",
	Long:  "Please read the README.md file",
	Example: strings.Join([]string{
		"update-default services avocado",
		"update-default lambda all",
	}, "\n"),
	Args: updateDefaultArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := context.Background()

		useProd, err := cmd.Flags().GetBool("prod")
		if err != nil {
			return err
		}

		dryRun, err := cmd.Flags().GetBool("dry-run")
		if err != nil {
			return nil
		}

		message, err := cmd.Flags().GetString("message")
		if err != nil {
			return err
		}

		params, err := parsers.Parse(args, cdep.DefaultBranch, useProd, message)
		if err != nil {
			return err
		}

		awsSession, err := session.NewSessionWithOptions(session.Options{
			Profile: "root",
			Config: aws.Config{
				Region:      ptr.String("eu-west-1"),
				Credentials: config.AWS{}.Credentials(),
			},
		})
		if err != nil {
			return errors.Wrap(err, "aws:")
		}

		sns := sns.New(awsSession)

		a := &app.App{
			DryRun: dryRun,
			SNS:    sns,
		}

		overruleChecks, err := cmd.Flags().GetStringSlice("overrule-checks")
		if err != nil {
			return err
		}

		return a.UpdateDefault(ctx, params, overruleChecks)
	},
}

UpdateDefaultCmd is the update-default command

View Source
var UpdateWebCmd = &cobra.Command{
	Use:   "update-web [type] [env] [services ...]",
	Short: "Update the deployment identifier for web applications ",
	Long:  "Please read the README.md file",
	Example: strings.Join([]string{
		"update-web cloudfront all website",
		"uw cf prod website --prod",
		"uw cf prod website -b new-landing-page --prod",
	}, "\n"),
	Aliases: []string{"uw"},
	Args:    updateWebArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := context.Background()

		branch, err := cmd.Flags().GetString("branch")
		if err != nil {
			return err
		}

		useProd, err := cmd.Flags().GetBool("prod")
		if err != nil {
			return err
		}

		dryRun, err := cmd.Flags().GetBool("dry-run")
		if err != nil {
			return nil
		}

		params, err := parsers.ParseWeb(args, branch, useProd)
		if err != nil {
			return err
		}

		a := &app.App{
			DryRun: dryRun,
		}

		overruleChecks, err := cmd.Flags().GetStringSlice("overrule-checks")
		if err != nil {
			return err
		}

		return a.UpdateWeb(ctx, params, overruleChecks)
	},
}

UpdateWebCmd is the initiator for the update command

View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print the version number of cdep",
	Long:  "All software has versions.",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("cdep v%s\n", cdep.Version)
	},
}

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