From 2618d3fa2f3f085def81893a8d49f534bc5ca983 Mon Sep 17 00:00:00 2001 From: Samuel K Date: Thu, 22 Oct 2026 01:05:22 -0600 Subject: [PATCH] refactor(config): rename DEVSY_PRO_RUNNER to DEVSY_PLATFORM_RUNNER with fallback --- cmd/pro/flags/flags.go | 2 +- cmd/pro/workspace/import.go | 4 +-- pkg/config/env.go | 7 ++++-- pkg/config/platform.go | 11 +++++++++ pkg/config/platform_test.go | 42 ++++++++++++++++++++++++++++++++ pkg/flags/names/names.go | 2 +- pkg/ide/opener/browser_tunnel.go | 2 +- pkg/telemetry/collect.go | 4 +-- 8 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 pkg/config/platform.go create mode 100644 pkg/config/platform_test.go diff --git a/cmd/pro/flags/flags.go b/cmd/pro/flags/flags.go index 3ca239e461..ce23b1213d 100644 --- a/cmd/pro/flags/flags.go +++ b/cmd/pro/flags/flags.go @@ -8,7 +8,7 @@ import ( flag "github.com/spf13/pflag" ) -// BindEnv re-exports pkgflags.BindEnv so pro subcommands can wire env vars +// BindEnv re-exports pkgflags.BindEnv so platform subcommands can wire env vars // through their existing local `flags` import alias. func BindEnv(fs *flag.FlagSet, flagName string) { pkgflags.BindEnv(fs, flagName) diff --git a/cmd/pro/workspace/import.go b/cmd/pro/workspace/import.go index 922a8fbe0a..a6477baf62 100644 --- a/cmd/pro/workspace/import.go +++ b/cmd/pro/workspace/import.go @@ -186,7 +186,7 @@ func (cmd *ImportCmd) importInstance( devsyConfig *config.Config, ref workspaceInstanceRef, ) error { - // old pro provider + // old platform provider if !ref.provider.HasHealthCheck() { instanceOpts, err := resolveInstanceOptions(ctx, ref.instance, ref.baseClient) if err != nil { @@ -201,7 +201,7 @@ func (cmd *ImportCmd) importInstance( return nil } - // new pro provider + // new platform provider err := cmd.writeNewWorkspaceDefinition(devsyConfig, ref.instance, ref.provider.Name) if err != nil { return fmt.Errorf("prepare workspace to import definition: %w", err) diff --git a/pkg/config/env.go b/pkg/config/env.go index ff3efe9d54..35cc8ef0d7 100644 --- a/pkg/config/env.go +++ b/pkg/config/env.go @@ -40,7 +40,10 @@ const ( EnvDisableTelemetry = "DEVSY_DISABLE_TELEMETRY" // EnvPlatformRunner is set by the Devsy Platform runner pod to mark runner-side CLI invocations. - EnvPlatformRunner = "DEVSY_PRO_RUNNER" + EnvPlatformRunner = "DEVSY_PLATFORM_RUNNER" + + // EnvPlatformRunnerLegacy is the pre-rename runner marker still set by existing runner pods. + EnvPlatformRunnerLegacy = "DEVSY_PRO_RUNNER" // EnvTelemetryDistinctID is set by the desktop app on spawned CLI // processes so their events share the desktop's analytics identity. @@ -171,7 +174,7 @@ const ( // EnvProviderFolder is the provider folder path passed to providers. EnvProviderFolder = "PROVIDER_FOLDER" - // EnvProject is the Devsy project name for pro features. + // EnvProject is the Devsy project name for platform features. EnvProject = "DEVSY_PROJECT" // EnvFilterByOwner enables filtering by owner in Devsy. diff --git a/pkg/config/platform.go b/pkg/config/platform.go new file mode 100644 index 0000000000..9f8abb7f2f --- /dev/null +++ b/pkg/config/platform.go @@ -0,0 +1,11 @@ +package config + +import "os" + +// IsPlatformRunner reports whether the CLI runs inside a Platform runner pod; the new env var wins when set. +func IsPlatformRunner() bool { + if value := os.Getenv(EnvPlatformRunner); value != "" { + return value == BoolTrue + } + return os.Getenv(EnvPlatformRunnerLegacy) == BoolTrue +} diff --git a/pkg/config/platform_test.go b/pkg/config/platform_test.go new file mode 100644 index 0000000000..fd6d271298 --- /dev/null +++ b/pkg/config/platform_test.go @@ -0,0 +1,42 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestIsPlatformRunner(t *testing.T) { + tests := []struct { + name string + newValue string + legacyValue string + want bool + }{ + {name: "neither set", want: false}, + {name: "only new set to true", newValue: BoolTrue, want: true}, + {name: "only legacy set to true", legacyValue: BoolTrue, want: true}, + {name: "both set to true", newValue: BoolTrue, legacyValue: BoolTrue, want: true}, + { + name: "new false wins over legacy true", + newValue: BoolFalse, + legacyValue: BoolTrue, + want: false, + }, + { + name: "new true wins over legacy false", + newValue: BoolTrue, + legacyValue: BoolFalse, + want: true, + }, + {name: "only legacy set to false", legacyValue: BoolFalse, want: false}, + {name: "empty new falls back to legacy", newValue: "", legacyValue: BoolTrue, want: true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + t.Setenv(EnvPlatformRunner, tt.newValue) + t.Setenv(EnvPlatformRunnerLegacy, tt.legacyValue) + assert.Equal(t, tt.want, IsPlatformRunner()) + }) + } +} diff --git a/pkg/flags/names/names.go b/pkg/flags/names/names.go index f30a252c4b..647276968f 100644 --- a/pkg/flags/names/names.go +++ b/pkg/flags/names/names.go @@ -265,7 +265,7 @@ const ( Version = "version" ) -// Pro / platform commands. +// Platform commands. const ( Channel = "channel" ChartPath = "chart-path" diff --git a/pkg/ide/opener/browser_tunnel.go b/pkg/ide/opener/browser_tunnel.go index 17ffc69f24..978a7d0863 100644 --- a/pkg/ide/opener/browser_tunnel.go +++ b/pkg/ide/opener/browser_tunnel.go @@ -171,7 +171,7 @@ type browserIDEInvocation struct { // detached background process so the CLI can return to the prompt while the // tunnel remains running. // -// If params.Client is a DaemonClient (pro mode) this falls back to running +// If params.Client is a DaemonClient (platform mode) this falls back to running // the tunnel inline because the daemon already runs out-of-process. // // If a tunnel is already running for this workspace, no new process is diff --git a/pkg/telemetry/collect.go b/pkg/telemetry/collect.go index 50d579b135..87a0528747 100644 --- a/pkg/telemetry/collect.go +++ b/pkg/telemetry/collect.go @@ -66,7 +66,7 @@ func BootstrapCLI(cmd *cobra.Command) CLICollector { } isUI := os.Getenv(config.EnvUI) == config.BoolTrue - isPlatformRunner := os.Getenv(config.EnvPlatformRunner) == config.BoolTrue + isPlatformRunner := config.IsPlatformRunner() if !isUI && !isPlatformRunner && isCIEnvironment() { log.Debug("telemetry: disabled in CI environment") return &noopCollector{} @@ -144,7 +144,7 @@ func (d *cliCollector) RecordCLI(err error) { } eventType := config.BinaryName + "_cli" - if os.Getenv(config.EnvPlatformRunner) == config.BoolTrue { + if config.IsPlatformRunner() { eventType = config.BinaryName + "_cli_runner" }