@@ -26,6 +26,7 @@ import (
26
26
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials"
27
27
"github.com/aws/amazon-ecs-agent/ecs-agent/credentials/providers"
28
28
"github.com/aws/amazon-ecs-agent/ecs-agent/httpclient"
29
+ "github.com/aws/amazon-ecs-agent/ecs-agent/logger"
29
30
"github.com/aws/amazon-ecs-agent/ecs-agent/utils"
30
31
31
32
"github.com/aws/aws-sdk-go-v2/aws"
@@ -40,25 +41,25 @@ type ECRFactory interface {
40
41
}
41
42
42
43
type ecrFactory struct {
43
- httpClient * http.Client
44
- isIPv6Only bool
44
+ httpClient * http.Client
45
+ useDualStackEndpoint bool
45
46
}
46
47
47
48
const (
48
49
roundtripTimeout = 5 * time .Second
49
50
)
50
51
51
52
// 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 {
53
54
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 ,
56
57
}
57
58
}
58
59
59
60
// GetClient creates the ECR SDK client based on the authdata
60
61
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 )
62
63
if err != nil {
63
64
return & ecrClient {}, err
64
65
}
@@ -67,15 +68,16 @@ func (factory *ecrFactory) GetClient(authData *apicontainer.ECRAuthData) (ECRCli
67
68
}
68
69
69
70
// 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 ) {
71
72
opts := []func (* awsconfig.LoadOptions ) error {
72
73
awsconfig .WithRegion (authData .Region ),
73
74
awsconfig .WithHTTPClient (httpClient ),
74
75
}
75
76
76
77
if authData .EndpointOverride != "" {
77
78
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" )
79
81
opts = append (opts , awsconfig .WithUseDualStackEndpoint (aws .DualStackEndpointStateEnabled ))
80
82
}
81
83
0 commit comments