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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions src/pkg/stacks/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,14 @@ func (sm *manager) List(ctx context.Context) ([]ListItem, error) {
return nil, fmt.Errorf("failed to list local stacks: %w", err)
}
// Merge remote and local stacks into a single list of type StackOption,
// prefer local if both exist, but keep remote deployed time if available
// prefer remote if both exist
stackMap := make(map[string]ListItem)
for _, local := range localStacks {
stackMap[local.Name] = local
}
for _, remote := range remoteStacks {
stackMap[remote.Name] = remote
}
for _, local := range localStacks {
remote, exists := stackMap[local.Parameters.Name]
if exists {
local.DeployedAt = remote.DeployedAt
local.Default = remote.Default
stackMap[local.Parameters.Name] = local
} else {
stackMap[local.Parameters.Name] = ListItem{
Parameters: local.Parameters,
}
}
}

stackList := make([]ListItem, 0, len(stackMap))
for _, stack := range stackMap {
Expand Down
6 changes: 3 additions & 3 deletions src/pkg/stacks/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,10 @@ GOOGLE_REGION=us-central1
if !exists {
t.Error("Expected to find sharedstack")
}
assert.Equal(t, "us-west-2", sharedStack.Region, "Expected shared stack to use local region us-west-2")
assert.Equal(t, "us-east-1", sharedStack.Region, "Expected shared stack to use remote region us-east-1")
assert.Equal(t, client.ProviderAWS, sharedStack.Provider, "Expected shared stack to use provider aws")
assert.Equal(t, modes.ModeAffordable, sharedStack.Mode, "Expected shared stack to use mode AFFORDABLE")
assert.Equal(t, "default", sharedStack.Variables["AWS_PROFILE"], "Expected shared stack to have AWS_PROFILE variable from local stack")
assert.Equal(t, modes.ModeUnspecified, sharedStack.Mode, "Expected shared stack to use mode UNSPECIFIED")
assert.Equal(t, "", sharedStack.Variables["AWS_PROFILE"], "Expected shared stack to have empty AWS_PROFILE variable")
assert.Equal(t, deployedAt.Local().Format(time.RFC3339), sharedStack.DeployedAt.Local().Format(time.RFC3339), "Expected shared stack to have deployment time from remote")

// Check remote-only stack exists
Expand Down