Skip to content

Commit 5ccd4c3

Browse files
update to use fallback approach
1 parent 883b427 commit 5ccd4c3

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

auth/credentials/internal/externalaccount/testdata/certificate_config_workload_use_ecp.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"cert_configs": {
3-
"workload": {
4-
"use_ecp": true
5-
}
63
},
74
"libs": {
85
"ecp": "./testdata/signer.sh"

auth/internal/transport/cert/testdata/certificate_config_workload_use_ecp.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
{
22
"cert_configs": {
3-
"workload": {
4-
"use_ecp": true
5-
}
63
},
74
"libs": {
85
"ecp": "./testdata/signer.sh"

auth/internal/transport/cert/workload_cert.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ type certConfigs struct {
3131
type workloadSource struct {
3232
CertPath string `json:"cert_path"`
3333
KeyPath string `json:"key_path"`
34-
UseEcp bool `json:"use_ecp"`
3534
}
3635

3736
type certificateConfig struct {
@@ -111,7 +110,6 @@ func NewWorkloadX509CertProvider(configFilePath string) (Provider, error) {
111110
source := &workloadSource{
112111
CertPath: certFile,
113112
KeyPath: keyFile,
114-
UseEcp: useEcp,
115113
}
116114
return source.getClientCertificate, nil
117115
}
@@ -145,22 +143,20 @@ func getCertKeyAndUseEcp(configFilePath string) (string, string, bool, error) {
145143
}
146144

147145
if config.CertConfigs.Workload == nil {
148-
return "", "", false, errSourceUnavailable
146+
// If 'workload' field is absent, it is an ECP config.
147+
return "", "", true, nil
149148
}
150149

151150
certFile := config.CertConfigs.Workload.CertPath
152151
keyFile := config.CertConfigs.Workload.KeyPath
153-
useEcp := config.CertConfigs.Workload.UseEcp
154152

155-
if !useEcp {
156-
if certFile == "" {
157-
return "", "", false, errors.New("certificate configuration is missing the certificate file location")
158-
}
153+
if certFile == "" {
154+
return "", "", false, errors.New("certificate configuration is missing the certificate file location")
155+
}
159156

160-
if keyFile == "" {
161-
return "", "", false, errors.New("certificate configuration is missing the key file location")
162-
}
157+
if keyFile == "" {
158+
return "", "", false, errors.New("certificate configuration is missing the key file location")
163159
}
164160

165-
return certFile, keyFile, useEcp, nil
161+
return certFile, keyFile, false, nil
166162
}

0 commit comments

Comments
 (0)