Skip to content

Commit de85c34

Browse files
committed
Fallback to user-provided cluster from metadata
Fixes: docker-archive#1084, docker-archive#2086
1 parent 8a400d0 commit de85c34

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bin/
22
dist/
3+
/.idea/
34
/.vscode/

ecs/aws.go

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type API interface {
5151
GetStackID(ctx context.Context, name string) (string, error)
5252
ListStacks(ctx context.Context) ([]api.Stack, error)
5353
GetStackClusterID(ctx context.Context, stack string) (string, error)
54+
GetStackMetadataClusterID(ctx context.Context, stack string) (string, error)
5455
GetServiceTaskDefinition(ctx context.Context, cluster string, serviceArns []string) (map[string]string, error)
5556
ListStackServices(ctx context.Context, stack string) ([]string, error)
5657
GetServiceTasks(ctx context.Context, cluster string, service string, stopped bool) ([]*ecs.Task, error)

ecs/list.go

+6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ func (b *ecsAPIService) checkStackState(ctx context.Context, name string) error
7171
svcNames[r.ARN] = r.LogicalID
7272
}
7373
}
74+
if len(cluster) == 0 {
75+
cluster, err = b.aws.GetStackMetadataClusterID(ctx, name)
76+
if err != nil {
77+
return err
78+
}
79+
}
7480
if len(svcArns) == 0 {
7581
return nil
7682
}

ecs/sdk.go

+4
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,10 @@ func (s sdk) GetStackClusterID(ctx context.Context, stack string) (string, error
505505
token = response.NextToken
506506
}
507507
// stack is using user-provided cluster
508+
return s.GetStackMetadataClusterID(ctx, stack)
509+
}
510+
511+
func (s sdk) GetStackMetadataClusterID(ctx context.Context, stack string) (string, error) {
508512
res, err := s.CF.GetTemplateSummaryWithContext(ctx, &cloudformation.GetTemplateSummaryInput{
509513
StackName: aws.String(stack),
510514
})

0 commit comments

Comments
 (0)