Skip to content

Commit d8ec153

Browse files
authored
Merge pull request #12 from CentML/ft/panic-on-ecr-creds-error
patch: panic if unable to get ecr creds
2 parents 982206c + 3adb19a commit d8ec153

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module github.com/centml/platform/ecr-anywhere
22

33
go 1.24.1
4-
toolchain go1.24.1
54

65
require (
76
k8s.io/api v0.30.2

pkg/credentials/credentials.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ func (ecu *ecrCredentialInjector) Inject(secret *corev1.Secret) (patching.Operat
111111
// Call the API to get ECR credentials
112112
res, err := ecu.ecrClient.GetAuthorizationToken(context.Background(), &ecr.GetAuthorizationTokenInput{})
113113
if err != nil {
114-
return nil, fmt.Errorf("failed to get authorization token: %w", err)
114+
ecu.ErrorLogger.Printf("Failed to get authorization token: %v", err)
115+
panic(fmt.Errorf("failed to get authorization token: %w", err))
115116
}
116117
ecu.InfoLogger.Print("Received authorization data")
117118

pkg/credentials/credentials_test.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,20 @@ func TestInject(t *testing.T) {
254254
for _, tt := range tests {
255255
t.Run(tt.name, func(t *testing.T) {
256256
tt.setupMock()
257-
258-
patches, err := injector.Inject(tt.secret)
259257
if tt.expectedError != "" {
260-
assert.EqualError(t, err, tt.expectedError)
258+
if tt.name == "GetAuthorizationToken fails" {
259+
assert.PanicsWithError(t, tt.expectedError, func() {
260+
_, _ = injector.Inject(tt.secret)
261+
})
262+
} else {
263+
_, err := injector.Inject(tt.secret)
264+
assert.EqualError(t, err, tt.expectedError)
265+
}
261266
} else {
267+
patches, err := injector.Inject(tt.secret)
262268
assert.NoError(t, err)
263269
assert.Equal(t, tt.expectedPatches, patches)
264270
}
265-
266271
mockECRClient.AssertExpectations(t)
267272
})
268273
}

0 commit comments

Comments
 (0)