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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ contexts/**/.tfstate/
contexts/**/.kube/
contexts/**/.talos/
contexts/**/.aws/
contexts/**/.omni/
22 changes: 11 additions & 11 deletions api/v1alpha1/blueprint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ type Blueprint struct {
}

type PartialBlueprint struct {
Kind string `yaml:"kind"`
ApiVersion string `yaml:"apiVersion"`
Metadata Metadata `yaml:"metadata"`
Sources []Source `yaml:"sources"`
Repository Repository `yaml:"repository"`
TerraformComponents []TerraformComponent `yaml:"terraform"`
Kustomizations []map[string]interface{} `yaml:"kustomize"`
Kind string `yaml:"kind"`
ApiVersion string `yaml:"apiVersion"`
Metadata Metadata `yaml:"metadata"`
Sources []Source `yaml:"sources"`
Repository Repository `yaml:"repository"`
TerraformComponents []TerraformComponent `yaml:"terraform"`
Kustomizations []map[string]any `yaml:"kustomize"`
}

// Metadata describes a blueprint, including name and authors.
Expand Down Expand Up @@ -113,7 +113,7 @@ type TerraformComponent struct {
FullPath string `yaml:"-"`

// Values are configuration values for the module.
Values map[string]interface{} `yaml:"values,omitempty"`
Values map[string]any `yaml:"values,omitempty"`

// Variables are input variables for the module.
Variables map[string]TerraformVariable `yaml:"variables,omitempty"`
Expand All @@ -125,7 +125,7 @@ type TerraformVariable struct {
Type string `yaml:"type,omitempty"`

// Default value for the variable.
Default interface{} `yaml:"default,omitempty"`
Default any `yaml:"default,omitempty"`

// Description of the variable's purpose.
Description string `yaml:"description,omitempty"`
Expand Down Expand Up @@ -247,7 +247,7 @@ func (b *Blueprint) DeepCopy() *Blueprint {
}
}

valuesCopy := make(map[string]interface{}, len(component.Values))
valuesCopy := make(map[string]any, len(component.Values))
for key, value := range component.Values {
valuesCopy[key] = value
}
Expand Down Expand Up @@ -379,7 +379,7 @@ func (b *Blueprint) Merge(overlay *Blueprint) {
mergedComponent := existingComponent

if mergedComponent.Values == nil {
mergedComponent.Values = make(map[string]interface{})
mergedComponent.Values = make(map[string]any)
}
for k, v := range overlayComponent.Values {
mergedComponent.Values[k] = v
Expand Down
24 changes: 12 additions & 12 deletions api/v1alpha1/blueprint_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{"key1": "value1"},
Values: map[string]any{"key1": "value1"},
FullPath: "original/full/path",
},
},
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var2": {Default: "default2"},
},
Values: map[string]interface{}{"key2": "value2"},
Values: map[string]any{"key2": "value2"},
FullPath: "updated/full/path",
},
{
Expand All @@ -98,7 +98,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var3": {Default: "default3"},
},
Values: map[string]interface{}{"key3": "value3"},
Values: map[string]any{"key3": "value3"},
FullPath: "new/full/path",
},
},
Expand Down Expand Up @@ -240,7 +240,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
FullPath: "overlay/full/path",
Expand Down Expand Up @@ -340,7 +340,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
FullPath: "original/full/path",
Expand All @@ -356,7 +356,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var2": {Default: "default2"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key2": "value2",
},
FullPath: "updated/full/path",
Expand Down Expand Up @@ -396,7 +396,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
FullPath: "original/full/path",
Expand Down Expand Up @@ -444,7 +444,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
FullPath: "overlay/full/path",
Expand Down Expand Up @@ -565,7 +565,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var1": {Default: "default1"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
FullPath: "original/full/path",
Expand All @@ -581,7 +581,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var2": {Default: "default2"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key2": "value2",
},
FullPath: "updated/full/path",
Expand All @@ -592,7 +592,7 @@ func TestBlueprint_Merge(t *testing.T) {
Variables: map[string]TerraformVariable{
"var3": {Default: "default3"},
},
Values: map[string]interface{}{
Values: map[string]any{
"key3": "value3",
},
FullPath: "new/full/path",
Expand Down Expand Up @@ -925,7 +925,7 @@ func TestBlueprint_DeepCopy(t *testing.T) {
Description: "A test variable",
},
},
Values: map[string]interface{}{
Values: map[string]any{
"key1": "value1",
},
},
Expand Down
9 changes: 7 additions & 2 deletions api/v1alpha1/docker/docker_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func (base *DockerConfig) Merge(overlay *DockerConfig) {
base.Enabled = overlay.Enabled
}

if overlay.RegistryURL != "" {
base.RegistryURL = overlay.RegistryURL
}

// Overwrite base.Registries entirely with overlay.Registries if defined, otherwise keep base.Registries
if overlay.Registries != nil {
base.Registries = overlay.Registries
Expand Down Expand Up @@ -49,8 +53,9 @@ func (c *DockerConfig) Copy() *DockerConfig {
}

return &DockerConfig{
Enabled: enabledCopy,
Registries: registriesCopy,
Enabled: enabledCopy,
RegistryURL: c.RegistryURL,
Registries: registriesCopy,
}
}

Expand Down
20 changes: 15 additions & 5 deletions api/v1alpha1/docker/docker_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import (
func TestDockerConfig_Merge(t *testing.T) {
t.Run("MergeWithNonNilValues", func(t *testing.T) {
base := &DockerConfig{
Enabled: ptrBool(true),
Enabled: ptrBool(true),
RegistryURL: "base-registry-url",
Registries: map[string]RegistryConfig{
"base-registry1": {Remote: "base-remote1", Local: "base-local1", HostName: "base-hostname1"},
"base-registry2": {Remote: "base-remote2", Local: "base-local2", HostName: "base-hostname2"},
},
}

overlay := &DockerConfig{
Enabled: ptrBool(false),
Enabled: ptrBool(false),
RegistryURL: "overlay-registry-url",
Registries: map[string]RegistryConfig{
"base-registry1": {Remote: "overlay-remote1", Local: "overlay-local1", HostName: "overlay-hostname1"},
"new-registry": {Remote: "overlay-remote2", Local: "overlay-local2", HostName: "overlay-hostname2"},
Expand All @@ -27,6 +29,9 @@ func TestDockerConfig_Merge(t *testing.T) {
if base.Enabled == nil || *base.Enabled != false {
t.Errorf("Enabled mismatch: expected %v, got %v", false, *base.Enabled)
}
if base.RegistryURL != "overlay-registry-url" {
t.Errorf("RegistryURL mismatch: expected %v, got %v", "overlay-registry-url", base.RegistryURL)
}
if len(base.Registries) != 2 {
t.Errorf("Registries length mismatch: expected %v, got %v", 2, len(base.Registries))
}
Expand All @@ -51,22 +56,27 @@ func TestDockerConfig_Merge(t *testing.T) {

t.Run("MergeWithNilValues", func(t *testing.T) {
base := &DockerConfig{
Enabled: ptrBool(true),
Enabled: ptrBool(true),
RegistryURL: "base-registry-url",
Registries: map[string]RegistryConfig{
"base-registry1": {Remote: "base-remote1", Local: "base-local1", HostName: "base-hostname1"},
},
}

overlay := &DockerConfig{
Enabled: nil,
Registries: nil,
Enabled: nil,
RegistryURL: "",
Registries: nil,
}

base.Merge(overlay)

if base.Enabled == nil || *base.Enabled != true {
t.Errorf("Enabled mismatch: expected %v, got %v", true, *base.Enabled)
}
if base.RegistryURL != "base-registry-url" {
t.Errorf("RegistryURL mismatch: expected %v, got %v", "base-registry-url", base.RegistryURL)
}
if len(base.Registries) != 1 || base.Registries["base-registry1"].Remote != "base-remote1" || base.Registries["base-registry1"].Local != "base-local1" || base.Registries["base-registry1"].HostName != "base-hostname1" {
t.Errorf("Registries mismatch: expected %v, got %v", "base-registry1", base.Registries["base-registry1"])
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func setupSafeContextCmdMocks(optionalInjector ...di.Injector) MockSafeContextCm

// Setup mock config handler
mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.SetFunc = func(key string, value interface{}) error {
mockConfigHandler.SetFunc = func(key string, value any) error {
return nil
}
mockConfigHandler.GetContextFunc = func() string {
Expand Down
2 changes: 1 addition & 1 deletion cmd/down_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func setupSafeDownCmdMocks(optionalInjector ...di.Injector) MockSafeDownCmdCompo

// Setup mock config handler
mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.SetFunc = func(key string, value interface{}) error {
mockConfigHandler.SetFunc = func(key string, value any) error {
return nil
}
mockConfigHandler.GetContextFunc = func() string {
Expand Down
6 changes: 0 additions & 6 deletions cmd/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ func TestEnvCmd(t *testing.T) {
}
})

// Also reset the session token in the shell package
shell.ResetSessionToken()
t.Cleanup(func() {
shell.ResetSessionToken()
})

t.Run("Success", func(t *testing.T) {
defer resetRootCmd()

Expand Down
8 changes: 4 additions & 4 deletions cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func setupSafeInitCmdMocks(existingInjectors ...di.Injector) *initMockObjects {
mockController.InitializeComponentsFunc = func() error { return nil }

mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.SetFunc = func(key string, value interface{}) error { return nil }
mockConfigHandler.SetFunc = func(key string, value any) error { return nil }
mockConfigHandler.GetContextFunc = func() string { return "test-context" }
mockConfigHandler.SetContextFunc = func(contextName string) error { return nil }
mockConfigHandler.InitializeFunc = func() error { return nil }
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestInitCmd(t *testing.T) {
}
return nil
}
mocks.ConfigHandler.SetContextValueFunc = func(key string, value interface{}) error {
mocks.ConfigHandler.SetContextValueFunc = func(key string, value any) error {
if key == "vm.driver" {
if goos() == "darwin" || goos() == "windows" {
if value == "docker-desktop" {
Expand Down Expand Up @@ -356,7 +356,7 @@ func TestInitCmd(t *testing.T) {
mocks := setupSafeInitCmdMocks()

// Mock SetContextValue to return an error
mocks.ConfigHandler.SetContextValueFunc = func(key string, value interface{}) error {
mocks.ConfigHandler.SetContextValueFunc = func(key string, value any) error {
if key == "vm.driver" {
return fmt.Errorf("mocked error setting vm driver")
}
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestInitCmd(t *testing.T) {
mocks := setupSafeInitCmdMocks()

// Mock SetContextValue to return an error for a specific flag
mocks.ConfigHandler.SetContextValueFunc = func(configPath string, value interface{}) error {
mocks.ConfigHandler.SetContextValueFunc = func(configPath string, value any) error {
if configPath == "aws.aws_endpoint_url" {
return fmt.Errorf("mocked error setting aws-endpoint-url configuration")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func setupSafeUpCmdMocks(optionalInjector ...di.Injector) SafeUpCmdComponents {

// Setup mock config handler
mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.SetFunc = func(key string, value interface{}) error {
mockConfigHandler.SetFunc = func(key string, value any) error {
return nil
}
mockConfigHandler.GetContextFunc = func() string {
Expand Down
7 changes: 0 additions & 7 deletions cmd/windsor/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"os"

"github.com/windsorcli/cli/cmd"
Expand All @@ -16,12 +15,6 @@ func main() {
// Create a new controller
controller := controller.NewRealController(injector)

// Initialize components
if err := controller.InitializeComponents(); err != nil {
fmt.Fprintf(os.Stderr, "Error initializing components: %v\n", err)
os.Exit(1)
}

// Execute the root command and handle the error,
// exiting with a non-zero exit code if there's an error
if err := cmd.Execute(controller); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ terraform:
|------------|----------------------------------|--------------------------------------------------|
| `source` | `string` | Source of the Terraform module. Must be included in the list of sources. |
| `path` | `string` | Path of the Terraform module relative to the `terraform/` folder. |
| `values` | `map[string]interface{}` | Configuration values for the module. |
| `values` | `map[string]any` | Configuration values for the module. |
| `variables`| `map[string]TerraformVariable` | Input variables for the module. |

### Kustomization
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ require (
github.com/x448/float16 v0.8.4 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/errs v1.4.0 // indirect
github.com/zeebo/errs/v2 v2.0.5 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/detectors/gcp v1.35.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 // indirect
Expand Down Expand Up @@ -191,5 +190,4 @@ require (
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.0.0 // indirect
)
Loading
Loading