Skip to content

Commit 9ab1522

Browse files
authored
Merge pull request #897 from ManoManoTech/panic-oci-auth
Handle nil OCI authenticator with malformed registry
2 parents 9e853a9 + 03ba63b commit 9ab1522

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

controllers/helmrepository_controller_oci.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,5 +382,9 @@ func oidcAuthFromAdapter(ctx context.Context, url, provider string) (helmreg.Log
382382
return nil, err
383383
}
384384

385+
if auth == nil {
386+
return nil, fmt.Errorf("could not validate OCI provider %s with URL %s", provider, url)
387+
}
388+
385389
return registry.OIDCAdaptHelper(auth)
386390
}

controllers/helmrepository_controller_oci_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ func TestHelmRepositoryOCIReconciler_authStrategy(t *testing.T) {
229229
*conditions.FalseCondition(meta.ReadyCondition, sourcev1.AuthenticationFailedReason, "failed to get credential from"),
230230
},
231231
},
232+
{
233+
name: "with contextual login provider and invalid repository URL",
234+
wantErr: true,
235+
provider: "aws",
236+
providerImg: "oci://123456789000.dkr.ecr.us-east-2.amazonaws.com",
237+
assertConditions: []metav1.Condition{
238+
*conditions.FalseCondition(meta.ReadyCondition, sourcev1.AuthenticationFailedReason, "failed to get credential from"),
239+
},
240+
},
232241
{
233242
name: "with contextual login provider and secretRef",
234243
want: ctrl.Result{RequeueAfter: interval},

0 commit comments

Comments
 (0)