diff --git a/cmd/build_id.go b/cmd/build_id.go index cb38bffe4..f867869c4 100644 --- a/cmd/build_id.go +++ b/cmd/build_id.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -28,11 +28,11 @@ Examples: RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/build_id_test.go b/cmd/build_id_test.go index 8157347f7..a18d92e4e 100644 --- a/cmd/build_id_test.go +++ b/cmd/build_id_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) func TestBuildIDCmd(t *testing.T) { diff --git a/cmd/bundle.go b/cmd/bundle.go index 943317502..b98826d48 100644 --- a/cmd/bundle.go +++ b/cmd/bundle.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/windsorcli/cli/pkg/composer" "github.com/windsorcli/cli/pkg/composer/artifact" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -35,17 +35,17 @@ Examples: RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } - composerCtx := &composer.ComposerExecutionContext{ - ExecutionContext: *execCtx, + composerCtx := &composer.ComposerRuntime{ + Runtime: *execCtx, } if existingArtifactBuilder := injector.Resolve("artifactBuilder"); existingArtifactBuilder != nil { diff --git a/cmd/bundle_test.go b/cmd/bundle_test.go index 3332c1974..4f9c25a95 100644 --- a/cmd/bundle_test.go +++ b/cmd/bundle_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" "github.com/windsorcli/cli/pkg/composer/artifact" diff --git a/cmd/check.go b/cmd/check.go index a5332ae92..1b9f919fd 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner" ) @@ -27,11 +27,11 @@ var checkCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } @@ -72,11 +72,11 @@ var checkNodeHealthCmd = &cobra.Command{ nodeHealthTimeout = constants.DefaultNodeHealthCheckTimeout } - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } @@ -93,8 +93,8 @@ var checkNodeHealthCmd = &cobra.Command{ return fmt.Errorf("Nothing to check. Have you run \033[1mwindsor init\033[0m?") } - provisionerCtx := &provisioner.ProvisionerExecutionContext{ - ExecutionContext: *execCtx, + provisionerCtx := &provisioner.ProvisionerRuntime{ + Runtime: *execCtx, } prov := provisioner.NewProvisioner(provisionerCtx) diff --git a/cmd/check_test.go b/cmd/check_test.go index 0ccfe1cdc..dd4e6c00b 100644 --- a/cmd/check_test.go +++ b/cmd/check_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/tools" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/tools" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/cluster" ) @@ -156,7 +156,7 @@ func TestCheckCmd_ErrorScenarios(t *testing.T) { return stdout, stderr } - t.Run("HandlesNewContextError", func(t *testing.T) { + t.Run("HandlesNewRuntimeError", func(t *testing.T) { setup(t) injector := di.NewInjector() mockShell := shell.NewMockShell() @@ -176,7 +176,7 @@ func TestCheckCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { @@ -474,7 +474,7 @@ func TestCheckNodeHealthCmd_ErrorScenarios(t *testing.T) { return stdout, stderr } - t.Run("HandlesNewContextError", func(t *testing.T) { + t.Run("HandlesNewRuntimeError", func(t *testing.T) { setup(t) injector := di.NewInjector() mockShell := shell.NewMockShell() @@ -494,7 +494,7 @@ func TestCheckNodeHealthCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { diff --git a/cmd/context.go b/cmd/context.go index f9bd81538..8577fa6e1 100644 --- a/cmd/context.go +++ b/cmd/context.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -17,11 +17,11 @@ var getContextCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } @@ -47,11 +47,11 @@ var setContextCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/context_test.go b/cmd/context_test.go index 113184a73..3d46d3887 100644 --- a/cmd/context_test.go +++ b/cmd/context_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) @@ -189,7 +189,7 @@ func TestContextCmd_ErrorScenarios(t *testing.T) { return stdout, stderr } - t.Run("GetContext_HandlesNewContextError", func(t *testing.T) { + t.Run("GetContext_HandlesNewRuntimeError", func(t *testing.T) { setup(t) injector := di.NewInjector() mockShell := shell.NewMockShell() @@ -208,7 +208,7 @@ func TestContextCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { @@ -256,7 +256,7 @@ func TestContextCmd_ErrorScenarios(t *testing.T) { } }) - t.Run("SetContext_HandlesNewContextError", func(t *testing.T) { + t.Run("SetContext_HandlesNewRuntimeError", func(t *testing.T) { setup(t) injector := di.NewInjector() mockShell := shell.NewMockShell() @@ -275,7 +275,7 @@ func TestContextCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { diff --git a/cmd/down_test.go b/cmd/down_test.go index fb95893eb..42a4cff79 100644 --- a/cmd/down_test.go +++ b/cmd/down_test.go @@ -11,8 +11,8 @@ import ( blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" - execcontext "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime/config" + execcontext "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/provisioner" terraforminfra "github.com/windsorcli/cli/pkg/provisioner/terraform" "github.com/windsorcli/cli/pkg/workstation" @@ -284,16 +284,16 @@ func setupDownMocksWithProject(t *testing.T) (*Mocks, *provisioner.Provisioner, t.Fatal("executionContext not found in injector") } - prov := provisioner.NewProvisioner(&provisioner.ProvisionerExecutionContext{ - ExecutionContext: *mockExecCtx.(*execcontext.ExecutionContext), + prov := provisioner.NewProvisioner(&provisioner.ProvisionerRuntime{ + Runtime: *mockExecCtx.(*execcontext.Runtime), }) - comp := composer.NewComposer(&composer.ComposerExecutionContext{ - ExecutionContext: *mockExecCtx.(*execcontext.ExecutionContext), + comp := composer.NewComposer(&composer.ComposerRuntime{ + Runtime: *mockExecCtx.(*execcontext.Runtime), }) - ws, err := workstation.NewWorkstation(&workstation.WorkstationExecutionContext{ - ExecutionContext: *mockExecCtx.(*execcontext.ExecutionContext), + ws, err := workstation.NewWorkstation(&workstation.WorkstationRuntime{ + Runtime: *mockExecCtx.(*execcontext.Runtime), }, mocks.Injector) if err != nil { t.Fatalf("Failed to create workstation: %v", err) diff --git a/cmd/env.go b/cmd/env.go index a69ef7e56..30574dfcd 100644 --- a/cmd/env.go +++ b/cmd/env.go @@ -5,7 +5,7 @@ import ( "os" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -27,11 +27,11 @@ var envCmd = &cobra.Command{ injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/env_test.go b/cmd/env_test.go index b2f86da04..17b5b0f0e 100644 --- a/cmd/env_test.go +++ b/cmd/env_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) @@ -231,7 +231,7 @@ func TestEnvCmd_ErrorScenarios(t *testing.T) { // so testing the Setenv error path isn't realistic. The error handling code exists // for completeness but cannot be triggered in practice. - t.Run("HandlesNewContextError", func(t *testing.T) { + t.Run("HandlesNewRuntimeError", func(t *testing.T) { setup(t) // Reset context and verbose before setting up test rootCmd.SetContext(context.Background()) @@ -257,7 +257,7 @@ func TestEnvCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { @@ -399,7 +399,7 @@ func TestEnvCmd_ErrorScenarios(t *testing.T) { return fmt.Errorf("hook failed") } // Override the WindsorEnv printer after LoadEnvironment has initialized it - // We need to set it directly on the ExecutionContext after it's created + // We need to set it directly on the Runtime after it's created injector := mocks.Injector ctx := context.WithValue(context.Background(), injectorKey, injector) diff --git a/cmd/exec.go b/cmd/exec.go index 70ba5a872..dce80b169 100644 --- a/cmd/exec.go +++ b/cmd/exec.go @@ -5,7 +5,7 @@ import ( "os" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -25,11 +25,11 @@ var execCmd = &cobra.Command{ injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/exec_test.go b/cmd/exec_test.go index 9a6065760..a348b74c2 100644 --- a/cmd/exec_test.go +++ b/cmd/exec_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) @@ -151,7 +151,7 @@ func TestExecCmd_ErrorScenarios(t *testing.T) { return stdout, stderr } - t.Run("HandlesNewContextError", func(t *testing.T) { + t.Run("HandlesNewRuntimeError", func(t *testing.T) { setup(t) injector := di.NewInjector() mockShell := shell.NewMockShell() @@ -175,7 +175,7 @@ func TestExecCmd_ErrorScenarios(t *testing.T) { err := Execute() if err == nil { - t.Error("Expected error when NewContext fails") + t.Error("Expected error when NewRuntime fails") } if !strings.Contains(err.Error(), "failed to initialize context") { diff --git a/cmd/hook.go b/cmd/hook.go index 9ba12f020..69f2ed2ea 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -17,11 +17,11 @@ var hookCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/init.go b/cmd/init.go index 071ceb8f5..2ccf8a94b 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/project" ) @@ -43,11 +43,11 @@ var initCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { injector := cmd.Context().Value(injectorKey).(di.Injector) - baseCtx := &context.ExecutionContext{ + baseCtx := &runtime.Runtime{ Injector: injector, } - baseCtx, err := context.NewContext(baseCtx) + baseCtx, err := runtime.NewRuntime(baseCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } diff --git a/cmd/init_test.go b/cmd/init_test.go index c268e2ab3..db656ce94 100644 --- a/cmd/init_test.go +++ b/cmd/init_test.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/pflag" "github.com/windsorcli/cli/pkg/composer/blueprint" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/tools" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/tools" "github.com/windsorcli/cli/pkg/di" ) diff --git a/cmd/install_test.go b/cmd/install_test.go index fd43154f0..cbf6da884 100644 --- a/cmd/install_test.go +++ b/cmd/install_test.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/pflag" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" terraforminfra "github.com/windsorcli/cli/pkg/provisioner/terraform" "github.com/windsorcli/cli/pkg/workstation/virt" ) diff --git a/cmd/push.go b/cmd/push.go index 64d5982de..36a31c59e 100644 --- a/cmd/push.go +++ b/cmd/push.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" "github.com/windsorcli/cli/pkg/composer" "github.com/windsorcli/cli/pkg/composer/artifact" - "github.com/windsorcli/cli/pkg/context" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/di" ) @@ -38,17 +38,17 @@ Examples: injector := cmd.Context().Value(injectorKey).(di.Injector) - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ Injector: injector, } - execCtx, err := context.NewContext(execCtx) + execCtx, err := runtime.NewRuntime(execCtx) if err != nil { return fmt.Errorf("failed to initialize context: %w", err) } - composerCtx := &composer.ComposerExecutionContext{ - ExecutionContext: *execCtx, + composerCtx := &composer.ComposerRuntime{ + Runtime: *execCtx, } if existingArtifactBuilder := injector.Resolve("artifactBuilder"); existingArtifactBuilder != nil { diff --git a/cmd/push_test.go b/cmd/push_test.go index d20cd2d58..e5b801ed0 100644 --- a/cmd/push_test.go +++ b/cmd/push_test.go @@ -9,12 +9,12 @@ import ( "testing" "github.com/spf13/cobra" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" "github.com/windsorcli/cli/pkg/composer/artifact" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/cmd/root_test.go b/cmd/root_test.go index 52f8b2ee2..aa33cc996 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -14,10 +14,10 @@ import ( "github.com/spf13/cobra" blueprintpkg "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" - envvars "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/secrets" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + envvars "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/secrets" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" ) diff --git a/cmd/up_test.go b/cmd/up_test.go index d9972caca..6f370b423 100644 --- a/cmd/up_test.go +++ b/cmd/up_test.go @@ -11,10 +11,10 @@ import ( "github.com/spf13/pflag" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" - envvars "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/tools" + "github.com/windsorcli/cli/pkg/runtime/config" + envvars "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/tools" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" terraforminfra "github.com/windsorcli/cli/pkg/provisioner/terraform" diff --git a/pkg/composer/artifact/artifact.go b/pkg/composer/artifact/artifact.go index abc7f4369..7d959fa61 100644 --- a/pkg/composer/artifact/artifact.go +++ b/pkg/composer/artifact/artifact.go @@ -18,7 +18,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/static" "github.com/google/go-containerregistry/pkg/v1/types" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/composer/artifact/artifact_test.go b/pkg/composer/artifact/artifact_test.go index c7720e9e1..81a74dad3 100644 --- a/pkg/composer/artifact/artifact_test.go +++ b/pkg/composer/artifact/artifact_test.go @@ -18,7 +18,7 @@ import ( "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/types" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/composer/blueprint/blueprint_handler.go b/pkg/composer/blueprint/blueprint_handler.go index 8c8bff936..df5f2e4e3 100644 --- a/pkg/composer/blueprint/blueprint_handler.go +++ b/pkg/composer/blueprint/blueprint_handler.go @@ -20,8 +20,8 @@ import ( "github.com/goccy/go-yaml" "github.com/windsorcli/cli/pkg/composer/artifact" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" diff --git a/pkg/composer/blueprint/blueprint_handler_helper_test.go b/pkg/composer/blueprint/blueprint_handler_helper_test.go index 591c43017..5da34b2c3 100644 --- a/pkg/composer/blueprint/blueprint_handler_helper_test.go +++ b/pkg/composer/blueprint/blueprint_handler_helper_test.go @@ -7,7 +7,7 @@ import ( "time" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/composer/blueprint/blueprint_handler_private_test.go b/pkg/composer/blueprint/blueprint_handler_private_test.go index 223124444..880013141 100644 --- a/pkg/composer/blueprint/blueprint_handler_private_test.go +++ b/pkg/composer/blueprint/blueprint_handler_private_test.go @@ -10,8 +10,8 @@ import ( sourcev1 "github.com/fluxcd/source-controller/api/v1" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/composer/blueprint/blueprint_handler_public_test.go b/pkg/composer/blueprint/blueprint_handler_public_test.go index 72ac6d0de..519419558 100644 --- a/pkg/composer/blueprint/blueprint_handler_public_test.go +++ b/pkg/composer/blueprint/blueprint_handler_public_test.go @@ -17,8 +17,8 @@ import ( blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer/artifact" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/composer/blueprint/feature_evaluator.go b/pkg/composer/blueprint/feature_evaluator.go index 6e76325ad..c5afa7324 100644 --- a/pkg/composer/blueprint/feature_evaluator.go +++ b/pkg/composer/blueprint/feature_evaluator.go @@ -9,10 +9,10 @@ import ( "github.com/expr-lang/expr" "github.com/google/go-jsonnet" "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/constants" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // FeatureEvaluator provides lightweight expression evaluation for blueprint feature conditions. diff --git a/pkg/composer/blueprint/feature_evaluator_test.go b/pkg/composer/blueprint/feature_evaluator_test.go index 9f841b52c..cd77c506c 100644 --- a/pkg/composer/blueprint/feature_evaluator_test.go +++ b/pkg/composer/blueprint/feature_evaluator_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/composer/composer.go b/pkg/composer/composer.go index 809d02200..8281e4c68 100644 --- a/pkg/composer/composer.go +++ b/pkg/composer/composer.go @@ -9,7 +9,7 @@ import ( "github.com/windsorcli/cli/pkg/composer/artifact" "github.com/windsorcli/cli/pkg/composer/blueprint" "github.com/windsorcli/cli/pkg/composer/terraform" - "github.com/windsorcli/cli/pkg/context" + context "github.com/windsorcli/cli/pkg/runtime" ) // The Composer package provides high-level resource management functionality @@ -21,10 +21,10 @@ import ( // Types // ============================================================================= -// ComposerExecutionContext holds the execution context for resource operations. -// It embeds the base ExecutionContext and includes all resource-specific dependencies. -type ComposerExecutionContext struct { - context.ExecutionContext +// ComposerRuntime holds the execution context for resource operations. +// It embeds the base Runtime and includes all resource-specific dependencies. +type ComposerRuntime struct { + context.Runtime // Resource-specific dependencies ArtifactBuilder artifact.Artifact @@ -36,7 +36,7 @@ type ComposerExecutionContext struct { // It provides a unified interface for creating, initializing, and managing these resources // with proper dependency injection and error handling. type Composer struct { - *ComposerExecutionContext + *ComposerRuntime } // ============================================================================= @@ -47,9 +47,9 @@ type Composer struct { // It sets up all required resource handlers—artifact builder, blueprint handler, and terraform resolver— // and registers each handler with the dependency injector for use throughout the resource lifecycle. // Returns a pointer to the fully initialized Composer struct. -func NewComposer(ctx *ComposerExecutionContext) *Composer { +func NewComposer(ctx *ComposerRuntime) *Composer { composer := &Composer{ - ComposerExecutionContext: ctx, + ComposerRuntime: ctx, } if composer.ArtifactBuilder == nil { @@ -187,6 +187,7 @@ func (r *Composer) generateGitignore() error { gitignorePath := filepath.Join(projectRoot, ".gitignore") + // #nosec G304 - gitignorePath is constructed from trusted project root content, err := os.ReadFile(gitignorePath) if err != nil && !os.IsNotExist(err) { return fmt.Errorf("failed to read .gitignore: %w", err) @@ -239,6 +240,7 @@ func (r *Composer) generateGitignore() error { finalContent += "\n" } + // #nosec G306 - .gitignore files are standard 0644 permissions (world-readable, owner-writable) if err := os.WriteFile(gitignorePath, []byte(finalContent), 0644); err != nil { return fmt.Errorf("failed to write to .gitignore: %w", err) } diff --git a/pkg/composer/composer_test.go b/pkg/composer/composer_test.go index 3e5c9b156..24d74121a 100644 --- a/pkg/composer/composer_test.go +++ b/pkg/composer/composer_test.go @@ -3,10 +3,10 @@ package composer import ( "testing" - "github.com/windsorcli/cli/pkg/context" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" "github.com/windsorcli/cli/pkg/di" + "github.com/windsorcli/cli/pkg/runtime" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= @@ -22,7 +22,7 @@ func setupComposerMocks(t *testing.T) *Mocks { shell := shell.NewMockShell() // Create execution context - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ ContextName: "test-context", ProjectRoot: "/test/project", ConfigRoot: "/test/project/contexts/test-context", @@ -33,24 +33,24 @@ func setupComposerMocks(t *testing.T) *Mocks { } // Create composer execution context - composerCtx := &ComposerExecutionContext{ - ExecutionContext: *execCtx, + composerCtx := &ComposerRuntime{ + Runtime: *execCtx, } return &Mocks{ - Injector: injector, - ConfigHandler: configHandler, - Shell: shell, - ComposerExecutionContext: composerCtx, + Injector: injector, + ConfigHandler: configHandler, + Shell: shell, + ComposerRuntime: composerCtx, } } // Mocks contains all the mock dependencies for testing type Mocks struct { - Injector di.Injector - ConfigHandler config.ConfigHandler - Shell shell.Shell - ComposerExecutionContext *ComposerExecutionContext + Injector di.Injector + ConfigHandler config.ConfigHandler + Shell shell.Shell + ComposerRuntime *ComposerRuntime } // ============================================================================= @@ -61,7 +61,7 @@ func TestNewComposer(t *testing.T) { t.Run("CreatesComposerWithDependencies", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) if composer == nil { t.Fatal("Expected Composer to be created") @@ -97,7 +97,7 @@ func TestCreateComposer(t *testing.T) { t.Run("CreatesComposerWithDependencies", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) if composer == nil { t.Fatal("Expected Composer to be created") @@ -124,7 +124,7 @@ func TestCreateComposer(t *testing.T) { func TestComposer_Bundle(t *testing.T) { t.Run("HandlesBundleSuccessfully", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) // This test would need proper mocking of the artifact builder // For now, we'll just test that the method exists and handles errors @@ -139,7 +139,7 @@ func TestComposer_Bundle(t *testing.T) { func TestComposer_Push(t *testing.T) { t.Run("HandlesPushSuccessfully", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) // This test would need proper mocking of the artifact builder // For now, we'll just test that the method exists and handles errors @@ -154,7 +154,7 @@ func TestComposer_Push(t *testing.T) { func TestComposer_Generate(t *testing.T) { t.Run("HandlesGenerateSuccessfully", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) // This test would need proper mocking of the blueprint handler and terraform resolver // For now, we'll just test that the method exists and handles errors @@ -167,7 +167,7 @@ func TestComposer_Generate(t *testing.T) { t.Run("HandlesGenerateWithOverwrite", func(t *testing.T) { mocks := setupComposerMocks(t) - composer := NewComposer(mocks.ComposerExecutionContext) + composer := NewComposer(mocks.ComposerRuntime) // This test would need proper mocking of the blueprint handler and terraform resolver // For now, we'll just test that the method exists and handles errors @@ -180,20 +180,20 @@ func TestComposer_Generate(t *testing.T) { } // ============================================================================= -// Test ComposerExecutionContext +// Test ComposerRuntime // ============================================================================= -func TestComposerExecutionContext(t *testing.T) { - t.Run("CreatesComposerExecutionContext", func(t *testing.T) { - execCtx := &context.ExecutionContext{ +func TestComposerRuntime(t *testing.T) { + t.Run("CreatesComposerRuntime", func(t *testing.T) { + execCtx := &runtime.Runtime{ ContextName: "test-context", ProjectRoot: "/test/project", ConfigRoot: "/test/project/contexts/test-context", TemplateRoot: "/test/project/contexts/_template", } - composerCtx := &ComposerExecutionContext{ - ExecutionContext: *execCtx, + composerCtx := &ComposerRuntime{ + Runtime: *execCtx, } if composerCtx.ContextName != "test-context" { diff --git a/pkg/composer/terraform/module_resolver.go b/pkg/composer/terraform/module_resolver.go index 2fb3ab6f2..14dd90c0e 100644 --- a/pkg/composer/terraform/module_resolver.go +++ b/pkg/composer/terraform/module_resolver.go @@ -12,8 +12,8 @@ import ( "github.com/hashicorp/hcl/v2/hclwrite" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/zclconf/go-cty/cty" ) diff --git a/pkg/composer/terraform/module_resolver_test.go b/pkg/composer/terraform/module_resolver_test.go index f7a0bfd35..96d6ff914 100644 --- a/pkg/composer/terraform/module_resolver_test.go +++ b/pkg/composer/terraform/module_resolver_test.go @@ -14,8 +14,8 @@ import ( blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/composer/artifact" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/composer/terraform/oci_module_resolver_test.go b/pkg/composer/terraform/oci_module_resolver_test.go index 8ff448e1d..adbef0573 100644 --- a/pkg/composer/terraform/oci_module_resolver_test.go +++ b/pkg/composer/terraform/oci_module_resolver_test.go @@ -11,7 +11,7 @@ import ( blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/composer/artifact" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // MockTarReader provides a mock implementation for TarReader interface diff --git a/pkg/composer/terraform/standard_module_resolver.go b/pkg/composer/terraform/standard_module_resolver.go index 695d978d1..e3c364427 100644 --- a/pkg/composer/terraform/standard_module_resolver.go +++ b/pkg/composer/terraform/standard_module_resolver.go @@ -5,10 +5,10 @@ import ( "path/filepath" "strings" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The StandardModuleResolver is a terraform module resolver for standard source types. diff --git a/pkg/composer/terraform/standard_module_resolver_test.go b/pkg/composer/terraform/standard_module_resolver_test.go index 2168ea218..d315c19d5 100644 --- a/pkg/composer/terraform/standard_module_resolver_test.go +++ b/pkg/composer/terraform/standard_module_resolver_test.go @@ -9,10 +9,10 @@ import ( "encoding/json" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The StandardModuleResolverTest is a test suite for the StandardModuleResolver implementation diff --git a/pkg/project/project.go b/pkg/project/project.go index d6de26669..bfecf0d44 100644 --- a/pkg/project/project.go +++ b/pkg/project/project.go @@ -6,9 +6,9 @@ import ( "path/filepath" "github.com/windsorcli/cli/pkg/composer" - "github.com/windsorcli/cli/pkg/context" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner" + "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/workstation" ) @@ -16,7 +16,7 @@ import ( // It coordinates context, provisioner, composer, and workstation managers // to provide a unified interface for project initialization and management. type Project struct { - Context *context.ExecutionContext + Context *runtime.Runtime Provisioner *provisioner.Provisioner Composer *composer.Composer Workstation *workstation.Workstation @@ -28,17 +28,17 @@ type Project struct { // is in dev mode. If an existing context is provided, it will be reused; otherwise, // a new context will be created. Returns the initialized Project or an error if any step fails. // After creation, call Configure() to apply flag overrides if needed. -func NewProject(injector di.Injector, contextName string, existingCtx ...*context.ExecutionContext) (*Project, error) { - var baseCtx *context.ExecutionContext +func NewProject(injector di.Injector, contextName string, existingCtx ...*runtime.Runtime) (*Project, error) { + var baseCtx *runtime.Runtime var err error if len(existingCtx) > 0 && existingCtx[0] != nil { baseCtx = existingCtx[0] } else { - baseCtx = &context.ExecutionContext{ + baseCtx = &runtime.Runtime{ Injector: injector, } - baseCtx, err = context.NewContext(baseCtx) + baseCtx, err = runtime.NewRuntime(baseCtx) if err != nil { return nil, fmt.Errorf("failed to initialize context: %w", err) } @@ -58,20 +58,20 @@ func NewProject(injector di.Injector, contextName string, existingCtx ...*contex return nil, err } - provCtx := &provisioner.ProvisionerExecutionContext{ - ExecutionContext: *baseCtx, + provCtx := &provisioner.ProvisionerRuntime{ + Runtime: *baseCtx, } prov := provisioner.NewProvisioner(provCtx) - composerCtx := &composer.ComposerExecutionContext{ - ExecutionContext: *baseCtx, + composerCtx := &composer.ComposerRuntime{ + Runtime: *baseCtx, } comp := composer.NewComposer(composerCtx) var ws *workstation.Workstation if baseCtx.ConfigHandler.IsDevMode(baseCtx.ContextName) { - workstationCtx := &workstation.WorkstationExecutionContext{ - ExecutionContext: *baseCtx, + workstationCtx := &workstation.WorkstationRuntime{ + Runtime: *baseCtx, } ws, err = workstation.NewWorkstation(workstationCtx, baseCtx.Injector) if err != nil { diff --git a/pkg/project/project_test.go b/pkg/project/project_test.go index afeda9f62..81c64d2e8 100644 --- a/pkg/project/project_test.go +++ b/pkg/project/project_test.go @@ -7,10 +7,10 @@ import ( "testing" "github.com/windsorcli/cli/pkg/composer" - "github.com/windsorcli/cli/pkg/context" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/tools" + "github.com/windsorcli/cli/pkg/runtime" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/tools" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner" "github.com/windsorcli/cli/pkg/workstation" @@ -102,22 +102,22 @@ func setupMocks(t *testing.T) *Mocks { injector.Register("configHandler", configHandler) injector.Register("toolsManager", mockToolsManager) - baseCtx := &context.ExecutionContext{ + baseCtx := &runtime.Runtime{ Injector: injector, } - ctx, err := context.NewContext(baseCtx) + ctx, err := runtime.NewRuntime(baseCtx) if err != nil { t.Fatalf("Failed to create context: %v", err) } - provCtx := &provisioner.ProvisionerExecutionContext{ - ExecutionContext: *ctx, + provCtx := &provisioner.ProvisionerRuntime{ + Runtime: *ctx, } prov := provisioner.NewProvisioner(provCtx) - composerCtx := &composer.ComposerExecutionContext{ - ExecutionContext: *ctx, + composerCtx := &composer.ComposerRuntime{ + Runtime: *ctx, } comp := composer.NewComposer(composerCtx) diff --git a/pkg/provisioner/provisioner.go b/pkg/provisioner/provisioner.go index a22640f3a..6db8701ea 100644 --- a/pkg/provisioner/provisioner.go +++ b/pkg/provisioner/provisioner.go @@ -9,7 +9,7 @@ import ( "github.com/briandowns/spinner" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/constants" - execcontext "github.com/windsorcli/cli/pkg/context" + execcontext "github.com/windsorcli/cli/pkg/runtime" "github.com/windsorcli/cli/pkg/provisioner/cluster" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" k8sclient "github.com/windsorcli/cli/pkg/provisioner/kubernetes/client" @@ -26,10 +26,10 @@ import ( // Types // ============================================================================= -// ProvisionerExecutionContext holds the execution context for provisioner operations. -// It embeds the base ExecutionContext and includes all provisioner-specific dependencies. -type ProvisionerExecutionContext struct { - execcontext.ExecutionContext +// ProvisionerRuntime holds the execution context for provisioner operations. +// It embeds the base Runtime and includes all provisioner-specific dependencies. +type ProvisionerRuntime struct { + execcontext.Runtime TerraformStack terraforminfra.Stack KubernetesManager kubernetes.KubernetesManager @@ -41,7 +41,7 @@ type ProvisionerExecutionContext struct { // It provides a unified interface for creating, initializing, and managing these infrastructure components // with proper dependency injection and error handling. type Provisioner struct { - *ProvisionerExecutionContext + *ProvisionerRuntime } // ============================================================================= @@ -54,9 +54,9 @@ type Provisioner struct { // provisioner lifecycle. The cluster client is created based on the cluster driver configuration (talos/omni). // Components are initialized lazily when needed by the Up() and Down() methods. // Returns a pointer to the Provisioner struct. -func NewProvisioner(ctx *ProvisionerExecutionContext) *Provisioner { +func NewProvisioner(ctx *ProvisionerRuntime) *Provisioner { infra := &Provisioner{ - ProvisionerExecutionContext: ctx, + ProvisionerRuntime: ctx, } if infra.TerraformStack == nil { diff --git a/pkg/provisioner/provisioner_test.go b/pkg/provisioner/provisioner_test.go index 1d53689c5..32163377b 100644 --- a/pkg/provisioner/provisioner_test.go +++ b/pkg/provisioner/provisioner_test.go @@ -8,9 +8,9 @@ import ( "time" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/provisioner/cluster" "github.com/windsorcli/cli/pkg/provisioner/kubernetes" @@ -60,7 +60,7 @@ type Mocks struct { KubernetesManager *kubernetes.MockKubernetesManager KubernetesClient k8sclient.KubernetesClient ClusterClient *cluster.MockClusterClient - ProvisionerExecutionContext *ProvisionerExecutionContext + ProvisionerRuntime *ProvisionerRuntime } // setupProvisionerMocks creates mock components for testing the Provisioner @@ -92,7 +92,7 @@ func setupProvisionerMocks(t *testing.T) *Mocks { kubernetesClient := k8sclient.NewMockKubernetesClient() clusterClient := cluster.NewMockClusterClient() - execCtx := &context.ExecutionContext{ + execCtx := &runtime.Runtime{ ContextName: "test-context", ProjectRoot: "/test/project", ConfigRoot: "/test/project/contexts/test-context", @@ -102,8 +102,8 @@ func setupProvisionerMocks(t *testing.T) *Mocks { Shell: mockShell, } - provisionerCtx := &ProvisionerExecutionContext{ - ExecutionContext: *execCtx, + provisionerCtx := &ProvisionerRuntime{ + Runtime: *execCtx, TerraformStack: terraformStack, KubernetesManager: kubernetesManager, KubernetesClient: kubernetesClient, @@ -125,7 +125,7 @@ func setupProvisionerMocks(t *testing.T) *Mocks { KubernetesManager: kubernetesManager, KubernetesClient: kubernetesClient, ClusterClient: clusterClient, - ProvisionerExecutionContext: provisionerCtx, + ProvisionerRuntime: provisionerCtx, } } @@ -137,7 +137,7 @@ func TestNewProvisioner(t *testing.T) { t.Run("CreatesProvisionerWithDependencies", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) if provisioner == nil { t.Fatal("Expected Provisioner to be created") @@ -170,7 +170,7 @@ func TestNewProvisioner(t *testing.T) { t.Run("CreatesClusterClientForTalos", func(t *testing.T) { mocks := setupProvisionerMocks(t) - mocks.ProvisionerExecutionContext.ClusterClient = nil + mocks.ProvisionerRuntime.ClusterClient = nil mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { @@ -180,7 +180,7 @@ func TestNewProvisioner(t *testing.T) { return "" } - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) if provisioner.ClusterClient == nil { t.Error("Expected cluster client to be created for talos driver") @@ -189,7 +189,7 @@ func TestNewProvisioner(t *testing.T) { t.Run("CreatesClusterClientForOmni", func(t *testing.T) { mocks := setupProvisionerMocks(t) - mocks.ProvisionerExecutionContext.ClusterClient = nil + mocks.ProvisionerRuntime.ClusterClient = nil mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { @@ -199,7 +199,7 @@ func TestNewProvisioner(t *testing.T) { return "" } - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) if provisioner.ClusterClient == nil { t.Error("Expected cluster client to be created for omni driver") @@ -208,7 +208,7 @@ func TestNewProvisioner(t *testing.T) { t.Run("SkipsClusterClientForOtherDrivers", func(t *testing.T) { mocks := setupProvisionerMocks(t) - mocks.ProvisionerExecutionContext.ClusterClient = nil + mocks.ProvisionerRuntime.ClusterClient = nil mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string { @@ -218,7 +218,7 @@ func TestNewProvisioner(t *testing.T) { return "" } - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) if provisioner.ClusterClient != nil { t.Error("Expected cluster client to be nil for non-talos/omni driver") @@ -228,7 +228,7 @@ func TestNewProvisioner(t *testing.T) { t.Run("UsesExistingDependencies", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) if provisioner.TerraformStack != mocks.TerraformStack { t.Error("Expected existing terraform stack to be used") @@ -255,7 +255,7 @@ func TestNewProvisioner(t *testing.T) { func TestProvisioner_Up(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return nil @@ -274,7 +274,7 @@ func TestProvisioner_Up(t *testing.T) { t.Run("ErrorNilBlueprint", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) err := provisioner.Up(nil) @@ -289,7 +289,7 @@ func TestProvisioner_Up(t *testing.T) { t.Run("ErrorNilTerraformStack", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.TerraformStack = nil blueprint := createTestBlueprint() @@ -306,7 +306,7 @@ func TestProvisioner_Up(t *testing.T) { t.Run("ErrorTerraformStackInitialize", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return fmt.Errorf("initialize failed") @@ -326,7 +326,7 @@ func TestProvisioner_Up(t *testing.T) { t.Run("ErrorTerraformStackUp", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return nil @@ -351,7 +351,7 @@ func TestProvisioner_Up(t *testing.T) { func TestProvisioner_Down(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return nil @@ -370,7 +370,7 @@ func TestProvisioner_Down(t *testing.T) { t.Run("ErrorNilBlueprint", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) err := provisioner.Down(nil) @@ -385,7 +385,7 @@ func TestProvisioner_Down(t *testing.T) { t.Run("ErrorNilTerraformStack", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.TerraformStack = nil blueprint := createTestBlueprint() @@ -402,7 +402,7 @@ func TestProvisioner_Down(t *testing.T) { t.Run("ErrorTerraformStackInitialize", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return fmt.Errorf("initialize failed") @@ -422,7 +422,7 @@ func TestProvisioner_Down(t *testing.T) { t.Run("ErrorTerraformStackDown", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.TerraformStack.InitializeFunc = func() error { return nil @@ -447,7 +447,7 @@ func TestProvisioner_Down(t *testing.T) { func TestProvisioner_Install(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -466,7 +466,7 @@ func TestProvisioner_Install(t *testing.T) { t.Run("ErrorNilBlueprint", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) err := provisioner.Install(nil) @@ -481,7 +481,7 @@ func TestProvisioner_Install(t *testing.T) { t.Run("ErrorNilKubernetesManager", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.KubernetesManager = nil blueprint := createTestBlueprint() @@ -498,7 +498,7 @@ func TestProvisioner_Install(t *testing.T) { t.Run("ErrorKubernetesManagerInitialize", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return fmt.Errorf("initialize failed") @@ -518,7 +518,7 @@ func TestProvisioner_Install(t *testing.T) { t.Run("ErrorApplyBlueprint", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -543,7 +543,7 @@ func TestProvisioner_Install(t *testing.T) { func TestProvisioner_Wait(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -562,7 +562,7 @@ func TestProvisioner_Wait(t *testing.T) { t.Run("ErrorNilBlueprint", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) err := provisioner.Wait(nil) @@ -577,7 +577,7 @@ func TestProvisioner_Wait(t *testing.T) { t.Run("ErrorNilKubernetesManager", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.KubernetesManager = nil blueprint := createTestBlueprint() @@ -594,7 +594,7 @@ func TestProvisioner_Wait(t *testing.T) { t.Run("ErrorKubernetesManagerInitialize", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return fmt.Errorf("initialize failed") @@ -614,7 +614,7 @@ func TestProvisioner_Wait(t *testing.T) { t.Run("ErrorWaitForKustomizations", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -639,7 +639,7 @@ func TestProvisioner_Wait(t *testing.T) { func TestProvisioner_Close(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) closeCalled := false mocks.ClusterClient.CloseFunc = func() { @@ -655,7 +655,7 @@ func TestProvisioner_Close(t *testing.T) { t.Run("HandlesNilClusterClient", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.ClusterClient = nil provisioner.Close() @@ -667,20 +667,20 @@ func TestProvisioner_Close(t *testing.T) { } // ============================================================================= -// Test ProvisionerExecutionContext +// Test ProvisionerRuntime // ============================================================================= -func TestProvisionerExecutionContext(t *testing.T) { - t.Run("CreatesProvisionerExecutionContext", func(t *testing.T) { - execCtx := &context.ExecutionContext{ +func TestProvisionerRuntime(t *testing.T) { + t.Run("CreatesProvisionerRuntime", func(t *testing.T) { + execCtx := &runtime.Runtime{ ContextName: "test-context", ProjectRoot: "/test/project", ConfigRoot: "/test/project/contexts/test-context", TemplateRoot: "/test/project/contexts/_template", } - provisionerCtx := &ProvisionerExecutionContext{ - ExecutionContext: *execCtx, + provisionerCtx := &ProvisionerRuntime{ + Runtime: *execCtx, } if provisionerCtx.ContextName != "test-context" { @@ -708,7 +708,7 @@ func TestProvisionerExecutionContext(t *testing.T) { func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithNodeCheckOnly", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -741,7 +741,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithNodeCheckAndVersion", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -778,7 +778,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithKubernetesCheckOnly", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -814,7 +814,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithBothChecks", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -846,7 +846,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithNodeReadinessCheck", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -882,7 +882,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorNoHealthChecksSpecified", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) options := NodeHealthCheckOptions{ K8SEndpointProvided: false, @@ -901,7 +901,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorClusterClientWaitForNodesHealthy", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.ClusterClient.WaitForNodesHealthyFunc = func(ctx stdcontext.Context, nodeAddresses []string, expectedVersion string) error { return fmt.Errorf("cluster health check failed") @@ -925,7 +925,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("WarningClusterClientFailureWithK8sCheck", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) var outputMessages []string outputFunc := func(msg string) { @@ -969,7 +969,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorKubernetesManagerInitialize", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return fmt.Errorf("initialization failed") @@ -993,7 +993,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorKubernetesManagerWaitForKubernetesHealthy", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -1020,7 +1020,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorCheckNodeReadyRequiresNodes", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.KubernetesManager.InitializeFunc = func() error { return nil @@ -1045,7 +1045,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("ErrorNoKubernetesManager", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) provisioner.KubernetesManager = nil options := NodeHealthCheckOptions{ @@ -1066,7 +1066,7 @@ func TestProvisioner_CheckNodeHealth(t *testing.T) { t.Run("SuccessWithDefaultTimeout", func(t *testing.T) { mocks := setupProvisionerMocks(t) - provisioner := NewProvisioner(mocks.ProvisionerExecutionContext) + provisioner := NewProvisioner(mocks.ProvisionerRuntime) mocks.ClusterClient.WaitForNodesHealthyFunc = func(ctx stdcontext.Context, nodeAddresses []string, expectedVersion string) error { deadline, ok := ctx.Deadline() diff --git a/pkg/provisioner/terraform/stack.go b/pkg/provisioner/terraform/stack.go index 120cb3fb4..4f1f68428 100644 --- a/pkg/provisioner/terraform/stack.go +++ b/pkg/provisioner/terraform/stack.go @@ -16,8 +16,8 @@ import ( "strings" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - envvars "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/shell" + envvars "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/composer/blueprint" ) diff --git a/pkg/provisioner/terraform/stack_test.go b/pkg/provisioner/terraform/stack_test.go index 32ccf63f7..51e244b74 100644 --- a/pkg/provisioner/terraform/stack_test.go +++ b/pkg/provisioner/terraform/stack_test.go @@ -13,11 +13,11 @@ import ( "testing" blueprintv1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" - envvars "github.com/windsorcli/cli/pkg/context/env" + envvars "github.com/windsorcli/cli/pkg/runtime/env" "github.com/windsorcli/cli/pkg/composer/blueprint" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/context/config/config_handler.go b/pkg/runtime/config/config_handler.go similarity index 99% rename from pkg/context/config/config_handler.go rename to pkg/runtime/config/config_handler.go index 9e24c1c9c..fb4934003 100644 --- a/pkg/context/config/config_handler.go +++ b/pkg/runtime/config/config_handler.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/config/config_handler_private_test.go b/pkg/runtime/config/config_handler_private_test.go similarity index 99% rename from pkg/context/config/config_handler_private_test.go rename to pkg/runtime/config/config_handler_private_test.go index 125f607c2..658763b19 100644 --- a/pkg/context/config/config_handler_private_test.go +++ b/pkg/runtime/config/config_handler_private_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/context/config/config_handler_public_test.go b/pkg/runtime/config/config_handler_public_test.go similarity index 99% rename from pkg/context/config/config_handler_public_test.go rename to pkg/runtime/config/config_handler_public_test.go index 99e2d7233..94c8ac999 100644 --- a/pkg/context/config/config_handler_public_test.go +++ b/pkg/runtime/config/config_handler_public_test.go @@ -7,7 +7,7 @@ import ( "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/context/config/defaults.go b/pkg/runtime/config/defaults.go similarity index 100% rename from pkg/context/config/defaults.go rename to pkg/runtime/config/defaults.go diff --git a/pkg/context/config/defaults_test.go b/pkg/runtime/config/defaults_test.go similarity index 100% rename from pkg/context/config/defaults_test.go rename to pkg/runtime/config/defaults_test.go diff --git a/pkg/context/config/mock_config_handler.go b/pkg/runtime/config/mock_config_handler.go similarity index 100% rename from pkg/context/config/mock_config_handler.go rename to pkg/runtime/config/mock_config_handler.go diff --git a/pkg/context/config/mock_config_handler_test.go b/pkg/runtime/config/mock_config_handler_test.go similarity index 100% rename from pkg/context/config/mock_config_handler_test.go rename to pkg/runtime/config/mock_config_handler_test.go diff --git a/pkg/context/config/schema_validator.go b/pkg/runtime/config/schema_validator.go similarity index 99% rename from pkg/context/config/schema_validator.go rename to pkg/runtime/config/schema_validator.go index d86ae51b9..a8e74128b 100644 --- a/pkg/context/config/schema_validator.go +++ b/pkg/runtime/config/schema_validator.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/goccy/go-yaml" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The SchemaValidator is a JSON Schema validation component for Windsor blueprints. diff --git a/pkg/context/config/schema_validator_test.go b/pkg/runtime/config/schema_validator_test.go similarity index 99% rename from pkg/context/config/schema_validator_test.go rename to pkg/runtime/config/schema_validator_test.go index 5ed9cfe61..bd28c0c26 100644 --- a/pkg/context/config/schema_validator_test.go +++ b/pkg/runtime/config/schema_validator_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The SchemaValidatorTest is a comprehensive test suite for the SchemaValidator component. diff --git a/pkg/context/config/shims.go b/pkg/runtime/config/shims.go similarity index 100% rename from pkg/context/config/shims.go rename to pkg/runtime/config/shims.go diff --git a/pkg/context/env/aws_env.go b/pkg/runtime/env/aws_env.go similarity index 100% rename from pkg/context/env/aws_env.go rename to pkg/runtime/env/aws_env.go diff --git a/pkg/context/env/aws_env_test.go b/pkg/runtime/env/aws_env_test.go similarity index 99% rename from pkg/context/env/aws_env_test.go rename to pkg/runtime/env/aws_env_test.go index 7bc7ce082..2091da0e1 100644 --- a/pkg/context/env/aws_env_test.go +++ b/pkg/runtime/env/aws_env_test.go @@ -10,7 +10,7 @@ import ( "github.com/goccy/go-yaml" "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" ) // ============================================================================= diff --git a/pkg/context/env/azure_env.go b/pkg/runtime/env/azure_env.go similarity index 100% rename from pkg/context/env/azure_env.go rename to pkg/runtime/env/azure_env.go diff --git a/pkg/context/env/azure_env_test.go b/pkg/runtime/env/azure_env_test.go similarity index 98% rename from pkg/context/env/azure_env_test.go rename to pkg/runtime/env/azure_env_test.go index 606792903..682713c44 100644 --- a/pkg/context/env/azure_env_test.go +++ b/pkg/runtime/env/azure_env_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" ) // ============================================================================= diff --git a/pkg/context/env/docker_env.go b/pkg/runtime/env/docker_env.go similarity index 100% rename from pkg/context/env/docker_env.go rename to pkg/runtime/env/docker_env.go diff --git a/pkg/context/env/docker_env_test.go b/pkg/runtime/env/docker_env_test.go similarity index 99% rename from pkg/context/env/docker_env_test.go rename to pkg/runtime/env/docker_env_test.go index 87d691c69..b155fa156 100644 --- a/pkg/context/env/docker_env_test.go +++ b/pkg/runtime/env/docker_env_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/env/env.go b/pkg/runtime/env/env.go similarity index 97% rename from pkg/context/env/env.go rename to pkg/runtime/env/env.go index 11bde2e14..23a107be0 100644 --- a/pkg/context/env/env.go +++ b/pkg/runtime/env/env.go @@ -9,8 +9,8 @@ import ( "fmt" "slices" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/env/env_test.go b/pkg/runtime/env/env_test.go similarity index 99% rename from pkg/context/env/env_test.go rename to pkg/runtime/env/env_test.go index 349bec3e5..f1754d536 100644 --- a/pkg/context/env/env_test.go +++ b/pkg/runtime/env/env_test.go @@ -5,8 +5,8 @@ import ( "reflect" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/env/kube_env.go b/pkg/runtime/env/kube_env.go similarity index 100% rename from pkg/context/env/kube_env.go rename to pkg/runtime/env/kube_env.go diff --git a/pkg/context/env/kube_env_test.go b/pkg/runtime/env/kube_env_test.go similarity index 99% rename from pkg/context/env/kube_env_test.go rename to pkg/runtime/env/kube_env_test.go index f6f4866de..23e563d18 100644 --- a/pkg/context/env/kube_env_test.go +++ b/pkg/runtime/env/kube_env_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/pkg/context/env/mock_env.go b/pkg/runtime/env/mock_env.go similarity index 100% rename from pkg/context/env/mock_env.go rename to pkg/runtime/env/mock_env.go diff --git a/pkg/context/env/mock_env_test.go b/pkg/runtime/env/mock_env_test.go similarity index 100% rename from pkg/context/env/mock_env_test.go rename to pkg/runtime/env/mock_env_test.go diff --git a/pkg/context/env/shims.go b/pkg/runtime/env/shims.go similarity index 100% rename from pkg/context/env/shims.go rename to pkg/runtime/env/shims.go diff --git a/pkg/context/env/shims_test.go b/pkg/runtime/env/shims_test.go similarity index 100% rename from pkg/context/env/shims_test.go rename to pkg/runtime/env/shims_test.go diff --git a/pkg/context/env/talos_env.go b/pkg/runtime/env/talos_env.go similarity index 100% rename from pkg/context/env/talos_env.go rename to pkg/runtime/env/talos_env.go diff --git a/pkg/context/env/talos_env_test.go b/pkg/runtime/env/talos_env_test.go similarity index 99% rename from pkg/context/env/talos_env_test.go rename to pkg/runtime/env/talos_env_test.go index 2957489ad..6e6d0a0bc 100644 --- a/pkg/context/env/talos_env_test.go +++ b/pkg/runtime/env/talos_env_test.go @@ -6,7 +6,7 @@ import ( "path/filepath" "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" ) // ============================================================================= diff --git a/pkg/context/env/terraform_env.go b/pkg/runtime/env/terraform_env.go similarity index 100% rename from pkg/context/env/terraform_env.go rename to pkg/runtime/env/terraform_env.go diff --git a/pkg/context/env/terraform_env_test.go b/pkg/runtime/env/terraform_env_test.go similarity index 99% rename from pkg/context/env/terraform_env_test.go rename to pkg/runtime/env/terraform_env_test.go index 759bfc94d..67637f5f1 100644 --- a/pkg/context/env/terraform_env_test.go +++ b/pkg/runtime/env/terraform_env_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" ) // ============================================================================= diff --git a/pkg/context/env/windsor_env.go b/pkg/runtime/env/windsor_env.go similarity index 99% rename from pkg/context/env/windsor_env.go rename to pkg/runtime/env/windsor_env.go index 68d78a741..2fdb22dc4 100644 --- a/pkg/context/env/windsor_env.go +++ b/pkg/runtime/env/windsor_env.go @@ -16,7 +16,7 @@ import ( "strings" "time" - "github.com/windsorcli/cli/pkg/context/secrets" + "github.com/windsorcli/cli/pkg/runtime/secrets" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/env/windsor_env_test.go b/pkg/runtime/env/windsor_env_test.go similarity index 99% rename from pkg/context/env/windsor_env_test.go rename to pkg/runtime/env/windsor_env_test.go index 4eec3b465..c8b6dac76 100644 --- a/pkg/context/env/windsor_env_test.go +++ b/pkg/runtime/env/windsor_env_test.go @@ -7,8 +7,8 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/secrets" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/secrets" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/context.go b/pkg/runtime/runtime.go similarity index 92% rename from pkg/context/context.go rename to pkg/runtime/runtime.go index 8e970533b..50c5c767b 100644 --- a/pkg/context/context.go +++ b/pkg/runtime/runtime.go @@ -1,4 +1,4 @@ -package context +package runtime import ( "crypto/rand" @@ -12,19 +12,19 @@ import ( "strings" "time" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/env" - "github.com/windsorcli/cli/pkg/context/secrets" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/tools" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/env" + "github.com/windsorcli/cli/pkg/runtime/secrets" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/tools" "github.com/windsorcli/cli/pkg/di" ) -// ExecutionContext holds common execution values and core dependencies used across the Windsor CLI. +// Runtime holds common execution values and core dependencies used across the Windsor CLI. // These fields are set during various initialization steps rather than computed on-demand. // Includes secret providers for Sops and 1Password, enabling access to secrets across all contexts. // Also includes environment printers, tools manager, and environment variable/alias storage. -type ExecutionContext struct { +type Runtime struct { // ContextName is the current context name ContextName string @@ -75,15 +75,15 @@ type ExecutionContext struct { // Constructor // ============================================================================= -// NewContext creates a new ExecutionContext with ConfigHandler and Shell initialized if not already present. +// NewRuntime creates a new Runtime with ConfigHandler and Shell initialized if not already present. // This is the base constructor that ensures core dependencies are available. // If ConfigHandler is nil, it creates one using the Injector and initializes it. // If Shell is nil, it creates one using the Injector and initializes it. // Both are registered in the Injector for use by other components. // The context also initializes envVars and aliases maps, and automatically sets up // ContextName, ProjectRoot, ConfigRoot, and TemplateRoot based on the current project state. -// Returns the ExecutionContext with initialized dependencies or an error if initialization fails. -func NewContext(ctx *ExecutionContext) (*ExecutionContext, error) { +// Returns the Runtime with initialized dependencies or an error if initialization fails. +func NewRuntime(ctx *Runtime) (*Runtime, error) { if ctx == nil { return nil, fmt.Errorf("execution context is required") } @@ -166,7 +166,7 @@ func NewContext(ctx *ExecutionContext) (*ExecutionContext, error) { // CheckTrustedDirectory verifies that the current directory is in the trusted file list. // It delegates to the Shell's CheckTrustedDirectory method. Returns an error if the // directory is not trusted or if Shell is not initialized. -func (ctx *ExecutionContext) CheckTrustedDirectory() error { +func (ctx *Runtime) CheckTrustedDirectory() error { if ctx.Shell == nil { return fmt.Errorf("shell not initialized") } @@ -177,7 +177,7 @@ func (ctx *ExecutionContext) CheckTrustedDirectory() error { // The context paths (ContextName, ProjectRoot, ConfigRoot, TemplateRoot) are already // set up in the constructor, so this method only needs to load the configuration data. // Returns an error if configuration loading fails or if required dependencies are missing. -func (ctx *ExecutionContext) LoadConfig() error { +func (ctx *Runtime) LoadConfig() error { if ctx.ConfigHandler == nil { return fmt.Errorf("config handler not initialized") } @@ -189,7 +189,7 @@ func (ctx *ExecutionContext) LoadConfig() error { // variables if needed. It checks for WINDSOR_SESSION_TOKEN and uses the shell's CheckResetFlags // method to determine if a reset should occur. If reset is needed, it calls Shell.Reset() and // sets NO_CACHE=true. Returns an error if Shell is not initialized or if reset flag checking fails. -func (ctx *ExecutionContext) HandleSessionReset() error { +func (ctx *Runtime) HandleSessionReset() error { if ctx.Shell == nil { return fmt.Errorf("shell not initialized") } @@ -215,10 +215,10 @@ func (ctx *ExecutionContext) HandleSessionReset() error { // LoadEnvironment loads environment variables and aliases from all configured environment printers, // then executes post-environment hooks. It initializes all necessary components, optionally loads -// secrets if requested, and aggregates all environment variables and aliases into the ExecutionContext +// secrets if requested, and aggregates all environment variables and aliases into the Runtime // instance. Returns an error if any required dependency is missing or if any step fails. This method // expects the ConfigHandler to be set before invocation. -func (ctx *ExecutionContext) LoadEnvironment(decrypt bool) error { +func (ctx *Runtime) LoadEnvironment(decrypt bool) error { if ctx.ConfigHandler == nil { return fmt.Errorf("config handler not loaded") } @@ -283,7 +283,7 @@ func (ctx *ExecutionContext) LoadEnvironment(decrypt bool) error { // PrintEnvVars returns all collected environment variables in key=value format. // If no environment variables are loaded, returns an empty string. -func (ctx *ExecutionContext) PrintEnvVars() string { +func (ctx *Runtime) PrintEnvVars() string { if ctx.Shell == nil || len(ctx.envVars) == 0 { return "" } @@ -292,7 +292,7 @@ func (ctx *ExecutionContext) PrintEnvVars() string { // PrintEnvVarsExport returns all collected environment variables in export key=value format. // If no environment variables are loaded, returns an empty string. -func (ctx *ExecutionContext) PrintEnvVarsExport() string { +func (ctx *Runtime) PrintEnvVarsExport() string { if ctx.Shell == nil || len(ctx.envVars) == 0 { return "" } @@ -301,7 +301,7 @@ func (ctx *ExecutionContext) PrintEnvVarsExport() string { // PrintAliases returns all collected aliases using the shell's RenderAliases method. // If no aliases are loaded, returns an empty string. -func (ctx *ExecutionContext) PrintAliases() string { +func (ctx *Runtime) PrintAliases() string { if ctx.Shell == nil || len(ctx.aliases) == 0 { return "" } @@ -309,14 +309,14 @@ func (ctx *ExecutionContext) PrintAliases() string { } // GetEnvVars returns a copy of the collected environment variables. -func (ctx *ExecutionContext) GetEnvVars() map[string]string { +func (ctx *Runtime) GetEnvVars() map[string]string { result := make(map[string]string) maps.Copy(result, ctx.envVars) return result } // GetAliases returns a copy of the collected aliases. -func (ctx *ExecutionContext) GetAliases() map[string]string { +func (ctx *Runtime) GetAliases() map[string]string { result := make(map[string]string) maps.Copy(result, ctx.aliases) return result @@ -326,7 +326,7 @@ func (ctx *ExecutionContext) GetAliases() map[string]string { // It validates that all required tools are installed and meet minimum version requirements. // The tools manager must be initialized before calling this method. Returns an error if // the tools manager is not available or if tool checking fails. -func (ctx *ExecutionContext) CheckTools() error { +func (ctx *Runtime) CheckTools() error { if ctx.ToolsManager == nil { ctx.initializeToolsManager() if ctx.ToolsManager == nil { @@ -347,7 +347,7 @@ func (ctx *ExecutionContext) CheckTools() error { // GetBuildID retrieves the current build ID from the .windsor/.build-id file. // If no build ID exists, a new one is generated, persisted, and returned. // Returns the build ID string or an error if retrieval or persistence fails. -func (ctx *ExecutionContext) GetBuildID() (string, error) { +func (ctx *Runtime) GetBuildID() (string, error) { projectRoot := ctx.ProjectRoot if err := os.MkdirAll(projectRoot, 0750); err != nil { @@ -390,7 +390,7 @@ func (ctx *ExecutionContext) GetBuildID() (string, error) { // GenerateBuildID generates a new build ID and persists it to the .windsor/.build-id file, // overwriting any existing value. Returns the new build ID or an error if generation or persistence fails. -func (ctx *ExecutionContext) GenerateBuildID() (string, error) { +func (ctx *Runtime) GenerateBuildID() (string, error) { newBuildID, err := ctx.generateBuildID() if err != nil { return "", fmt.Errorf("failed to generate build ID: %w", err) @@ -410,7 +410,7 @@ func (ctx *ExecutionContext) GenerateBuildID() (string, error) { // initializeEnvPrinters initializes environment printers based on configuration settings. // It creates and registers the appropriate environment printers with the dependency injector // based on the current configuration state. -func (ctx *ExecutionContext) initializeEnvPrinters() { +func (ctx *Runtime) initializeEnvPrinters() { if ctx.EnvPrinters.AwsEnv == nil && ctx.ConfigHandler.GetBool("aws.enabled", false) { ctx.EnvPrinters.AwsEnv = env.NewAwsEnvPrinter(ctx.Injector) ctx.Injector.Register("awsEnv", ctx.EnvPrinters.AwsEnv) @@ -481,7 +481,7 @@ func (ctx *ExecutionContext) initializeEnvPrinters() { // initializeToolsManager initializes the tools manager if not already set. // It checks the injector for an existing tools manager first, and only creates a new one if not found. // It creates a new ToolsManager instance and registers it with the dependency injector. -func (ctx *ExecutionContext) initializeToolsManager() { +func (ctx *Runtime) initializeToolsManager() { if ctx.ToolsManager == nil { if existingManager := ctx.Injector.Resolve("toolsManager"); existingManager != nil { if toolsManager, ok := existingManager.(tools.ToolsManager); ok { @@ -498,7 +498,7 @@ func (ctx *ExecutionContext) initializeToolsManager() { // based on current configuration settings. The method sets up the SOPS provider if enabled with the // context's config root path, and sets up the 1Password provider if enabled, using a mock in test // scenarios. Providers are only initialized if not already present on the context. -func (ctx *ExecutionContext) initializeSecretsProviders() { +func (ctx *Runtime) initializeSecretsProviders() { if ctx.SecretsProviders.Sops == nil && ctx.ConfigHandler.GetBool("secrets.sops.enabled", false) { if existingProvider := ctx.Injector.Resolve("sopsSecretsProvider"); existingProvider != nil { if provider, ok := existingProvider.(secrets.SecretsProvider); ok { @@ -528,7 +528,7 @@ func (ctx *ExecutionContext) initializeSecretsProviders() { // getAllEnvPrinters returns all environment printers in a consistent order. // This ensures that environment variables are processed in a predictable sequence // with WindsorEnv being processed last to take precedence. -func (ctx *ExecutionContext) getAllEnvPrinters() []env.EnvPrinter { +func (ctx *Runtime) getAllEnvPrinters() []env.EnvPrinter { return []env.EnvPrinter{ ctx.EnvPrinters.AwsEnv, ctx.EnvPrinters.AzureEnv, @@ -544,7 +544,7 @@ func (ctx *ExecutionContext) getAllEnvPrinters() []env.EnvPrinter { // This includes initializing the tools manager (if present) and all configured environment printers. // Each component's Initialize method is called if the component is non-nil. // Returns an error if any initialization fails, otherwise returns nil. -func (ctx *ExecutionContext) initializeComponents() error { +func (ctx *Runtime) initializeComponents() error { if ctx.ToolsManager != nil { if err := ctx.ToolsManager.Initialize(); err != nil { return fmt.Errorf("failed to initialize tools manager: %w", err) @@ -562,7 +562,7 @@ func (ctx *ExecutionContext) initializeComponents() error { // loadSecrets loads secrets from configured secrets providers. // It attempts to load secrets from both SOPS and 1Password providers if they are available. -func (ctx *ExecutionContext) loadSecrets() error { +func (ctx *Runtime) loadSecrets() error { providers := []secrets.SecretsProvider{ ctx.SecretsProviders.Sops, ctx.SecretsProviders.Onepassword, @@ -581,7 +581,7 @@ func (ctx *ExecutionContext) loadSecrets() error { // writeBuildIDToFile writes the provided build ID string to the .windsor/.build-id file in the project root. // Ensures the .windsor directory exists before writing. Returns an error if directory creation or file write fails. -func (ctx *ExecutionContext) writeBuildIDToFile(buildID string) error { +func (ctx *Runtime) writeBuildIDToFile(buildID string) error { projectRoot := ctx.ProjectRoot if err := os.MkdirAll(projectRoot, 0750); err != nil { @@ -609,7 +609,7 @@ func (ctx *ExecutionContext) writeBuildIDToFile(buildID string) error { // and # is a sequential counter incremented for each build on the same day. If a build ID already exists for the current day, // the counter is incremented; otherwise, a new build ID is generated with counter set to 1. Ensures global ordering and uniqueness. // Returns the build ID string or an error if generation or retrieval fails. -func (ctx *ExecutionContext) generateBuildID() (string, error) { +func (ctx *Runtime) generateBuildID() (string, error) { now := time.Now() yy := now.Year() % 100 mm := int(now.Month()) @@ -660,7 +660,7 @@ func (ctx *ExecutionContext) generateBuildID() (string, error) { // incrementBuildID parses an existing build ID and increments its counter component. // If the date component differs from the current date, generates a new random number and resets the counter to 1. // Returns the incremented or reset build ID string, or an error if the input format is invalid. -func (ctx *ExecutionContext) incrementBuildID(existingBuildID, currentDate string) (string, error) { +func (ctx *Runtime) incrementBuildID(existingBuildID, currentDate string) (string, error) { parts := strings.Split(existingBuildID, ".") if len(parts) != 3 { return "", fmt.Errorf("invalid build ID format: %s", existingBuildID) @@ -690,7 +690,7 @@ func (ctx *ExecutionContext) incrementBuildID(existingBuildID, currentDate strin // and dev mode settings. For dev mode, it also sets the provider to "generic" if not already set. // This method should be called before loading configuration from disk to ensure defaults are applied first. // The context name is read from ctx.ContextName. Returns an error if any configuration operation fails. -func (ctx *ExecutionContext) ApplyConfigDefaults() error { +func (ctx *Runtime) ApplyConfigDefaults() error { contextName := ctx.ContextName if contextName == "" { contextName = "local" @@ -760,7 +760,7 @@ func (ctx *ExecutionContext) ApplyConfigDefaults() error { // For "generic", it sets the cluster driver to "talos". // If no provider is set but dev mode is enabled, it defaults the cluster driver to "talos". // The context name is read from ctx.ContextName. Returns an error if any configuration operation fails. -func (ctx *ExecutionContext) ApplyProviderDefaults(providerOverride string) error { +func (ctx *Runtime) ApplyProviderDefaults(providerOverride string) error { if ctx.ConfigHandler == nil { return fmt.Errorf("config handler not available") } @@ -811,7 +811,7 @@ func (ctx *ExecutionContext) ApplyProviderDefaults(providerOverride string) erro // It first checks that all required tools are installed and meet version requirements, // then installs any missing or outdated tools. The tools manager must be available. // Returns an error if the tools manager is not available or if checking or installation fails. -func (ctx *ExecutionContext) PrepareTools() error { +func (ctx *Runtime) PrepareTools() error { if ctx.ToolsManager == nil { ctx.initializeToolsManager() if ctx.ToolsManager == nil { diff --git a/pkg/context/context_test.go b/pkg/runtime/runtime_test.go similarity index 91% rename from pkg/context/context_test.go rename to pkg/runtime/runtime_test.go index d181cb94d..fe5364a2e 100644 --- a/pkg/context/context_test.go +++ b/pkg/runtime/runtime_test.go @@ -1,4 +1,4 @@ -package context +package runtime import ( "errors" @@ -9,9 +9,9 @@ import ( "testing" v1alpha1 "github.com/windsorcli/cli/api/v1alpha1" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/secrets" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/secrets" + "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) @@ -19,7 +19,7 @@ import ( // Test Setup // ============================================================================= -// setupEnvironmentMocks creates mock components for testing the ExecutionContext +// setupEnvironmentMocks creates mock components for testing the Runtime func setupEnvironmentMocks(t *testing.T) *Mocks { t.Helper() @@ -92,12 +92,12 @@ func setupEnvironmentMocks(t *testing.T) *Mocks { injector.Register("projectRoot", "/test/project") injector.Register("contextName", "test-context") - // Create execution context - paths will be set automatically by NewContext - execCtx := &ExecutionContext{ + // Create execution context - paths will be set automatically by NewRuntime + execCtx := &Runtime{ Injector: injector, } - ctx, err := NewContext(execCtx) + ctx, err := NewRuntime(execCtx) if err != nil { t.Fatalf("Failed to create context: %v", err) } @@ -106,7 +106,7 @@ func setupEnvironmentMocks(t *testing.T) *Mocks { Injector: injector, ConfigHandler: configHandler, Shell: shell, - ExecutionContext: ctx, + Runtime: ctx, } } @@ -115,18 +115,18 @@ type Mocks struct { Injector di.Injector ConfigHandler config.ConfigHandler Shell shell.Shell - ExecutionContext *ExecutionContext + Runtime *Runtime } // ============================================================================= // Test Constructor // ============================================================================= -func TestNewContext(t *testing.T) { +func TestNewRuntime(t *testing.T) { t.Run("CreatesContextWithDependencies", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime if ctx == nil { t.Fatal("Expected context to be created") @@ -172,7 +172,7 @@ func TestNewContext(t *testing.T) { }) t.Run("ErrorWhenContextIsNil", func(t *testing.T) { - _, err := NewContext(nil) + _, err := NewRuntime(nil) if err == nil { t.Error("Expected error when context is nil") @@ -184,9 +184,9 @@ func TestNewContext(t *testing.T) { }) t.Run("ErrorWhenInjectorIsNil", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} - _, err := NewContext(ctx) + _, err := NewRuntime(ctx) if err == nil { t.Error("Expected error when injector is nil") @@ -205,11 +205,11 @@ func TestNewContext(t *testing.T) { } injector.Register("configHandler", mockConfigHandler) - ctx := &ExecutionContext{ + ctx := &Runtime{ Injector: injector, } - result, err := NewContext(ctx) + result, err := NewRuntime(ctx) if err != nil { t.Errorf("Expected no error, got: %v", err) @@ -231,12 +231,12 @@ func TestNewContext(t *testing.T) { } injector.Register("shell", mockShell) - ctx := &ExecutionContext{ + ctx := &Runtime{ Injector: injector, Shell: mockShell, } - result, err := NewContext(ctx) + result, err := NewRuntime(ctx) if err != nil { t.Errorf("Expected no error, got: %v", err) @@ -252,10 +252,10 @@ func TestNewContext(t *testing.T) { // Test LoadEnvironment // ============================================================================= -func TestExecutionContext_LoadEnvironment(t *testing.T) { +func TestRuntime_LoadEnvironment(t *testing.T) { t.Run("LoadsEnvironmentSuccessfully", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime err := ctx.LoadEnvironment(false) @@ -277,7 +277,7 @@ func TestExecutionContext_LoadEnvironment(t *testing.T) { t.Run("HandlesConfigHandlerNotLoaded", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set config handler to nil to test error handling ctx.ConfigHandler = nil @@ -291,7 +291,7 @@ func TestExecutionContext_LoadEnvironment(t *testing.T) { t.Run("HandlesEnvPrinterInitializationError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime err := ctx.LoadEnvironment(false) @@ -311,10 +311,10 @@ func TestExecutionContext_LoadEnvironment(t *testing.T) { // Test PrintEnvVars // ============================================================================= -func TestExecutionContext_PrintEnvVars(t *testing.T) { +func TestRuntime_PrintEnvVars(t *testing.T) { t.Run("PrintsEnvironmentVariables", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up environment variables ctx.envVars = map[string]string{ @@ -331,7 +331,7 @@ func TestExecutionContext_PrintEnvVars(t *testing.T) { t.Run("HandlesEmptyEnvironmentVariables", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime output := ctx.PrintEnvVars() @@ -346,10 +346,10 @@ func TestExecutionContext_PrintEnvVars(t *testing.T) { // Test PrintAliases // ============================================================================= -func TestExecutionContext_PrintAliases(t *testing.T) { +func TestRuntime_PrintAliases(t *testing.T) { t.Run("PrintsAliases", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up aliases ctx.aliases = map[string]string{ @@ -366,7 +366,7 @@ func TestExecutionContext_PrintAliases(t *testing.T) { t.Run("HandlesEmptyAliases", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime output := ctx.PrintAliases() @@ -383,10 +383,10 @@ func TestExecutionContext_PrintAliases(t *testing.T) { // Test Getter Methods // ============================================================================= -func TestExecutionContext_GetEnvVars(t *testing.T) { +func TestRuntime_GetEnvVars(t *testing.T) { t.Run("ReturnsCopyOfEnvVars", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime original := map[string]string{ "TEST_VAR1": "value1", @@ -410,10 +410,10 @@ func TestExecutionContext_GetEnvVars(t *testing.T) { }) } -func TestExecutionContext_GetAliases(t *testing.T) { +func TestRuntime_GetAliases(t *testing.T) { t.Run("ReturnsCopyOfAliases", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime original := map[string]string{ "test1": "echo test1", @@ -441,10 +441,10 @@ func TestExecutionContext_GetAliases(t *testing.T) { // Test Private Methods // ============================================================================= -func TestExecutionContext_loadSecrets(t *testing.T) { +func TestRuntime_loadSecrets(t *testing.T) { t.Run("LoadsSecretsSuccessfully", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up mock secrets providers mockSopsProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -461,7 +461,7 @@ func TestExecutionContext_loadSecrets(t *testing.T) { t.Run("HandlesSecretsProviderError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up mock secrets provider that returns an error mockProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -483,7 +483,7 @@ func TestExecutionContext_loadSecrets(t *testing.T) { t.Run("HandlesNilProviders", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Leave providers as nil ctx.SecretsProviders.Sops = nil @@ -497,7 +497,7 @@ func TestExecutionContext_loadSecrets(t *testing.T) { t.Run("HandlesMixedProviders", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up one provider that works and one that's nil mockProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -511,10 +511,10 @@ func TestExecutionContext_loadSecrets(t *testing.T) { }) } -func TestExecutionContext_initializeSecretsProviders(t *testing.T) { +func TestRuntime_initializeSecretsProviders(t *testing.T) { t.Run("InitializesSopsProviderWhenEnabled", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Enable SOPS in config mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -539,7 +539,7 @@ func TestExecutionContext_initializeSecretsProviders(t *testing.T) { t.Run("InitializesOnepasswordProviderWhenEnabled", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Enable 1Password in config mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -564,7 +564,7 @@ func TestExecutionContext_initializeSecretsProviders(t *testing.T) { t.Run("SkipsProvidersWhenDisabled", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Disable both providers mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -585,7 +585,7 @@ func TestExecutionContext_initializeSecretsProviders(t *testing.T) { t.Run("DoesNotOverrideExistingProviders", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Pre-set a provider existingProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -609,10 +609,10 @@ func TestExecutionContext_initializeSecretsProviders(t *testing.T) { }) } -func TestExecutionContext_LoadEnvironment_WithSecrets(t *testing.T) { +func TestRuntime_LoadEnvironment_WithSecrets(t *testing.T) { t.Run("LoadsEnvironmentWithSecretsSuccessfully", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up mock secrets providers mockSopsProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -629,7 +629,7 @@ func TestExecutionContext_LoadEnvironment_WithSecrets(t *testing.T) { t.Run("HandlesSecretsLoadError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up mock secrets provider that returns an error mockProvider := secrets.NewMockSecretsProvider(mocks.Injector) @@ -650,10 +650,10 @@ func TestExecutionContext_LoadEnvironment_WithSecrets(t *testing.T) { }) } -func TestExecutionContext_PrintEnvVars_EdgeCases(t *testing.T) { +func TestRuntime_PrintEnvVars_EdgeCases(t *testing.T) { t.Run("HandlesNilShell", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.Shell = nil // This should not panic @@ -665,7 +665,7 @@ func TestExecutionContext_PrintEnvVars_EdgeCases(t *testing.T) { t.Run("HandlesEmptyEnvVars", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.envVars = make(map[string]string) result := ctx.PrintEnvVars() @@ -675,10 +675,10 @@ func TestExecutionContext_PrintEnvVars_EdgeCases(t *testing.T) { }) } -func TestExecutionContext_PrintEnvVarsExport_EdgeCases(t *testing.T) { +func TestRuntime_PrintEnvVarsExport_EdgeCases(t *testing.T) { t.Run("HandlesNilShell", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.Shell = nil // This should not panic @@ -690,7 +690,7 @@ func TestExecutionContext_PrintEnvVarsExport_EdgeCases(t *testing.T) { t.Run("HandlesEmptyEnvVars", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.envVars = make(map[string]string) result := ctx.PrintEnvVarsExport() @@ -700,10 +700,10 @@ func TestExecutionContext_PrintEnvVarsExport_EdgeCases(t *testing.T) { }) } -func TestExecutionContext_PrintAliases_EdgeCases(t *testing.T) { +func TestRuntime_PrintAliases_EdgeCases(t *testing.T) { t.Run("HandlesNilShell", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.Shell = nil // This should not panic @@ -715,7 +715,7 @@ func TestExecutionContext_PrintAliases_EdgeCases(t *testing.T) { t.Run("HandlesEmptyAliases", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.aliases = make(map[string]string) result := ctx.PrintAliases() @@ -725,10 +725,10 @@ func TestExecutionContext_PrintAliases_EdgeCases(t *testing.T) { }) } -func TestExecutionContext_initializeComponents_EdgeCases(t *testing.T) { +func TestRuntime_initializeComponents_EdgeCases(t *testing.T) { t.Run("HandlesToolsManagerInitializationError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up a mock tools manager that returns an error mockToolsManager := &MockToolsManager{} @@ -749,7 +749,7 @@ func TestExecutionContext_initializeComponents_EdgeCases(t *testing.T) { t.Run("HandlesEnvPrinterInitializationError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime // Set up a mock env printer that returns an error mockPrinter := &MockEnvPrinter{} @@ -884,10 +884,10 @@ func (m *MockEnvPrinter) Reset() { // Test CheckTools // ============================================================================= -func TestExecutionContext_CheckTools(t *testing.T) { +func TestRuntime_CheckTools(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockToolsManager := &MockToolsManager{} mockToolsManager.InitializeFunc = func() error { @@ -907,7 +907,7 @@ func TestExecutionContext_CheckTools(t *testing.T) { t.Run("InitializesToolsManagerWhenNil", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool { @@ -932,7 +932,7 @@ func TestExecutionContext_CheckTools(t *testing.T) { t.Run("HandlesToolsManagerInitializationError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ToolsManager = nil @@ -958,7 +958,7 @@ func TestExecutionContext_CheckTools(t *testing.T) { t.Run("HandlesToolsManagerCheckError", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockToolsManager := &MockToolsManager{} mockToolsManager.InitializeFunc = func() error { @@ -986,10 +986,10 @@ func TestExecutionContext_CheckTools(t *testing.T) { } -func TestExecutionContext_CheckTrustedDirectory(t *testing.T) { +func TestRuntime_CheckTrustedDirectory(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockShell := mocks.Shell.(*shell.MockShell) mockShell.CheckTrustedDirectoryFunc = func() error { @@ -1004,7 +1004,7 @@ func TestExecutionContext_CheckTrustedDirectory(t *testing.T) { }) t.Run("ErrorWhenShellNotInitialized", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} err := ctx.CheckTrustedDirectory() @@ -1019,7 +1019,7 @@ func TestExecutionContext_CheckTrustedDirectory(t *testing.T) { t.Run("ErrorWhenCheckFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockShell := mocks.Shell.(*shell.MockShell) mockShell.CheckTrustedDirectoryFunc = func() error { @@ -1038,10 +1038,10 @@ func TestExecutionContext_CheckTrustedDirectory(t *testing.T) { }) } -func TestExecutionContext_LoadConfig(t *testing.T) { +func TestRuntime_LoadConfig(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.LoadConfigFunc = func() error { @@ -1056,7 +1056,7 @@ func TestExecutionContext_LoadConfig(t *testing.T) { }) t.Run("ErrorWhenConfigHandlerNotInitialized", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} err := ctx.LoadConfig() @@ -1071,7 +1071,7 @@ func TestExecutionContext_LoadConfig(t *testing.T) { t.Run("ErrorWhenLoadConfigFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.LoadConfigFunc = func() error { @@ -1090,7 +1090,7 @@ func TestExecutionContext_LoadConfig(t *testing.T) { }) } -func TestExecutionContext_HandleSessionReset(t *testing.T) { +func TestRuntime_HandleSessionReset(t *testing.T) { t.Run("ResetsWhenNoSessionToken", func(t *testing.T) { t.Cleanup(func() { os.Unsetenv("NO_CACHE") @@ -1099,7 +1099,7 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { os.Unsetenv("WINDSOR_SESSION_TOKEN") mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockShell := mocks.Shell.(*shell.MockShell) resetCalled := false @@ -1127,7 +1127,7 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { }) mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockShell := mocks.Shell.(*shell.MockShell) resetCalled := false @@ -1151,7 +1151,7 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { t.Run("SkipsResetWhenSessionTokenAndNoResetFlag", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime t.Setenv("WINDSOR_SESSION_TOKEN", "test-token") @@ -1176,7 +1176,7 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { }) t.Run("ErrorWhenShellNotInitialized", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} err := ctx.HandleSessionReset() @@ -1191,7 +1191,7 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { t.Run("ErrorWhenCheckResetFlagsFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockShell := mocks.Shell.(*shell.MockShell) mockShell.CheckResetFlagsFunc = func() (bool, error) { @@ -1210,10 +1210,10 @@ func TestExecutionContext_HandleSessionReset(t *testing.T) { }) } -func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { +func TestRuntime_ApplyConfigDefaults(t *testing.T) { t.Run("SkipsWhenConfigAlreadyLoaded", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) mockConfigHandler.IsLoadedFunc = func() bool { @@ -1229,7 +1229,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("SetsDefaultsForDevMode", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1275,7 +1275,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { }) t.Run("ErrorWhenConfigHandlerNotAvailable", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} err := ctx.ApplyConfigDefaults() @@ -1290,7 +1290,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("ErrorWhenSetDevFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1323,7 +1323,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("SetsDefaultsForNonDevMode", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1360,7 +1360,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("SetsVMDriverForDockerDesktop", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1406,7 +1406,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("ErrorWhenSetDefaultFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1441,7 +1441,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("ErrorWhenSetVMDriverFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1479,7 +1479,7 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { t.Run("ErrorWhenSetProviderFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1516,10 +1516,10 @@ func TestExecutionContext_ApplyConfigDefaults(t *testing.T) { }) } -func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { +func TestRuntime_ApplyProviderDefaults(t *testing.T) { t.Run("SetsAWSDefaults", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1546,7 +1546,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("SetsAzureDefaults", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1573,7 +1573,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("SetsGenericDefaults", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1595,7 +1595,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { }) t.Run("ErrorWhenConfigHandlerNotAvailable", func(t *testing.T) { - ctx := &ExecutionContext{} + ctx := &Runtime{} err := ctx.ApplyProviderDefaults("aws") @@ -1610,7 +1610,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("ErrorWhenSetFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1634,7 +1634,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("SetsDefaultsForDevModeWithNoProvider", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1670,7 +1670,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("GetsProviderFromConfig", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1700,7 +1700,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("ErrorWhenSetClusterDriverFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1730,7 +1730,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("ErrorWhenSetAzureDriverFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "prod" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1754,7 +1754,7 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { t.Run("ErrorWhenSetDevModeClusterDriverFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime ctx.ContextName = "local" mockConfigHandler := mocks.ConfigHandler.(*config.MockConfigHandler) @@ -1789,10 +1789,10 @@ func TestExecutionContext_ApplyProviderDefaults(t *testing.T) { }) } -func TestExecutionContext_PrepareTools(t *testing.T) { +func TestRuntime_PrepareTools(t *testing.T) { t.Run("Success", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockToolsManager := &MockToolsManager{} mockToolsManager.CheckFunc = func() error { @@ -1812,7 +1812,7 @@ func TestExecutionContext_PrepareTools(t *testing.T) { t.Run("ErrorWhenCheckFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockToolsManager := &MockToolsManager{} mockToolsManager.CheckFunc = func() error { @@ -1833,7 +1833,7 @@ func TestExecutionContext_PrepareTools(t *testing.T) { t.Run("ErrorWhenInstallFails", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime mockToolsManager := &MockToolsManager{} mockToolsManager.CheckFunc = func() error { @@ -1856,10 +1856,10 @@ func TestExecutionContext_PrepareTools(t *testing.T) { }) } -func TestExecutionContext_GetBuildID(t *testing.T) { +func TestRuntime_GetBuildID(t *testing.T) { t.Run("CreatesNewBuildIDWhenNoneExists", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1877,7 +1877,7 @@ func TestExecutionContext_GetBuildID(t *testing.T) { t.Run("ReturnsExistingBuildID", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1898,10 +1898,10 @@ func TestExecutionContext_GetBuildID(t *testing.T) { }) } -func TestExecutionContext_GenerateBuildID(t *testing.T) { +func TestRuntime_GenerateBuildID(t *testing.T) { t.Run("GeneratesAndSavesBuildID", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1919,7 +1919,7 @@ func TestExecutionContext_GenerateBuildID(t *testing.T) { t.Run("IncrementsBuildIDOnSubsequentCalls", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1941,7 +1941,7 @@ func TestExecutionContext_GenerateBuildID(t *testing.T) { t.Run("ErrorOnInvalidFormat", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1959,7 +1959,7 @@ func TestExecutionContext_GenerateBuildID(t *testing.T) { t.Run("ErrorOnInvalidCounter", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir @@ -1977,7 +1977,7 @@ func TestExecutionContext_GenerateBuildID(t *testing.T) { t.Run("ResetsCounterOnDateChange", func(t *testing.T) { mocks := setupEnvironmentMocks(t) - ctx := mocks.ExecutionContext + ctx := mocks.Runtime tmpDir := t.TempDir() ctx.ProjectRoot = tmpDir diff --git a/pkg/context/secrets/mock_secrets_provider.go b/pkg/runtime/secrets/mock_secrets_provider.go similarity index 100% rename from pkg/context/secrets/mock_secrets_provider.go rename to pkg/runtime/secrets/mock_secrets_provider.go diff --git a/pkg/context/secrets/mock_secrets_provider_test.go b/pkg/runtime/secrets/mock_secrets_provider_test.go similarity index 100% rename from pkg/context/secrets/mock_secrets_provider_test.go rename to pkg/runtime/secrets/mock_secrets_provider_test.go diff --git a/pkg/context/secrets/op_cli_secrets_provider.go b/pkg/runtime/secrets/op_cli_secrets_provider.go similarity index 100% rename from pkg/context/secrets/op_cli_secrets_provider.go rename to pkg/runtime/secrets/op_cli_secrets_provider.go diff --git a/pkg/context/secrets/op_cli_secrets_provider_test.go b/pkg/runtime/secrets/op_cli_secrets_provider_test.go similarity index 100% rename from pkg/context/secrets/op_cli_secrets_provider_test.go rename to pkg/runtime/secrets/op_cli_secrets_provider_test.go diff --git a/pkg/context/secrets/op_sdk_secrets_provider.go b/pkg/runtime/secrets/op_sdk_secrets_provider.go similarity index 100% rename from pkg/context/secrets/op_sdk_secrets_provider.go rename to pkg/runtime/secrets/op_sdk_secrets_provider.go diff --git a/pkg/context/secrets/op_sdk_secrets_provider_test.go b/pkg/runtime/secrets/op_sdk_secrets_provider_test.go similarity index 100% rename from pkg/context/secrets/op_sdk_secrets_provider_test.go rename to pkg/runtime/secrets/op_sdk_secrets_provider_test.go diff --git a/pkg/context/secrets/secrets_provider.go b/pkg/runtime/secrets/secrets_provider.go similarity index 99% rename from pkg/context/secrets/secrets_provider.go rename to pkg/runtime/secrets/secrets_provider.go index b9dc5aaec..78e674916 100644 --- a/pkg/context/secrets/secrets_provider.go +++ b/pkg/runtime/secrets/secrets_provider.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The SecretsProvider is a core interface for secrets management diff --git a/pkg/context/secrets/secrets_provider_test.go b/pkg/runtime/secrets/secrets_provider_test.go similarity index 99% rename from pkg/context/secrets/secrets_provider_test.go rename to pkg/runtime/secrets/secrets_provider_test.go index c8d82cba5..c3d85b1d6 100644 --- a/pkg/context/secrets/secrets_provider_test.go +++ b/pkg/runtime/secrets/secrets_provider_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The SecretsProviderTest is a test suite for the SecretsProvider interface diff --git a/pkg/context/secrets/shims.go b/pkg/runtime/secrets/shims.go similarity index 100% rename from pkg/context/secrets/shims.go rename to pkg/runtime/secrets/shims.go diff --git a/pkg/context/secrets/shims_test.go b/pkg/runtime/secrets/shims_test.go similarity index 100% rename from pkg/context/secrets/shims_test.go rename to pkg/runtime/secrets/shims_test.go diff --git a/pkg/context/secrets/sops_secrets_provider.go b/pkg/runtime/secrets/sops_secrets_provider.go similarity index 100% rename from pkg/context/secrets/sops_secrets_provider.go rename to pkg/runtime/secrets/sops_secrets_provider.go diff --git a/pkg/context/secrets/sops_secrets_provider_test.go b/pkg/runtime/secrets/sops_secrets_provider_test.go similarity index 100% rename from pkg/context/secrets/sops_secrets_provider_test.go rename to pkg/runtime/secrets/sops_secrets_provider_test.go diff --git a/pkg/context/shell/hooks.go b/pkg/runtime/shell/hooks.go similarity index 100% rename from pkg/context/shell/hooks.go rename to pkg/runtime/shell/hooks.go diff --git a/pkg/context/shell/mock_shell.go b/pkg/runtime/shell/mock_shell.go similarity index 100% rename from pkg/context/shell/mock_shell.go rename to pkg/runtime/shell/mock_shell.go diff --git a/pkg/context/shell/mock_shell_test.go b/pkg/runtime/shell/mock_shell_test.go similarity index 100% rename from pkg/context/shell/mock_shell_test.go rename to pkg/runtime/shell/mock_shell_test.go diff --git a/pkg/context/shell/scrubbing_writer.go b/pkg/runtime/shell/scrubbing_writer.go similarity index 100% rename from pkg/context/shell/scrubbing_writer.go rename to pkg/runtime/shell/scrubbing_writer.go diff --git a/pkg/context/shell/secure_shell.go b/pkg/runtime/shell/secure_shell.go similarity index 98% rename from pkg/context/shell/secure_shell.go rename to pkg/runtime/shell/secure_shell.go index c92997d2b..8c03d5ccc 100644 --- a/pkg/context/shell/secure_shell.go +++ b/pkg/runtime/shell/secure_shell.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" ) // The SecureShell is a secure implementation of the Shell interface using SSH. diff --git a/pkg/context/shell/secure_shell_test.go b/pkg/runtime/shell/secure_shell_test.go similarity index 99% rename from pkg/context/shell/secure_shell_test.go rename to pkg/runtime/shell/secure_shell_test.go index f7cde86dc..726f74072 100644 --- a/pkg/context/shell/secure_shell_test.go +++ b/pkg/runtime/shell/secure_shell_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" ) // The SecureShellTest is a test suite for the SecureShell implementation. diff --git a/pkg/context/shell/shell.go b/pkg/runtime/shell/shell.go similarity index 100% rename from pkg/context/shell/shell.go rename to pkg/runtime/shell/shell.go diff --git a/pkg/context/shell/shell_test.go b/pkg/runtime/shell/shell_test.go similarity index 100% rename from pkg/context/shell/shell_test.go rename to pkg/runtime/shell/shell_test.go diff --git a/pkg/context/shell/shims.go b/pkg/runtime/shell/shims.go similarity index 100% rename from pkg/context/shell/shims.go rename to pkg/runtime/shell/shims.go diff --git a/pkg/context/shell/shims_test.go b/pkg/runtime/shell/shims_test.go similarity index 100% rename from pkg/context/shell/shims_test.go rename to pkg/runtime/shell/shims_test.go diff --git a/pkg/context/shell/ssh/client.go b/pkg/runtime/shell/ssh/client.go similarity index 100% rename from pkg/context/shell/ssh/client.go rename to pkg/runtime/shell/ssh/client.go diff --git a/pkg/context/shell/ssh/client_test.go b/pkg/runtime/shell/ssh/client_test.go similarity index 100% rename from pkg/context/shell/ssh/client_test.go rename to pkg/runtime/shell/ssh/client_test.go diff --git a/pkg/context/shell/ssh/mock_client.go b/pkg/runtime/shell/ssh/mock_client.go similarity index 100% rename from pkg/context/shell/ssh/mock_client.go rename to pkg/runtime/shell/ssh/mock_client.go diff --git a/pkg/context/shell/ssh/mock_client_test.go b/pkg/runtime/shell/ssh/mock_client_test.go similarity index 100% rename from pkg/context/shell/ssh/mock_client_test.go rename to pkg/runtime/shell/ssh/mock_client_test.go diff --git a/pkg/context/shell/ssh/real_client.go b/pkg/runtime/shell/ssh/real_client.go similarity index 100% rename from pkg/context/shell/ssh/real_client.go rename to pkg/runtime/shell/ssh/real_client.go diff --git a/pkg/context/shell/ssh/shims.go b/pkg/runtime/shell/ssh/shims.go similarity index 100% rename from pkg/context/shell/ssh/shims.go rename to pkg/runtime/shell/ssh/shims.go diff --git a/pkg/context/shell/unix_shell.go b/pkg/runtime/shell/unix_shell.go similarity index 100% rename from pkg/context/shell/unix_shell.go rename to pkg/runtime/shell/unix_shell.go diff --git a/pkg/context/shell/unix_shell_test.go b/pkg/runtime/shell/unix_shell_test.go similarity index 100% rename from pkg/context/shell/unix_shell_test.go rename to pkg/runtime/shell/unix_shell_test.go diff --git a/pkg/context/shell/windows_shell.go b/pkg/runtime/shell/windows_shell.go similarity index 100% rename from pkg/context/shell/windows_shell.go rename to pkg/runtime/shell/windows_shell.go diff --git a/pkg/context/shell/windows_shell_test.go b/pkg/runtime/shell/windows_shell_test.go similarity index 100% rename from pkg/context/shell/windows_shell_test.go rename to pkg/runtime/shell/windows_shell_test.go diff --git a/pkg/context/tools/mock_tools_manager.go b/pkg/runtime/tools/mock_tools_manager.go similarity index 100% rename from pkg/context/tools/mock_tools_manager.go rename to pkg/runtime/tools/mock_tools_manager.go diff --git a/pkg/context/tools/mock_tools_manager_test.go b/pkg/runtime/tools/mock_tools_manager_test.go similarity index 100% rename from pkg/context/tools/mock_tools_manager_test.go rename to pkg/runtime/tools/mock_tools_manager_test.go diff --git a/pkg/context/tools/shims.go b/pkg/runtime/tools/shims.go similarity index 100% rename from pkg/context/tools/shims.go rename to pkg/runtime/tools/shims.go diff --git a/pkg/context/tools/tools_manager.go b/pkg/runtime/tools/tools_manager.go similarity index 98% rename from pkg/context/tools/tools_manager.go rename to pkg/runtime/tools/tools_manager.go index b1498d693..aea94e79d 100644 --- a/pkg/context/tools/tools_manager.go +++ b/pkg/runtime/tools/tools_manager.go @@ -11,9 +11,9 @@ import ( "github.com/briandowns/spinner" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - sh "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + sh "github.com/windsorcli/cli/pkg/runtime/shell" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/context/tools/tools_manager_test.go b/pkg/runtime/tools/tools_manager_test.go similarity index 99% rename from pkg/context/tools/tools_manager_test.go rename to pkg/runtime/tools/tools_manager_test.go index b5a1c64c9..f38b069e6 100644 --- a/pkg/context/tools/tools_manager_test.go +++ b/pkg/runtime/tools/tools_manager_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/constants" "github.com/windsorcli/cli/pkg/di" - sh "github.com/windsorcli/cli/pkg/context/shell" + sh "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/workstation/network/colima_network.go b/pkg/workstation/network/colima_network.go index b40b6a28e..e10257d13 100644 --- a/pkg/workstation/network/colima_network.go +++ b/pkg/workstation/network/colima_network.go @@ -7,8 +7,8 @@ import ( "github.com/windsorcli/cli/pkg/constants" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" "github.com/windsorcli/cli/pkg/workstation/services" ) diff --git a/pkg/workstation/network/network.go b/pkg/workstation/network/network.go index ef220c78d..4b8b90d0e 100644 --- a/pkg/workstation/network/network.go +++ b/pkg/workstation/network/network.go @@ -6,9 +6,9 @@ import ( "sort" "github.com/windsorcli/cli/pkg/constants" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/workstation/services" ) diff --git a/pkg/workstation/network/network_test.go b/pkg/workstation/network/network_test.go index 82d747e26..990b90de2 100644 --- a/pkg/workstation/network/network_test.go +++ b/pkg/workstation/network/network_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/workstation/services" ) diff --git a/pkg/workstation/services/dns_service_test.go b/pkg/workstation/services/dns_service_test.go index 8d4967e5d..9cbd6bfdf 100644 --- a/pkg/workstation/services/dns_service_test.go +++ b/pkg/workstation/services/dns_service_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/compose-spec/compose-go/v2/types" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" ) diff --git a/pkg/workstation/services/registry_service_test.go b/pkg/workstation/services/registry_service_test.go index f91e3509a..84ffdf334 100644 --- a/pkg/workstation/services/registry_service_test.go +++ b/pkg/workstation/services/registry_service_test.go @@ -9,7 +9,7 @@ import ( "github.com/compose-spec/compose-go/v2/types" "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/api/v1alpha1/docker" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/constants" ) diff --git a/pkg/workstation/services/service.go b/pkg/workstation/services/service.go index 97bb7bfa4..afde7b6f2 100644 --- a/pkg/workstation/services/service.go +++ b/pkg/workstation/services/service.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/compose-spec/compose-go/v2/types" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The Service is a core interface that defines the contract for service implementations diff --git a/pkg/workstation/services/service_test.go b/pkg/workstation/services/service_test.go index 2220fa80d..62392824b 100644 --- a/pkg/workstation/services/service_test.go +++ b/pkg/workstation/services/service_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // The ServiceTest is a test suite for the Service interface and BaseService implementation diff --git a/pkg/workstation/virt/colima_virt_test.go b/pkg/workstation/virt/colima_virt_test.go index d85f74c8f..2edc3db77 100644 --- a/pkg/workstation/virt/colima_virt_test.go +++ b/pkg/workstation/virt/colima_virt_test.go @@ -16,7 +16,7 @@ import ( colimaConfig "github.com/abiosoft/colima/config" "github.com/goccy/go-yaml" "github.com/shirou/gopsutil/mem" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" ) // ============================================================================= diff --git a/pkg/workstation/virt/mock_virt_test.go b/pkg/workstation/virt/mock_virt_test.go index 7331627b9..2f137d61b 100644 --- a/pkg/workstation/virt/mock_virt_test.go +++ b/pkg/workstation/virt/mock_virt_test.go @@ -8,10 +8,10 @@ package virt import ( "testing" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/workstation/services" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/workstation/virt/virt.go b/pkg/workstation/virt/virt.go index 150db1619..bfe8a7380 100644 --- a/pkg/workstation/virt/virt.go +++ b/pkg/workstation/virt/virt.go @@ -10,9 +10,9 @@ import ( "os" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/workstation/virt/virt_test.go b/pkg/workstation/virt/virt_test.go index 0cd678ee7..8ae735673 100644 --- a/pkg/workstation/virt/virt_test.go +++ b/pkg/workstation/virt/virt_test.go @@ -14,10 +14,10 @@ import ( "github.com/goccy/go-yaml" "github.com/shirou/gopsutil/mem" - "github.com/windsorcli/cli/pkg/context/config" + "github.com/windsorcli/cli/pkg/runtime/config" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/workstation/services" - "github.com/windsorcli/cli/pkg/context/shell" + "github.com/windsorcli/cli/pkg/runtime/shell" ) // ============================================================================= diff --git a/pkg/workstation/workstation.go b/pkg/workstation/workstation.go index 266f67849..e3c2094a4 100644 --- a/pkg/workstation/workstation.go +++ b/pkg/workstation/workstation.go @@ -4,9 +4,9 @@ import ( "fmt" "os" - "github.com/windsorcli/cli/pkg/context" - "github.com/windsorcli/cli/pkg/context/shell/ssh" "github.com/windsorcli/cli/pkg/di" + "github.com/windsorcli/cli/pkg/runtime" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" "github.com/windsorcli/cli/pkg/workstation/network" "github.com/windsorcli/cli/pkg/workstation/services" "github.com/windsorcli/cli/pkg/workstation/virt" @@ -22,10 +22,10 @@ import ( // Types // ============================================================================= -// WorkstationExecutionContext holds the execution context for workstation operations. -// It embeds the base ExecutionContext and includes all workstation-specific dependencies. -type WorkstationExecutionContext struct { - context.ExecutionContext +// WorkstationRuntime holds the execution context for workstation operations. +// It embeds the base Runtime and includes all workstation-specific dependencies. +type WorkstationRuntime struct { + runtime.Runtime // Workstation-specific dependencies (created as needed) NetworkManager network.NetworkManager @@ -37,9 +37,9 @@ type WorkstationExecutionContext struct { // Workstation manages all workstation functionality including virtualization, // networking, services, and SSH operations. -// It embeds WorkstationExecutionContext so all fields are directly accessible. +// It embeds WorkstationRuntime so all fields are directly accessible. type Workstation struct { - *WorkstationExecutionContext + *WorkstationRuntime injector di.Injector } @@ -50,7 +50,7 @@ type Workstation struct { // NewWorkstation creates a new Workstation instance with the provided execution context and injector. // The execution context should already have ConfigHandler and Shell set. // Other dependencies are created only if not already present on the context. -func NewWorkstation(ctx *WorkstationExecutionContext, injector di.Injector) (*Workstation, error) { +func NewWorkstation(ctx *WorkstationRuntime, injector di.Injector) (*Workstation, error) { if ctx == nil { return nil, fmt.Errorf("execution context is required") } @@ -66,8 +66,8 @@ func NewWorkstation(ctx *WorkstationExecutionContext, injector di.Injector) (*Wo // Create workstation first workstation := &Workstation{ - WorkstationExecutionContext: ctx, - injector: injector, + WorkstationRuntime: ctx, + injector: injector, } // Create NetworkManager if not already set diff --git a/pkg/workstation/workstation_test.go b/pkg/workstation/workstation_test.go index 296aebd1c..547a0bd7a 100644 --- a/pkg/workstation/workstation_test.go +++ b/pkg/workstation/workstation_test.go @@ -8,10 +8,10 @@ import ( "github.com/windsorcli/cli/api/v1alpha1" "github.com/windsorcli/cli/api/v1alpha1/docker" - ctxpkg "github.com/windsorcli/cli/pkg/context" - "github.com/windsorcli/cli/pkg/context/config" - "github.com/windsorcli/cli/pkg/context/shell" - "github.com/windsorcli/cli/pkg/context/shell/ssh" + ctxpkg "github.com/windsorcli/cli/pkg/runtime" + "github.com/windsorcli/cli/pkg/runtime/config" + "github.com/windsorcli/cli/pkg/runtime/shell" + "github.com/windsorcli/cli/pkg/runtime/shell/ssh" "github.com/windsorcli/cli/pkg/di" "github.com/windsorcli/cli/pkg/workstation/network" "github.com/windsorcli/cli/pkg/workstation/services" @@ -202,9 +202,9 @@ func setupMocks(t *testing.T, opts ...*SetupOptions) *Mocks { } } -func setupWorkstationContext(mocks *Mocks) *WorkstationExecutionContext { - return &WorkstationExecutionContext{ - ExecutionContext: ctxpkg.ExecutionContext{ +func setupWorkstationContext(mocks *Mocks) *WorkstationRuntime { + return &WorkstationRuntime{ + Runtime: ctxpkg.Runtime{ ContextName: "test-context", ProjectRoot: "/test/project", ConfigRoot: "/test/project/contexts/test-context", @@ -270,8 +270,8 @@ func TestNewWorkstation(t *testing.T) { t.Run("NilConfigHandler", func(t *testing.T) { // Given mocks := setupMocks(t) - ctx := &WorkstationExecutionContext{ - ExecutionContext: ctxpkg.ExecutionContext{ + ctx := &WorkstationRuntime{ + Runtime: ctxpkg.Runtime{ Shell: mocks.Shell, }, } @@ -294,8 +294,8 @@ func TestNewWorkstation(t *testing.T) { t.Run("NilShell", func(t *testing.T) { // Given mocks := setupMocks(t) - ctx := &WorkstationExecutionContext{ - ExecutionContext: ctxpkg.ExecutionContext{ + ctx := &WorkstationRuntime{ + Runtime: ctxpkg.Runtime{ ConfigHandler: mocks.ConfigHandler, }, }