cmd

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigureCmd = &cobra.Command{
	Use:   "configure",
	Short: "Creates an s3 bucket for the aws-switch state to reside",
	Run: func(cmd *cobra.Command, args []string) {

		bucket, err := lib.Configure()
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		} else {
			fmt.Printf("Created and configured bucket \"s3://%s\"\n", bucket)
		}
	},
}
View Source
var HaltCmd = &cobra.Command{
	Use:   "halt",
	Short: "Halt an aws service",
	Run: func(cmd *cobra.Command, args []string) {

		if len(tagsInput) == 0 {
			fmt.Println("--tags required")
			os.Exit(1)
		}

		tags, err := parseTagsFlag(tagsInput)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		services, err := lib.GetAWSServices(tags)
		if err != nil {
			fmt.Printf("Error getting services: %s\n", err)
			os.Exit(1)
		}

		fmt.Printf("Services to halt: \n\n")
		for _, service := range services {
			fmt.Println(service.GetARN())
		}

		fmt.Println()
		if !autoApprove {
			if _, err = confirmationPrompt.Run(); err != nil {
				fmt.Printf("No changes applied. %v\n", err)
				os.Exit(0)
			}
		}

		for _, service := range services {
			err := lib.Halt(service)
			if err != nil {
				fmt.Printf("Error halting service: %s\n", service.GetARN())
				os.Exit(1)
			} else {
				fmt.Printf("Halting service: %s\n", service.GetARN())
			}
		}
	},
}
View Source
var ResumeCmd = &cobra.Command{
	Use:   "resume",
	Short: "Resume a halted aws service",
	Run: func(cmd *cobra.Command, args []string) {

		if len(tagsInput) == 0 {
			fmt.Println("--tags required")
			os.Exit(1)
		}

		tags, err := parseTagsFlag(tagsInput)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}

		services, err := lib.GetAWSServices(tags)
		if err != nil {
			fmt.Printf("Error getting services: %s\n", err)
			os.Exit(1)
		}

		fmt.Printf("Services to resume: \n\n")
		for _, service := range services {
			fmt.Println(service.GetARN())
		}

		fmt.Println()
		if !autoApprove {
			if _, err = confirmationPrompt.Run(); err != nil {
				fmt.Printf("No changes applied. %v\n", err)
				os.Exit(0)
			}
		}

		for _, service := range services {
			err := lib.Resume(service)
			if err != nil {
				fmt.Printf("Error resuming service: %s\n", service.GetARN())
				os.Exit(1)
			} else {
				fmt.Printf("Resuming service: %s\n", service.GetARN())
			}
		}
	},
}

Functions

func Import

func Import(rootCmd *cobra.Command)

Import is used to import all of these package's commands

Types

This section is empty.

Jump to

Keyboard shortcuts

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