From b3f92f67c0e2ceb4839cb35eb13410b04ca52ec1 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Sun, 23 Oct 2022 12:53:13 -0400 Subject: [PATCH] review feedback --- pkg/authn/kubernetes/keychain.go | 5 ++++- pkg/name/fuzz_test.go | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pkg/name/fuzz_test.go diff --git a/pkg/authn/kubernetes/keychain.go b/pkg/authn/kubernetes/keychain.go index d468e1a9e..9e99b3139 100644 --- a/pkg/authn/kubernetes/keychain.go +++ b/pkg/authn/kubernetes/keychain.go @@ -86,7 +86,10 @@ func New(ctx context.Context, client kubernetes.Interface, opt Options) (authn.K if sa != nil { for _, localObj := range sa.ImagePullSecrets { ps, err := client.CoreV1().Secrets(opt.Namespace).Get(ctx, localObj.Name, metav1.GetOptions{}) - if err != nil { + if k8serrors.IsNotFound(err) { + logs.Warn.Printf("secret %s/%s not found; ignoring", opt.Namespace, localObj.Name) + continue + } else if err != nil { return nil, err } pullSecrets = append(pullSecrets, *ps) diff --git a/pkg/name/fuzz_test.go b/pkg/name/fuzz_test.go new file mode 100644 index 000000000..f79434656 --- /dev/null +++ b/pkg/name/fuzz_test.go @@ -0,0 +1,23 @@ +// Copyright 2022 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import "testing" + +func FuzzParseReference(f *testing.F) { + f.Fuzz(func(t *testing.T, s string) { + _, _ = ParseReference(s) + }) +}