Skip to content

Commit

Permalink
validate additionalContainers.image to make sure it is not empty (#3378
Browse files Browse the repository at this point in the history
…) (#3383)
  • Loading branch information
ti-srebot authored Oct 15, 2020
1 parent 1b9a6e5 commit f59ba26
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/apis/pingcap/v1alpha1/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func validateComponentSpec(spec *v1alpha1.ComponentSpec, fldPath *field.Path) fi
allErrs := field.ErrorList{}
// TODO validate other fields
allErrs = append(allErrs, validateEnv(spec.Env, fldPath.Child("env"))...)
allErrs = append(allErrs, validateAdditionalContainers(spec.AdditionalContainers, fldPath.Child("additionalContainers"))...)
return allErrs
}

Expand Down Expand Up @@ -481,3 +482,16 @@ func validateTimeDurationStr(timeStr *string, fldPath *field.Path) field.ErrorLi
}
return allErrs
}

func validateAdditionalContainers(containers []corev1.Container, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

for i, container := range containers {
idxPath := fldPath.Index(i)
if len(container.Image) == 0 {
allErrs = append(allErrs, field.Required(idxPath.Child("image"), "empty image"))
}
}

return allErrs
}

0 comments on commit f59ba26

Please sign in to comment.