Skip to content

Commit

Permalink
Remove src and dest version - they are not used (now)
Browse files Browse the repository at this point in the history
We will probably readd these as an opaque object passed down to
conversions that lets the caller get access to more info (like
a negotiated serializer).
  • Loading branch information
smarterclayton committed May 12, 2016
1 parent 0c2641d commit bffbc11
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 35 deletions.
3 changes: 0 additions & 3 deletions pkg/conversion/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ func (c ConversionFuncs) Merge(other ConversionFuncs) ConversionFuncs {

// Meta is supplied by Scheme, when it calls Convert.
type Meta struct {
SrcVersion string
DestVersion string

// KeyNameMapping is an optional function which may map the listed key (field name)
// into a source and destination value.
KeyNameMapping FieldMappingFunc
Expand Down
6 changes: 3 additions & 3 deletions pkg/conversion/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ func TestConverter_meta(t *testing.T) {
checks := 0
err := c.RegisterConversionFunc(
func(in *Foo, out *Bar, s Scope) error {
if s.Meta() == nil || s.Meta().SrcVersion != "test" || s.Meta().DestVersion != "passes" {
if s.Meta() == nil {
t.Errorf("Meta did not get passed!")
}
checks++
Expand All @@ -624,7 +624,7 @@ func TestConverter_meta(t *testing.T) {
}
err = c.RegisterConversionFunc(
func(in *string, out *string, s Scope) error {
if s.Meta() == nil || s.Meta().SrcVersion != "test" || s.Meta().DestVersion != "passes" {
if s.Meta() == nil {
t.Errorf("Meta did not get passed a second time!")
}
checks++
Expand All @@ -634,7 +634,7 @@ func TestConverter_meta(t *testing.T) {
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
err = c.Convert(&Foo{}, &Bar{}, 0, &Meta{SrcVersion: "test", DestVersion: "passes"})
err = c.Convert(&Foo{}, &Bar{}, 0, &Meta{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/conversion/deep_copy_generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ func DeepCopy_conversion_Equalities(in Equalities, out *Equalities, c *Cloner) e
}

func DeepCopy_conversion_Meta(in Meta, out *Meta, c *Cloner) error {
out.SrcVersion = in.SrcVersion
out.DestVersion = in.DestVersion
if in.KeyNameMapping == nil {
out.KeyNameMapping = nil
} else if newVal, err := c.DeepCopy(in.KeyNameMapping); err != nil {
Expand Down
12 changes: 3 additions & 9 deletions pkg/runtime/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,8 @@ func (s *Scheme) nameFunc(t reflect.Type) string {

// fromScope gets the input version, desired output version, and desired Scheme
// from a conversion.Scope.
func (s *Scheme) fromScope(scope conversion.Scope) (inVersion, outVersion string, scheme *Scheme) {
scheme = s
inVersion = scope.Meta().SrcVersion
outVersion = scope.Meta().DestVersion
return inVersion, outVersion, scheme
func (s *Scheme) fromScope(scope conversion.Scope) *Scheme {
return s
}

// Converter allows access to the converter for the scheme
Expand Down Expand Up @@ -532,10 +529,7 @@ func (s *Scheme) ConvertToVersion(in Object, outVersion string) (Object, error)

// generateConvertMeta constructs the meta value we pass to Convert.
func (s *Scheme) generateConvertMeta(srcGroupVersion, destGroupVersion unversioned.GroupVersion, in interface{}) (conversion.FieldMatchingFlags, *conversion.Meta) {
flags, meta := s.converter.DefaultMeta(reflect.TypeOf(in))
meta.SrcVersion = srcGroupVersion.String()
meta.DestVersion = destGroupVersion.String()
return flags, meta
return s.converter.DefaultMeta(reflect.TypeOf(in))
}

func setTargetVersion(obj Object, raw *Scheme, gv unversioned.GroupVersion) {
Expand Down
18 changes: 0 additions & 18 deletions pkg/runtime/scheme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,24 +570,12 @@ func TestMetaValues(t *testing.T) {
err := s.AddConversionFuncs(
func(in *InternalSimple, out *ExternalSimple, scope conversion.Scope) error {
t.Logf("internal -> external")
if e, a := internalGV.String(), scope.Meta().SrcVersion; e != a {
t.Fatalf("Expected '%v', got '%v'", e, a)
}
if e, a := externalGV.String(), scope.Meta().DestVersion; e != a {
t.Fatalf("Expected '%v', got '%v'", e, a)
}
scope.Convert(&in.TestString, &out.TestString, 0)
internalToExternalCalls++
return nil
},
func(in *ExternalSimple, out *InternalSimple, scope conversion.Scope) error {
t.Logf("external -> internal")
if e, a := externalGV.String(), scope.Meta().SrcVersion; e != a {
t.Errorf("Expected '%v', got '%v'", e, a)
}
if e, a := internalGV.String(), scope.Meta().DestVersion; e != a {
t.Fatalf("Expected '%v', got '%v'", e, a)
}
scope.Convert(&in.TestString, &out.TestString, 0)
externalToInternalCalls++
return nil
Expand Down Expand Up @@ -643,12 +631,6 @@ func TestMetaValuesUnregisteredConvert(t *testing.T) {
// Register functions to verify that scope.Meta() gets set correctly.
err := s.AddConversionFuncs(
func(in *InternalSimple, out *ExternalSimple, scope conversion.Scope) error {
if e, a := "unknown/unknown", scope.Meta().SrcVersion; e != a {
t.Fatalf("Expected '%v', got '%v'", e, a)
}
if e, a := "unknown/unknown", scope.Meta().DestVersion; e != a {
t.Fatalf("Expected '%v', got '%v'", e, a)
}
scope.Convert(&in.TestString, &out.TestString, 0)
internalToExternalCalls++
return nil
Expand Down

0 comments on commit bffbc11

Please sign in to comment.