mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 12:17:52 +00:00
Merge pull request #81940 from carlory/fix-appserver
fix static check failures
This commit is contained in:
@@ -84,7 +84,6 @@ type Plugin struct {
|
||||
responseCache *cache.LRUExpireCache
|
||||
allowTTL time.Duration
|
||||
denyTTL time.Duration
|
||||
retryBackoff time.Duration
|
||||
defaultAllow bool
|
||||
}
|
||||
|
||||
|
@@ -984,6 +984,7 @@ func TestReturnedAnnotationAdd(t *testing.T) {
|
||||
pod *api.Pod
|
||||
verifierAnnotations map[string]string
|
||||
expectedAnnotations map[string]string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
test: "Add valid response annotations",
|
||||
@@ -1029,6 +1030,7 @@ func TestReturnedAnnotationAdd(t *testing.T) {
|
||||
expectedAnnotations: map[string]string{
|
||||
"imagepolicywebhook.image-policy.k8s.io/foo-test": "false",
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
@@ -1058,6 +1060,14 @@ func TestReturnedAnnotationAdd(t *testing.T) {
|
||||
attr = &fakeAttributes{attr, annotations}
|
||||
|
||||
err = wh.Validate(context.TODO(), attr, nil)
|
||||
if tt.wantErr {
|
||||
if err == nil {
|
||||
t.Errorf("%s: expected error making admission request: %v", tt.test, err)
|
||||
}
|
||||
} else if err != nil {
|
||||
t.Errorf("%s: failed to admit: %v", tt.test, err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(annotations, tt.expectedAnnotations) {
|
||||
t.Errorf("got audit annotations: %v; want: %v", annotations, tt.expectedAnnotations)
|
||||
}
|
||||
|
@@ -17,6 +17,8 @@ limitations under the License.
|
||||
// This file was generated using openssl by the gencerts.sh script
|
||||
// and holds raw certificates for the imagepolicy webhook tests.
|
||||
|
||||
//lint:file-ignore U1000 Ignore all unused code, it's generated
|
||||
|
||||
package imagepolicy
|
||||
|
||||
var caKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
|
||||
|
@@ -86,6 +86,8 @@ limitations under the License.
|
||||
// This file was generated using openssl by the gencerts.sh script
|
||||
// and holds raw certificates for the imagepolicy webhook tests.
|
||||
|
||||
//lint:file-ignore U1000 Ignore all unused code, it's generated
|
||||
|
||||
package imagepolicy
|
||||
EOF
|
||||
|
||||
|
@@ -232,13 +232,12 @@ func (p *Plugin) defaultGetNamespace(name string) (*corev1.Namespace, error) {
|
||||
|
||||
func (p *Plugin) getNodeSelectorMap(namespace *corev1.Namespace) (labels.Set, error) {
|
||||
selector := labels.Set{}
|
||||
labelsMap := labels.Set{}
|
||||
var err error
|
||||
found := false
|
||||
if len(namespace.ObjectMeta.Annotations) > 0 {
|
||||
for _, annotation := range NamespaceNodeSelectors {
|
||||
if ns, ok := namespace.ObjectMeta.Annotations[annotation]; ok {
|
||||
labelsMap, err = labels.ConvertSelectorToLabelsMap(ns)
|
||||
labelsMap, err := labels.ConvertSelectorToLabelsMap(ns)
|
||||
if err != nil {
|
||||
return labels.Set{}, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user