Merge pull request #48915 from mattmoyer/fix-kubeadm-config-regression

Automatic merge from submit-queue

kubeadm: fix broken `kubeadm init --config` flag

**What this PR does / why we need it**:
This code was changed in ea196490a0 (https://github.com/kubernetes/kubernetes/pull/43558) to validate that `--config` wasn't passed along with other flags. Unfortunately, the implementation was checking `PersistentFlags()`, which was not parsed at the point it was being validated.

The fix is to use `Flags()` instead, which contains the expected data.


**Which issue this PR fixes** fixes https://github.com/kubernetes/kubeadm/issues/345

**Special notes for your reviewer**:
This is a regression that was cherry picked (https://github.com/kubernetes/kubernetes/pull/48577) into the `release-1.7` branch. We should fix this before the next 1.7 point release.

This is awkward to unit test without restructuring the code. I think this command parsing code would be a good candidate for some higher level tests.

**Release note**:
```release-note
Fix a regression that broke the `--config` flag for `kubeadm init`.
```

/assign @luxas
This commit is contained in:
Kubernetes Submit Queue
2017-07-14 09:03:18 -07:00
committed by GitHub

View File

@@ -206,7 +206,7 @@ type Init struct {
// Validate validates configuration passed to "kubeadm init" // Validate validates configuration passed to "kubeadm init"
func (i *Init) Validate(cmd *cobra.Command) error { func (i *Init) Validate(cmd *cobra.Command) error {
if err := validation.ValidateMixedArguments(cmd.PersistentFlags()); err != nil { if err := validation.ValidateMixedArguments(cmd.Flags()); err != nil {
return err return err
} }
return validation.ValidateMasterConfiguration(i.cfg).ToAggregate() return validation.ValidateMasterConfiguration(i.cfg).ToAggregate()