Skip to content

Commit eb6e066

Browse files
committed
Change variable name and add logging when using dualstack
1 parent c25a0a0 commit eb6e066

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

agent/ecr/factory.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
2727
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials/providers"
2828
"github.com/aws/amazon-ecs-agent/ecs-agent/httpclient"
29+
"github.com/aws/amazon-ecs-agent/ecs-agent/logger"
2930
"github.com/aws/amazon-ecs-agent/ecs-agent/utils"
3031

3132
"github.com/aws/aws-sdk-go-v2/aws"
@@ -40,25 +41,25 @@ type ECRFactory interface {
4041
}
4142

4243
type ecrFactory struct {
43-
httpClient *http.Client
44-
isIPv6Only bool
44+
httpClient *http.Client
45+
useDualStackEndpoint bool
4546
}
4647

4748
const (
4849
roundtripTimeout = 5 * time.Second
4950
)
5051

5152
// NewECRFactory returns an ECRFactory capable of producing ECRSDK clients
52-
func NewECRFactory(acceptInsecureCert bool, isIPv6Only bool) ECRFactory {
53+
func NewECRFactory(acceptInsecureCert bool, useDualStackEndpoint bool) ECRFactory {
5354
return &ecrFactory{
54-
httpClient: httpclient.New(roundtripTimeout, acceptInsecureCert, agentversion.String(), config.OSType),
55-
isIPv6Only: isIPv6Only,
55+
httpClient: httpclient.New(roundtripTimeout, acceptInsecureCert, agentversion.String(), config.OSType),
56+
useDualStackEndpoint: useDualStackEndpoint,
5657
}
5758
}
5859

5960
// GetClient creates the ECR SDK client based on the authdata
6061
func (factory *ecrFactory) GetClient(authData *apicontainer.ECRAuthData) (ECRClient, error) {
61-
clientConfig, err := getClientConfig(factory.httpClient, authData, factory.isIPv6Only)
62+
clientConfig, err := getClientConfig(factory.httpClient, authData, factory.useDualStackEndpoint)
6263
if err != nil {
6364
return &ecrClient{}, err
6465
}
@@ -67,15 +68,16 @@ func (factory *ecrFactory) GetClient(authData *apicontainer.ECRAuthData) (ECRCli
6768
}
6869

6970
// getClientConfig returns the config for the ecr client based on authData
70-
func getClientConfig(httpClient *http.Client, authData *apicontainer.ECRAuthData, isIPv6Only bool) (*aws.Config, error) {
71+
func getClientConfig(httpClient *http.Client, authData *apicontainer.ECRAuthData, useDualStackEndpoint bool) (*aws.Config, error) {
7172
opts := []func(*awsconfig.LoadOptions) error{
7273
awsconfig.WithRegion(authData.Region),
7374
awsconfig.WithHTTPClient(httpClient),
7475
}
7576

7677
if authData.EndpointOverride != "" {
7778
opts = append(opts, awsconfig.WithBaseEndpoint(utils.AddScheme(authData.EndpointOverride)))
78-
} else if isIPv6Only {
79+
} else if useDualStackEndpoint {
80+
logger.Debug("Configuring ECR Client DualStack endpoint")
7981
opts = append(opts, awsconfig.WithUseDualStackEndpoint(aws.DualStackEndpointStateEnabled))
8082
}
8183

0 commit comments

Comments
 (0)