Skip to content

Commit

Permalink
fix: run local --proxy should work when sc is off (#5604)
Browse files Browse the repository at this point in the history
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
iamhopaul123 authored Jan 11, 2024
1 parent 65383ed commit cc057a9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/pkg/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (c Client) ServiceConnectServices(app, env, svc string) ([]*ecs.Service, er
if err != nil {
return nil, fmt.Errorf("get service: %w", err)
}
if len(s.Deployments) == 0 {
if len(s.Deployments) == 0 || s.Deployments[0].ServiceConnectConfiguration == nil {
return nil, nil
}

Expand Down
36 changes: 36 additions & 0 deletions internal/pkg/ecs/ecs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,42 @@ func TestClient_ServiceConnectServices(t *testing.T) {
},
wantedError: fmt.Errorf(`get service: get ECS service mockService: some error`),
},
"return early when no deployments": {
setupMocks: func(m clientMocks) {
m.resourceGetter.EXPECT().GetResourcesByTags(serviceResourceType, getRgInput).
Return([]*resourcegroups.Resource{
{ARN: mockSvcARN},
}, nil)
m.resourceGetter.EXPECT().GetResourcesByTags(clusterResourceType, getRgEnvClusterInput).
Return([]*resourcegroups.Resource{
{ARN: "mockARN1"}, {ARN: "mockARN2"},
}, nil)
m.ecsClient.EXPECT().ActiveClusters("mockARN1", "mockARN2").Return([]string{"mockARN1"}, nil)
m.ecsClient.EXPECT().ActiveServices("mockARN1", []string{mockSvcARN}).Return([]string{mockSvcARN}, nil)
m.ecsClient.EXPECT().Service(mockCluster, mockService).Return(&ecs.Service{
Deployments: []*awsecs.Deployment{},
}, nil)
},
},
"return early when service connect is not enabled": {
setupMocks: func(m clientMocks) {
m.resourceGetter.EXPECT().GetResourcesByTags(serviceResourceType, getRgInput).
Return([]*resourcegroups.Resource{
{ARN: mockSvcARN},
}, nil)
m.resourceGetter.EXPECT().GetResourcesByTags(clusterResourceType, getRgEnvClusterInput).
Return([]*resourcegroups.Resource{
{ARN: "mockARN1"}, {ARN: "mockARN2"},
}, nil)
m.ecsClient.EXPECT().ActiveClusters("mockARN1", "mockARN2").Return([]string{"mockARN1"}, nil)
m.ecsClient.EXPECT().ActiveServices("mockARN1", []string{mockSvcARN}).Return([]string{mockSvcARN}, nil)
m.ecsClient.EXPECT().Service(mockCluster, mockService).Return(&ecs.Service{
Deployments: []*awsecs.Deployment{
{},
},
}, nil)
},
},
"error listing namespace": {
setupMocks: func(m clientMocks) {
m.resourceGetter.EXPECT().GetResourcesByTags(serviceResourceType, getRgInput).
Expand Down

0 comments on commit cc057a9

Please sign in to comment.