mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-10 21:50:05 +00:00
Factor out API defaulting from validation logic
Currently, the validation logic validates fields in an object and supply default values wherever applies. This change factors out defaulting to a set of defaulting callback functions for decoding (see #1502 for more discussion). * This change is based on pull request 2587. * Most defaulting has been migrated to defaults.go where the defaulting functions are added. * validation_test.go and converter_test.go have been adapted to not testing the default values. * Fixed all tests with that create invalid objects with the absence of defaulting logic.
This commit is contained in:
@@ -47,14 +47,6 @@ func init() {
|
||||
out.Spec.DNSPolicy = in.DNSPolicy
|
||||
out.Name = in.ID
|
||||
out.UID = in.UUID
|
||||
// TODO(dchen1107): Move this conversion to pkg/api/v1beta[123]/conversion.go
|
||||
// along with fixing #1502
|
||||
for i := range out.Spec.Containers {
|
||||
ctr := &out.Spec.Containers[i]
|
||||
if len(ctr.TerminationMessagePath) == 0 {
|
||||
ctr.TerminationMessagePath = TerminationMessagePathDefault
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(in *BoundPod, out *ContainerManifest, s conversion.Scope) error {
|
||||
@@ -65,12 +57,6 @@ func init() {
|
||||
out.Version = "v1beta2"
|
||||
out.ID = in.Name
|
||||
out.UUID = in.UID
|
||||
for i := range out.Containers {
|
||||
ctr := &out.Containers[i]
|
||||
if len(ctr.TerminationMessagePath) == 0 {
|
||||
ctr.TerminationMessagePath = TerminationMessagePathDefault
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user