Skip to content

Commit 03806b4

Browse files
authored
Merge pull request #31 from yue9944882/hack/fixes-nil-panic-from-sample-apiserver
Work-around for unwounding nil panic from bumping k8s dependencies to 1.20.1
2 parents faab081 + bdc4f11 commit 03806b4

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
Copyright 2016 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package server
18+
19+
import (
20+
"k8s.io/apiserver/pkg/server/options"
21+
)
22+
23+
// ValidateRecommendedOptions validates the options.
24+
//
25+
// A temporary work-around for https://github.com/kubernetes/kubernetes/pull/97954
26+
func ValidateRecommendedOptions(o *options.RecommendedOptions) []error {
27+
errors := []error{}
28+
29+
errors = append(errors, o.Etcd.Validate()...)
30+
errors = append(errors, o.SecureServing.Validate()...)
31+
32+
if o.Authentication != nil {
33+
errors = append(errors, o.Authentication.Validate()...)
34+
}
35+
if o.Authorization != nil {
36+
errors = append(errors, o.Authorization.Validate()...)
37+
}
38+
39+
errors = append(errors, o.Audit.Validate()...)
40+
errors = append(errors, o.Features.Validate()...)
41+
errors = append(errors, o.CoreAPI.Validate()...)
42+
errors = append(errors, o.Admission.Validate()...)
43+
errors = append(errors, o.EgressSelector.Validate()...)
44+
45+
return errors
46+
47+
}

internal/sample-apiserver/pkg/cmd/server/start.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ func NewCommandStartWardleServer(defaults *WardleServerOptions, stopCh <-chan st
8989
// Validate validates WardleServerOptions
9090
func (o WardleServerOptions) Validate(args []string) error {
9191
errors := []error{}
92-
errors = append(errors, o.RecommendedOptions.Validate()...)
92+
// TODO(1.21): revert this after https://github.com/kubernetes/kubernetes/pull/97954 fixed
93+
errors = append(errors, ValidateRecommendedOptions(o.RecommendedOptions)...)
9394
return utilerrors.NewAggregate(errors)
9495
}
9596

0 commit comments

Comments
 (0)