From 0f1191d3c7f8502f8789cba4bb5eea3fb11148ab Mon Sep 17 00:00:00 2001 From: Alex Steel <130377221+asteel-gsa@users.noreply.github.com> Date: Mon, 6 May 2024 13:53:27 -0400 Subject: [PATCH] Update to aws install command --- cmd/installaws.go | 34 ++++++++++++++++++++++++++++++++++ internal/util/paths.go | 2 +- main.go | 7 ------- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 cmd/installaws.go diff --git a/cmd/installaws.go b/cmd/installaws.go new file mode 100644 index 0000000..642abe2 --- /dev/null +++ b/cmd/installaws.go @@ -0,0 +1,34 @@ +/* +Copyright © 2024 NAME HERE +*/ +package cmd + +import ( + "fmt" + "os" + "slices" + + "github.com/spf13/cobra" + "gov.gsa.fac.cgov-util/internal/logging" + "gov.gsa.fac.cgov-util/internal/util" +) + +// installawsCmd represents the installaws command +var installawsCmd = &cobra.Command{ + Use: "installaws", + Short: "Install AWS CLI on cloud.gov instances", + Long: `Install AWS CLI on cloud.gov instances`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("Installing aws cli") + }, +} + +func init() { + rootCmd.AddCommand(installawsCmd) + if slices.Contains([]string{"DEV", "PREVIEW", "STAGING", "PRODUCTION"}, os.Getenv("ENV")) { + logging.Logger.Printf("ENV detected to be a cloud.gov environment. Installing AWS CLI.") + util.InstallAWS() + } else { + logging.Logger.Printf("ENV set to local or testing, aws not necessary to install.") + } +} diff --git a/internal/util/paths.go b/internal/util/paths.go index d35774a..01c7758 100644 --- a/internal/util/paths.go +++ b/internal/util/paths.go @@ -29,7 +29,7 @@ func SetPaths(env string) { PGDUMP_path = "/home/vcap/deps/0/apt/usr/lib/postgresql/15/bin/pg_dump" AWS_path = "/home/vcap/app/bin/aws" default: - logging.Logger.Println("No environment set, paths for executables were not set.") + logging.Logger.Println("ENV was not set, paths for executables have not been set.") os.Exit(-1) } } diff --git a/main.go b/main.go index 8e265f5..2f9e8ff 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "golang.org/x/exp/slices" "gov.gsa.fac.cgov-util/cmd" - "gov.gsa.fac.cgov-util/internal/logging" "gov.gsa.fac.cgov-util/internal/util" "gov.gsa.fac.cgov-util/internal/vcap" ) @@ -36,12 +35,6 @@ func readConfig() { } func main() { - if slices.Contains([]string{"DEV", "PREVIEW", "STAGING", "PRODUCTION"}, os.Getenv("ENV")) { - logging.Logger.Printf("ENV detected to be a cloud.gov environment. Installing AWS CLI.") - util.InstallAWS() - } else { - logging.Logger.Printf("ENV set to local, aws not necessary to install.") - } readConfig() util.SetPaths(os.Getenv("ENV")) cmd.Execute()