Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move defaulting funcs from internal to v1 #17099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions pkg/api/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ func init() {
obj.LabelSelector = labels.Everything()
obj.FieldSelector = fields.Everything()
},
// TODO: see about moving this into v1/defaults.go
func(obj *PodExecOptions) {
obj.Stderr = true
obj.Stdout = true
},
func(obj *PodAttachOptions) {
obj.Stderr = true
obj.Stdout = true
},
)
Scheme.AddConversionFuncs(
func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error {
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
return
}
if !api.Semantic.DeepEqual(item, obj2) {
t.Errorf("1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, util.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2))
t.Errorf("\n1: %v: diff: %v\nCodec: %v\nSource:\n\n%#v\n\nEncoded:\n\n%s\n\nFinal:\n\n%#v", name, util.ObjectGoPrintDiff(item, obj2), codec, printer.Sprintf("%#v", item), string(data), printer.Sprintf("%#v", obj2))
return
}

Expand Down Expand Up @@ -128,7 +128,8 @@ func TestList(t *testing.T) {
}

var nonRoundTrippableTypes = sets.NewString()
var nonInternalRoundTrippableTypes = sets.NewString("List", "ListOptions", "PodExecOptions", "PodAttachOptions")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra blank line (and all three of these things could be in one var ( ... ) block...)

var nonInternalRoundTrippableTypes = sets.NewString("List", "ListOptions")
var nonRoundTrippableTypesByVersion = map[string][]string{}

func TestRoundTripTypes(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
j.LabelSelector, _ = labels.Parse("a=b")
j.FieldSelector, _ = fields.ParseSelector("a=b")
},
func(j *api.PodExecOptions, c fuzz.Continue) {
j.Stdout = true
j.Stderr = true
},
func(j *api.PodAttachOptions, c fuzz.Continue) {
j.Stdout = true
j.Stderr = true
},
func(s *api.PodSpec, c fuzz.Continue) {
c.FuzzNoCustom(s)
// has a default value
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/v1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ import (

func addDefaultingFuncs() {
api.Scheme.AddDefaultingFuncs(
func(obj *PodExecOptions) {
obj.Stdout = true
obj.Stderr = true
},
func(obj *PodAttachOptions) {
obj.Stdout = true
obj.Stderr = true
},
func(obj *ReplicationController) {
var labels map[string]string
if obj.Spec.Template != nil {
Expand Down