From f7f821cb3cbe5e15ef0b91f273d41d3e670905be Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Mon, 15 Apr 2024 16:05:55 -0700 Subject: [PATCH] DEV: convert skip version check to CLI arg. preseve setting in env. --- launcher_go/v2/cli_runtime.go | 10 +++++----- launcher_go/v2/cli_runtime_test.go | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/launcher_go/v2/cli_runtime.go b/launcher_go/v2/cli_runtime.go index c22c1ba78..bf6f4f7d1 100644 --- a/launcher_go/v2/cli_runtime.go +++ b/launcher_go/v2/cli_runtime.go @@ -12,7 +12,6 @@ import ( "os" "os/exec" "runtime" - "slices" "strings" "syscall" "time" @@ -224,14 +223,15 @@ func (r *LogsCmd) Run(cli *Cli, ctx *context.Context) error { } type RebuildCmd struct { - Config string `arg:"" name:"config" help:"config" predictor:"config"` - FullBuild bool `name:"full-build" help:"Run a full build image even when migrate on boot and precompile on boot are present in the config. Saves a fully built image with environment baked in. Without this flag, if MIGRATE_ON_BOOT is set in config it will defer migration until container start, and if PRECOMPILE_ON_BOOT is set in the config, it will defer configure step until container start."` - Clean bool `help:"also runs clean"` + Config string `arg:"" name:"config" help:"config" predictor:"config"` + FullBuild bool `name:"full-build" help:"Run a full build image even when migrate on boot and precompile on boot are present in the config. Saves a fully built image with environment baked in. Without this flag, if MIGRATE_ON_BOOT is set in config it will defer migration until container start, and if PRECOMPILE_ON_BOOT is set in the config, it will defer configure step until container start."` + SkipVersionCheck bool `env:"SKIP_VERSION_CHECK" help:"Skips launcher checking for a new version"` + Clean bool `help:"also runs clean"` } func (r *RebuildCmd) Run(cli *Cli, ctx *context.Context) error { - if slices.Contains([]string{"", "0", "false"}, os.Getenv("SKIP_VERSION_CHECK")) { + if !r.SkipVersionCheck { CheckVersion() } diff --git a/launcher_go/v2/cli_runtime_test.go b/launcher_go/v2/cli_runtime_test.go index f06432773..beaf97e89 100644 --- a/launcher_go/v2/cli_runtime_test.go +++ b/launcher_go/v2/cli_runtime_test.go @@ -26,9 +26,6 @@ var _ = Describe("Runtime", func() { ctx = context.Background() - //Skip version checks for tests - os.Setenv("SKIP_VERSION_CHECK", "1") - cli = &ddocker.Cli{ ConfDir: "./test/containers", TemplatesDir: "./test", @@ -102,7 +99,7 @@ var _ = Describe("Runtime", func() { }) It("should keep running during commits, and be post-deploy migration aware when using a web only container", func() { - runner := ddocker.RebuildCmd{Config: "web_only"} + runner := ddocker.RebuildCmd{Config: "web_only", SkipVersionCheck: true} runner.Run(cli, &ctx) @@ -146,7 +143,7 @@ var _ = Describe("Runtime", func() { }) It("should stop with standalone", func() { - runner := ddocker.RebuildCmd{Config: "standalone"} + runner := ddocker.RebuildCmd{Config: "standalone", SkipVersionCheck: true} runner.Run(cli, &ctx)