Merge pull request #41571 from php-coder/fix_comments

Automatic merge from submit-queue

Minor cleanups

Minor improvements:
- `ValidateNoNewFinalizers`: remove unused const
- Mention that mutation of `spec.initContainers[*].image` field is allowed
- Improve godoc comments
This commit is contained in:
Kubernetes Submit Queue 2017-04-21 08:34:07 -07:00 committed by GitHub
commit 3559c067c6
6 changed files with 8 additions and 17 deletions

View File

@ -2446,8 +2446,8 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
specPath := field.NewPath("spec")
// validate updateable fields:
// 1. containers[*].image
// 2. initContainers[*].image
// 1. spec.containers[*].image
// 2. spec.initContainers[*].image
// 3. spec.activeDeadlineSeconds
containerErrs, stop := ValidateContainerUpdates(newPod.Spec.Containers, oldPod.Spec.Containers, specPath.Child("containers"))
@ -2483,14 +2483,14 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
// handle updateable fields by munging those fields prior to deep equal comparison.
mungedPod := *newPod
// munge containers[*].image
// munge spec.containers[*].image
var newContainers []api.Container
for ix, container := range mungedPod.Spec.Containers {
container.Image = oldPod.Spec.Containers[ix].Image
newContainers = append(newContainers, container)
}
mungedPod.Spec.Containers = newContainers
// munge initContainers[*].image
// munge spec.initContainers[*].image
var newInitContainers []api.Container
for ix, container := range mungedPod.Spec.InitContainers {
container.Image = oldPod.Spec.InitContainers[ix].Image
@ -2510,7 +2510,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
}
return allErrs

View File

@ -46,14 +46,6 @@ const (
idErrMsg = "a valid C identifier must"
)
func expectPrefix(t *testing.T, prefix string, errs field.ErrorList) {
for i := range errs {
if f, p := errs[i].Field, prefix; !strings.HasPrefix(f, p) {
t.Errorf("expected prefix '%s' for field '%s' (%v)", p, f, errs[i])
}
}
}
func testVolume(name string, namespace string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
objMeta := metav1.ObjectMeta{Name: name}
if namespace != "" {

View File

@ -21,7 +21,7 @@ import (
"k8s.io/kubernetes/pkg/api"
)
// mustRunAs implements the GroupStrategy interface
// runAsAny implements the GroupStrategy interface.
type runAsAny struct {
}

View File

@ -25,7 +25,7 @@ import (
"k8s.io/kubernetes/pkg/api/helper"
)
// mustMatchPatterns implements the CapabilitiesStrategy interface
// mustMatchPatterns implements the SysctlsStrategy interface
type mustMatchPatterns struct {
patterns []string
}

View File

@ -129,7 +129,7 @@ func GetVolumeFSType(v api.Volume) (extensions.FSType, error) {
return "", fmt.Errorf("unknown volume type for volume: %#v", v)
}
// fsTypeToStringSet converts an FSType slice to a string set.
// FSTypeToStringSet converts an FSType slice to a string set.
func FSTypeToStringSet(fsTypes []extensions.FSType) sets.String {
set := sets.NewString()
for _, v := range fsTypes {

View File

@ -112,7 +112,6 @@ func ValidateFinalizerName(stringValue string, fldPath *field.Path) field.ErrorL
}
func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fldPath *field.Path) field.ErrorList {
const newFinalizersErrorMsg string = `no new finalizers can be added if the object is being deleted`
allErrs := field.ErrorList{}
extra := sets.NewString(newFinalizers...).Difference(sets.NewString(oldFinalizers...))
if len(extra) != 0 {