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/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) diff --git a/cmd/cloudexec/main.go b/cmd/cloudexec/main.go index 5947c13..b7d7ea3 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,12 @@ func main() { return configErr } // Check if a local cloudexec.toml exists - 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") - } - LaunchConfigFilePath = c.Args().Get(0) + launchConfigFilePath := c.String("config") + if _, err := os.Stat(launchConfigFilePath); os.IsNotExist(err) { + 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) + lc, err := LoadLaunchConfig(launchConfigFilePath) if err != nil { return err } @@ -129,7 +126,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 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{}) {