Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions api/v1alpha1/cluster/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cluster
// ClusterConfig represents the cluster configuration
type ClusterConfig struct {
Enabled *bool `yaml:"enabled,omitempty"`
Platform *string `yaml:"platform,omitempty"`
Driver *string `yaml:"driver,omitempty"`
Endpoint *string `yaml:"endpoint,omitempty"`
Image *string `yaml:"image,omitempty"`
Expand Down Expand Up @@ -36,9 +35,6 @@ func (base *ClusterConfig) Merge(overlay *ClusterConfig) {
if overlay.Enabled != nil {
base.Enabled = overlay.Enabled
}
if overlay.Platform != nil {
base.Platform = overlay.Platform
}
if overlay.Driver != nil {
base.Driver = overlay.Driver
}
Expand Down Expand Up @@ -140,7 +136,6 @@ func (c *ClusterConfig) Copy() *ClusterConfig {

return &ClusterConfig{
Enabled: c.Enabled,
Platform: c.Platform,
Driver: c.Driver,
Endpoint: c.Endpoint,
Image: c.Image,
Expand Down
14 changes: 0 additions & 14 deletions api/v1alpha1/cluster/cluster_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ func TestClusterConfig_Merge(t *testing.T) {
base := &ClusterConfig{
Enabled: ptrBool(true),
Driver: ptrString("base-driver"),
Platform: ptrString("base-platform"),
Endpoint: ptrString("base-endpoint"),
Image: ptrString("base-image"),
ControlPlanes: struct {
Expand Down Expand Up @@ -74,7 +73,6 @@ func TestClusterConfig_Merge(t *testing.T) {
overlay := &ClusterConfig{
Enabled: ptrBool(false),
Driver: ptrString("overlay-driver"),
Platform: ptrString("overlay-platform"),
Endpoint: ptrString("overlay-endpoint"),
Image: ptrString("overlay-image"),
ControlPlanes: struct {
Expand Down Expand Up @@ -131,9 +129,6 @@ func TestClusterConfig_Merge(t *testing.T) {
if base.Driver == nil || *base.Driver != "overlay-driver" {
t.Errorf("Driver mismatch: expected 'overlay-driver', got '%s'", *base.Driver)
}
if base.Platform == nil || *base.Platform != "overlay-platform" {
t.Errorf("Platform mismatch: expected 'overlay-platform', got '%s'", *base.Platform)
}
if base.Endpoint == nil || *base.Endpoint != "overlay-endpoint" {
t.Errorf("Endpoint mismatch: expected 'overlay-endpoint', got '%s'", *base.Endpoint)
}
Expand Down Expand Up @@ -191,7 +186,6 @@ func TestClusterConfig_Merge(t *testing.T) {
base := &ClusterConfig{
Enabled: nil,
Driver: nil,
Platform: nil,
Endpoint: nil,
Image: nil,
ControlPlanes: struct {
Expand Down Expand Up @@ -233,7 +227,6 @@ func TestClusterConfig_Merge(t *testing.T) {
overlay := &ClusterConfig{
Enabled: nil,
Driver: nil,
Platform: nil,
Endpoint: nil,
Image: nil,
ControlPlanes: struct {
Expand Down Expand Up @@ -280,9 +273,6 @@ func TestClusterConfig_Merge(t *testing.T) {
if base.Driver != nil {
t.Errorf("Driver mismatch: expected nil, got '%s'", *base.Driver)
}
if base.Platform != nil {
t.Errorf("Platform mismatch: expected nil, got '%s'", *base.Platform)
}
if base.Endpoint != nil {
t.Errorf("Endpoint mismatch: expected nil, got '%s'", *base.Endpoint)
}
Expand Down Expand Up @@ -336,7 +326,6 @@ func TestClusterConfig_Copy(t *testing.T) {
original := &ClusterConfig{
Enabled: ptrBool(true),
Driver: ptrString("original-driver"),
Platform: ptrString("original-platform"),
Endpoint: ptrString("original-endpoint"),
Image: ptrString("original-image"),
ControlPlanes: struct {
Expand Down Expand Up @@ -393,9 +382,6 @@ func TestClusterConfig_Copy(t *testing.T) {
if original.Driver == nil || copy.Driver == nil || *original.Driver != *copy.Driver {
t.Errorf("Driver mismatch: expected %v, got %v", *original.Driver, *copy.Driver)
}
if original.Platform == nil || copy.Platform == nil || *original.Platform != *copy.Platform {
t.Errorf("Platform mismatch: expected %v, got %v", *original.Platform, *copy.Platform)
}
if original.Endpoint == nil || copy.Endpoint == nil || *original.Endpoint != *copy.Endpoint {
t.Errorf("Endpoint mismatch: expected %v, got %v", *original.Endpoint, *copy.Endpoint)
}
Expand Down
10 changes: 0 additions & 10 deletions api/v1alpha2/config/workstation/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package workstation
// ClusterConfig represents the cluster configuration
type ClusterConfig struct {
Enabled *bool `yaml:"enabled,omitempty"`
Platform *string `yaml:"platform,omitempty"`
Driver *string `yaml:"driver,omitempty"`
Endpoint *string `yaml:"endpoint,omitempty"`
Image *string `yaml:"image,omitempty"`
Expand Down Expand Up @@ -39,9 +38,6 @@ func (base *ClusterConfig) Merge(overlay *ClusterConfig) {
if overlay.Enabled != nil {
base.Enabled = overlay.Enabled
}
if overlay.Platform != nil {
base.Platform = overlay.Platform
}
if overlay.Driver != nil {
base.Driver = overlay.Driver
}
Expand Down Expand Up @@ -204,11 +200,6 @@ func (c *ClusterConfig) DeepCopy() *ClusterConfig {
enabledCopy = new(bool)
*enabledCopy = *c.Enabled
}
var platformCopy *string
if c.Platform != nil {
platformCopy = new(string)
*platformCopy = *c.Platform
}
var driverCopy *string
if c.Driver != nil {
driverCopy = new(string)
Expand All @@ -227,7 +218,6 @@ func (c *ClusterConfig) DeepCopy() *ClusterConfig {

return &ClusterConfig{
Enabled: enabledCopy,
Platform: platformCopy,
Driver: driverCopy,
Endpoint: endpointCopy,
Image: imageCopy,
Expand Down
14 changes: 2 additions & 12 deletions api/v1alpha2/config/workstation/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ func TestClusterConfig_Merge(t *testing.T) {
}

overlay := &ClusterConfig{
Enabled: ptrBool(true),
Driver: ptrString("talos"),
Platform: ptrString("local"),
Enabled: ptrBool(true),
Driver: ptrString("talos"),
}

base.Merge(overlay)
Expand All @@ -41,9 +40,6 @@ func TestClusterConfig_Merge(t *testing.T) {
if *base.Driver != "talos" {
t.Errorf("Expected Driver to be 'talos', got %s", *base.Driver)
}
if *base.Platform != "local" {
t.Errorf("Expected Platform to be 'local', got %s", *base.Platform)
}
})

t.Run("MergeControlPlanes", func(t *testing.T) {
Expand Down Expand Up @@ -282,15 +278,13 @@ func TestClusterConfig_Merge(t *testing.T) {
t.Run("MergeWithAllFields", func(t *testing.T) {
base := &ClusterConfig{
Enabled: ptrBool(false),
Platform: ptrString("cloud"),
Driver: ptrString("kind"),
Endpoint: ptrString("https://old.local:6443"),
Image: ptrString("kind:v1.0.0"),
}

overlay := &ClusterConfig{
Enabled: ptrBool(true),
Platform: ptrString("local"),
Driver: ptrString("talos"),
Endpoint: ptrString("https://new.local:6443"),
Image: ptrString("talos:v1.0.0"),
Expand All @@ -301,9 +295,6 @@ func TestClusterConfig_Merge(t *testing.T) {
if !*base.Enabled {
t.Errorf("Expected Enabled to be true")
}
if *base.Platform != "local" {
t.Errorf("Expected Platform to be 'local'")
}
if *base.Driver != "talos" {
t.Errorf("Expected Driver to be 'talos'")
}
Expand Down Expand Up @@ -342,7 +333,6 @@ func TestClusterConfig_Copy(t *testing.T) {
t.Run("CopyPopulatedConfig", func(t *testing.T) {
config := &ClusterConfig{
Enabled: ptrBool(true),
Platform: ptrString("local"),
Driver: ptrString("talos"),
Endpoint: ptrString("https://cluster.local:6443"),
Image: ptrString("talos:v1.0.0"),
Expand Down
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var initCmd = &cobra.Command{

// Set provider if context is "local" and no provider is specified
if len(args) > 0 && strings.HasPrefix(args[0], "local") && initProvider == "" {
initProvider = "local"
initProvider = "generic"
}

// Pass blueprint and provider to pipeline for decision logic
Expand Down
14 changes: 7 additions & 7 deletions cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func TestInitCmd(t *testing.T) {

// If context is "local" and neither provider nor blueprint is set, set both
if len(args) > 0 && strings.HasPrefix(args[0], "local") && initProvider == "" && initBlueprint == "" {
initProvider = "local"
initProvider = "generic"
initBlueprint = constants.DEFAULT_OCI_BLUEPRINT_URL
}

Expand All @@ -502,8 +502,8 @@ func TestInitCmd(t *testing.T) {
}

// Then both provider and blueprint should be set correctly
if initProvider != "local" {
t.Errorf("Expected provider to be 'local', got %s", initProvider)
if initProvider != "generic" {
t.Errorf("Expected provider to be 'generic', got %s", initProvider)
}

if blueprintCtx := ctx.Value("blueprint"); blueprintCtx == nil {
Expand All @@ -528,7 +528,7 @@ func TestInitCmd(t *testing.T) {

// If context is "local" and neither provider nor blueprint is set, set both
if len(args) > 0 && strings.HasPrefix(args[0], "local") && initProvider == "" && initBlueprint == "" {
initProvider = "local"
initProvider = "generic"
initBlueprint = constants.DEFAULT_OCI_BLUEPRINT_URL
}

Expand Down Expand Up @@ -569,7 +569,7 @@ func TestInitCmd(t *testing.T) {

// If context is "local" and neither provider nor blueprint is set, set both
if len(args) > 0 && strings.HasPrefix(args[0], "local") && initProvider == "" && initBlueprint == "" {
initProvider = "local"
initProvider = "generic"
initBlueprint = constants.DEFAULT_OCI_BLUEPRINT_URL
}

Expand Down Expand Up @@ -606,7 +606,7 @@ func TestInitCmd(t *testing.T) {

// If context is "local" and neither provider nor blueprint is set, set both
if len(args) > 0 && strings.HasPrefix(args[0], "local") && initProvider == "" && initBlueprint == "" {
initProvider = "local"
initProvider = "generic"
initBlueprint = constants.DEFAULT_OCI_BLUEPRINT_URL
}

Expand Down Expand Up @@ -1003,7 +1003,7 @@ func TestInitCmd(t *testing.T) {
cmd.SetContext(ctx)
err := cmd.Execute()

// Then no error should occur and "local" should be used as provider
// Then no error should occur and "generic" should be used as provider
if err != nil {
t.Errorf("Expected success, got error: %v", err)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/blueprint/blueprint_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,6 @@ func setupMocks(t *testing.T, opts ...*SetupOptions) *Mocks {

mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string {
switch key {
case "cluster.platform":
return "default"
case "context":
return currentContext
default:
Expand Down
28 changes: 14 additions & 14 deletions pkg/blueprint/feature_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ func TestEvaluateExpression(t *testing.T) {
},
{
name: "SimpleInequalityExpressionTrue",
expression: "provider != 'local'",
expression: "provider != 'generic'",
config: map[string]any{"provider": "aws"},
expected: true,
},
{
name: "SimpleInequalityExpressionFalse",
expression: "provider != 'local'",
config: map[string]any{"provider": "local"},
expression: "provider != 'generic'",
config: map[string]any{"provider": "generic"},
expected: false,
},
{
name: "LogicalAndExpressionTrue",
expression: "provider == 'local' && observability.enabled == true",
expression: "provider == 'generic' && observability.enabled == true",
config: map[string]any{
"provider": "local",
"provider": "generic",
"observability": map[string]any{
"enabled": true,
},
Expand All @@ -74,7 +74,7 @@ func TestEvaluateExpression(t *testing.T) {
},
{
name: "LogicalAndExpressionFalse",
expression: "provider == 'local' && observability.enabled == true",
expression: "provider == 'generic' && observability.enabled == true",
config: map[string]any{
"provider": "aws",
"observability": map[string]any{
Expand All @@ -92,14 +92,14 @@ func TestEvaluateExpression(t *testing.T) {
{
name: "LogicalOrExpressionFalse",
expression: "provider == 'aws' || provider == 'azure'",
config: map[string]any{"provider": "local"},
config: map[string]any{"provider": "generic"},
expected: false,
},
{
name: "ParenthesesGrouping",
expression: "provider == 'local' && (vm.driver != 'docker-desktop' || loadbalancer.enabled == true)",
expression: "provider == 'generic' && (vm.driver != 'docker-desktop' || loadbalancer.enabled == true)",
config: map[string]any{
"provider": "local",
"provider": "generic",
"vm": map[string]any{
"driver": "virtualbox",
},
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestMatchConditions(t *testing.T) {
{
name: "SimpleStringEqualityFalse",
conditions: map[string]any{"provider": "aws"},
config: map[string]any{"provider": "local"},
config: map[string]any{"provider": "generic"},
expected: false,
},
{
Expand All @@ -212,12 +212,12 @@ func TestMatchConditions(t *testing.T) {
{
name: "MultipleConditionsAllMatch",
conditions: map[string]any{
"provider": "local",
"provider": "generic",
"observability.enabled": true,
"observability.backend": "quickwit",
},
config: map[string]any{
"provider": "local",
"provider": "generic",
"observability": map[string]any{
"enabled": true,
"backend": "quickwit",
Expand All @@ -228,12 +228,12 @@ func TestMatchConditions(t *testing.T) {
{
name: "MultipleConditionsOneDoesNotMatch",
conditions: map[string]any{
"provider": "local",
"provider": "generic",
"observability.enabled": true,
"observability.backend": "elk",
},
config: map[string]any{
"provider": "local",
"provider": "generic",
"observability": map[string]any{
"enabled": true,
"backend": "quickwit",
Expand Down
Loading
Loading