Merge pull request #55379 from lichuqiang/admission_fix

Automatic merge from submit-queue (batch tested with PRs 54556, 55379, 55881, 55891, 55705). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Ensure config file exists before loading configuration in imagePolicyWebhook

**What this PR does / why we need it**:
ensure config file exists before loading configuration in imagePolicyWebhook

**Which issue(s) this PR fixes**
Fixes #55378

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-11-18 07:53:41 -08:00 committed by GitHub
commit 5033548574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -219,6 +219,10 @@ func (a *Plugin) admitPod(pod *api.Pod, attributes admission.Attributes, review
// For additional HTTP configuration, refer to the kubeconfig documentation // For additional HTTP configuration, refer to the kubeconfig documentation
// http://kubernetes.io/v1.1/docs/user-guide/kubeconfig-file.html. // http://kubernetes.io/v1.1/docs/user-guide/kubeconfig-file.html.
func NewImagePolicyWebhook(configFile io.Reader) (*Plugin, error) { func NewImagePolicyWebhook(configFile io.Reader) (*Plugin, error) {
if configFile == nil {
return nil, fmt.Errorf("no config specified")
}
// TODO: move this to a versioned configuration file format // TODO: move this to a versioned configuration file format
var config AdmissionConfig var config AdmissionConfig
d := yaml.NewYAMLOrJSONDecoder(configFile, 4096) d := yaml.NewYAMLOrJSONDecoder(configFile, 4096)