From 0f56164fa23cb6afa84013fa8c2d02c8e9a217a1 Mon Sep 17 00:00:00 2001 From: Ryan VanGundy <85766511+rmvangun@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:47:02 -0500 Subject: [PATCH] fix(config): Defaults to cluster.enabled=true Sets `cluster.enabled=true` by default. Fixes when `KUBECONFIG` was not set for CSP based blueprints. Signed-off-by: Ryan VanGundy <85766511+rmvangun@users.noreply.github.com> --- pkg/runtime/config/defaults.go | 29 +++++++++++++++-------------- pkg/runtime/runtime.go | 2 +- pkg/runtime/runtime_test.go | 10 +++++----- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/pkg/runtime/config/defaults.go b/pkg/runtime/config/defaults.go index 17a0f6675..ebf46e22e 100644 --- a/pkg/runtime/config/defaults.go +++ b/pkg/runtime/config/defaults.go @@ -19,20 +19,6 @@ import ( "github.com/windsorcli/cli/pkg/constants" ) -// DefaultConfig returns the default configuration for non-dev contexts -// Uses minimal config since non-dev contexts default to provider "none" -var DefaultConfig = v1alpha1.Context{ - Provider: ptrString("none"), - Terraform: commonTerraformConfig.Copy(), -} - -// DefaultConfig_None returns a minimal default configuration for provider "none" -// with terraform enabled but no cluster or DNS settings -var DefaultConfig_None = v1alpha1.Context{ - Provider: ptrString("none"), - Terraform: commonTerraformConfig.Copy(), -} - var commonDockerConfig = docker.DockerConfig{ Enabled: ptrBool(true), Registries: map[string]docker.RegistryConfig{ @@ -76,6 +62,12 @@ var commonTerraformConfig = terraform.TerraformConfig{ }, } +// commonClusterConfig_Minimal is a minimal cluster configuration with only enabled set to true. +// Used for provider-specific configurations where the driver will be set by ApplyProviderDefaults. +var commonClusterConfig_Minimal = cluster.ClusterConfig{ + Enabled: ptrBool(true), +} + // commonClusterConfig_NoHostPorts is the base cluster configuration without hostports, // used for VM drivers that use native networking (colima, docker) var commonClusterConfig_NoHostPorts = cluster.ClusterConfig{ @@ -120,6 +112,15 @@ var commonClusterConfig_WithHostPorts = cluster.ClusterConfig{ }, } +// DefaultConfig returns the default configuration for non-dev contexts +// Uses minimal config since non-dev contexts default to provider "none" +// Includes cluster.enabled=true for provider-specific contexts (aws, azure) +var DefaultConfig = v1alpha1.Context{ + Provider: ptrString("none"), + Terraform: commonTerraformConfig.Copy(), + Cluster: commonClusterConfig_Minimal.Copy(), +} + var DefaultConfig_Localhost = v1alpha1.Context{ Provider: ptrString("generic"), Environment: map[string]string{}, diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 11de02ad1..5d31e6d20 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -686,7 +686,7 @@ func (rt *Runtime) ApplyConfigDefaults(flagOverrides ...map[string]any) error { provider := rt.ConfigHandler.GetString("provider") if provider == "none" { - if err := rt.ConfigHandler.SetDefault(config.DefaultConfig_None); err != nil { + if err := rt.ConfigHandler.SetDefault(config.DefaultConfig); err != nil { return fmt.Errorf("failed to set default config: %w", err) } } else if vmDriver == "docker-desktop" { diff --git a/pkg/runtime/runtime_test.go b/pkg/runtime/runtime_test.go index 032a4579d..dced3e2e6 100644 --- a/pkg/runtime/runtime_test.go +++ b/pkg/runtime/runtime_test.go @@ -1558,16 +1558,16 @@ func TestRuntime_ApplyConfigDefaults(t *testing.T) { } if setDefaultConfig.Provider == nil || *setDefaultConfig.Provider != "none" { - t.Error("Expected DefaultConfig_None to be set with provider 'none'") + t.Error("Expected DefaultConfig to be set with provider 'none'") } - if setDefaultConfig.Cluster != nil { - t.Error("Expected DefaultConfig_None to have no cluster config") + if setDefaultConfig.Cluster == nil || setDefaultConfig.Cluster.Enabled == nil || !*setDefaultConfig.Cluster.Enabled { + t.Error("Expected DefaultConfig to have cluster.enabled=true") } if setDefaultConfig.DNS != nil { - t.Error("Expected DefaultConfig_None to have no DNS config") + t.Error("Expected DefaultConfig to have no DNS config") } if setDefaultConfig.Terraform == nil || setDefaultConfig.Terraform.Enabled == nil || !*setDefaultConfig.Terraform.Enabled { - t.Error("Expected DefaultConfig_None to have terraform enabled") + t.Error("Expected DefaultConfig to have terraform enabled") } })