From 990953987ddd8e0070f45abeb84aa6262afb45fb Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 16 Aug 2024 15:09:38 -0400 Subject: [PATCH 1/2] Remove unused region flag --- cmd/klotho/up.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/klotho/up.go b/cmd/klotho/up.go index 29c198b7..46b93042 100644 --- a/cmd/klotho/up.go +++ b/cmd/klotho/up.go @@ -20,7 +20,6 @@ import ( var upConfig struct { stateDir string - region string debugMode string debugPort int } @@ -33,7 +32,6 @@ func newUpCmd() *cobra.Command { } flags := upCommand.Flags() flags.StringVar(&upConfig.stateDir, "state-directory", "", "State directory") - flags.StringVarP(&upConfig.region, "region", "r", "us-west-2", "AWS region") flags.StringVar(&upConfig.debugMode, "debug", "", "Debug mode") flags.IntVar(&upConfig.debugPort, "debug-port", 5678, "Language Host Debug port") return upCommand From acfaa3335c1148c0a62193a71c392a10c57b46e7 Mon Sep 17 00:00:00 2001 From: Gordon Date: Fri, 16 Aug 2024 17:53:17 -0400 Subject: [PATCH 2/2] Allow region change if no deployed resources --- cmd/klotho/dependencies.go | 7 ++++--- pkg/k2/orchestration/orchestrator.go | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/klotho/dependencies.go b/cmd/klotho/dependencies.go index f533be40..e8878848 100644 --- a/cmd/klotho/dependencies.go +++ b/cmd/klotho/dependencies.go @@ -4,12 +4,13 @@ import ( "context" "errors" "fmt" - "github.com/klothoplatform/klotho/pkg/logging" "os" "os/exec" "path/filepath" "runtime" + "github.com/klothoplatform/klotho/pkg/logging" + pulumi "github.com/pulumi/pulumi/sdk/v3" "github.com/pulumi/pulumi/sdk/v3/go/auto" ) @@ -95,8 +96,8 @@ func installPulumi(ctx context.Context) error { } func isDockerInstalled() bool { - // Check if docker is installed - cmd := exec.Command("docker", "--version") + // Check if docker is installed and the daemon is running + cmd := exec.Command("docker", "ps") err := cmd.Run() return err == nil } diff --git a/pkg/k2/orchestration/orchestrator.go b/pkg/k2/orchestration/orchestrator.go index d8d59ed7..d39bc21a 100644 --- a/pkg/k2/orchestration/orchestrator.go +++ b/pkg/k2/orchestration/orchestrator.go @@ -87,7 +87,15 @@ func (o *Orchestrator) resolveInitialState(ir *model.ApplicationEnvironment) (ma // Check for default region mismatch if state.DefaultRegion != ir.DefaultRegion { - return nil, fmt.Errorf("default region mismatch: %s != %s", state.DefaultRegion, ir.DefaultRegion) + deployed := make(map[string]model.ConstructStatus) + for k, v := range state.Constructs { + if model.IsDeletable(v.Status) { + deployed[k] = v.Status + } + } + if len(deployed) > 0 { + return nil, fmt.Errorf("cannot change region (%s -> %s) with deployed resources: %v", state.DefaultRegion, ir.DefaultRegion, deployed) + } } // Check for schema version mismatch