Skip to content

Commit

Permalink
Allow region change if no deployed resources
Browse files Browse the repository at this point in the history
  • Loading branch information
gordon-klotho committed Aug 16, 2024
1 parent 9909539 commit acfaa33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions cmd/klotho/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/k2/orchestration/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit acfaa33

Please sign in to comment.