From bcd6144e17c00cfc5911bb2458fe09f2ba72363b Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 26 Jul 2024 13:53:10 -0400 Subject: [PATCH 1/4] brighten white logs --- pkg/log/log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/log/log.go b/pkg/log/log.go index c8d2db4..7ae3351 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -10,7 +10,7 @@ const ( ColorGreen = "\033[32m" ColorBlue = "\033[34m" ColorYellow = "\033[33m" - ColorWhite = "\033[37m" + ColorWhite = "\033[97m" ) func Info(msg string, args ...interface{}) { From 8bc0dd4d697f6a6c244faf142fb6041fe2ec345f Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 26 Jul 2024 16:00:50 -0400 Subject: [PATCH 2/4] add '/' to the end of the bucket deletion prefix --- cmd/cloudexec/clean.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/cloudexec/clean.go b/cmd/cloudexec/clean.go index 751cf41..46f0d10 100644 --- a/cmd/cloudexec/clean.go +++ b/cmd/cloudexec/clean.go @@ -12,7 +12,7 @@ import ( ) func CleanJob(config config.Config, existingState *state.State, jobID int64, force bool) error { - prefix := fmt.Sprintf("job-%v", jobID) + prefix := fmt.Sprintf("job-%v/", jobID) objects, err := s3.ListObjects(config, prefix) if err != nil { return fmt.Errorf("Failed to list objects in bucket with prefix %s: %w", prefix, err) From 1595eb83b93322ba1ada9bbbb4e1a91d76ce19e6 Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 26 Jul 2024 16:23:02 -0400 Subject: [PATCH 3/4] use flag to get launch config path instead of positional param --- cmd/cloudexec/cancel.go | 2 +- cmd/cloudexec/main.go | 21 +++++++++++---------- justfile | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/cloudexec/cancel.go b/cmd/cloudexec/cancel.go index b095219..d256291 100644 --- a/cmd/cloudexec/cancel.go +++ b/cmd/cloudexec/cancel.go @@ -13,7 +13,7 @@ import ( func CancelJob(config config.Config, existingState *state.State, job *state.Job, force bool) error { if job.Status != state.Provisioning && job.Status != state.Running { log.Info("Job %v is not running, it is %s", job.ID, job.Status) - return nil + return nil } log.Warn("Destroying droplet %s associated with job %v: IP=%v | CreatedAt=%s", job.Droplet.Name, job.ID, job.Droplet.IP, job.Droplet.Created) if !force { // Ask for confirmation before cleaning this job if no force flag diff --git a/cmd/cloudexec/main.go b/cmd/cloudexec/main.go index 5947c13..14254e6 100644 --- a/cmd/cloudexec/main.go +++ b/cmd/cloudexec/main.go @@ -14,11 +14,10 @@ import ( ) var ( - Version = "dev" - Commit = "none" - Date = "unknown" - ConfigFilePath = fmt.Sprintf("%s/.config/cloudexec/config.toml", os.Getenv("HOME")) - LaunchConfigFilePath = "./cloudexec.toml" + Version = "dev" + Commit = "none" + Date = "unknown" + ConfigFilePath = fmt.Sprintf("%s/.config/cloudexec/config.toml", os.Getenv("HOME")) ) func main() { @@ -90,6 +89,7 @@ func main() { Flags: []cli.Flag{ &cli.StringFlag{ Name: "config", + Value: "./cloudexec.toml", // default config filepath Usage: "cloudexec.toml file path", }, &cli.StringFlag{ @@ -109,15 +109,16 @@ func main() { return configErr } // Check if a local cloudexec.toml exists - if _, err := os.Stat(LaunchConfigFilePath); os.IsNotExist(err) { + launchConfigFilePath := c.String("config") + if _, err := os.Stat(launchConfigFilePath); os.IsNotExist(err) { // Check if the path to a launch config is provided if c.Args().Len() < 1 { - return fmt.Errorf("please provide a path to a cloudexec.toml file or create one in the current directory") + return fmt.Errorf("please create cloudexec.toml with 'cloudexec init' or use the '--config' flag to provide a path to your custom launch config file") } - LaunchConfigFilePath = c.Args().Get(0) + launchConfigFilePath = c.String("config") } // Load the launch configuration - lc, err := LoadLaunchConfig(LaunchConfigFilePath) + lc, err := LoadLaunchConfig(launchConfigFilePath) if err != nil { return err } @@ -129,7 +130,7 @@ func main() { return err } err = Launch(config, dropletSize, dropletRegion, lc) - return err + return err }, }, diff --git a/justfile b/justfile index 3b055af..78f07f5 100644 --- a/justfile +++ b/justfile @@ -5,7 +5,7 @@ fmt: go fmt pkg/ssh/*.go go fmt pkg/state/*.go -trunk: +trunk: fmt trunk fmt trunk check From 979c56774b3d8de6a958cefb7639b0b0944d2346 Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 26 Jul 2024 16:46:24 -0400 Subject: [PATCH 4/4] rm old positional arg logic from config flag check --- cmd/cloudexec/main.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cmd/cloudexec/main.go b/cmd/cloudexec/main.go index 14254e6..b7d7ea3 100644 --- a/cmd/cloudexec/main.go +++ b/cmd/cloudexec/main.go @@ -111,11 +111,7 @@ func main() { // Check if a local cloudexec.toml exists launchConfigFilePath := c.String("config") if _, err := os.Stat(launchConfigFilePath); os.IsNotExist(err) { - // Check if the path to a launch config is provided - if c.Args().Len() < 1 { - return fmt.Errorf("please create cloudexec.toml with 'cloudexec init' or use the '--config' flag to provide a path to your custom launch config file") - } - launchConfigFilePath = c.String("config") + return fmt.Errorf("please create cloudexec.toml with 'cloudexec init' or use the '--config' flag to provide a path to your custom launch config file") } // Load the launch configuration lc, err := LoadLaunchConfig(launchConfigFilePath)