Skip to content

Commit

Permalink
apimachinery: merge Scheme.AddKnownTypes and Scheme.AddKnownTypeWithName
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Feb 27, 2017
1 parent 6d9e2af commit 6050f59
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,13 @@ func (s *Scheme) AddUnversionedTypes(version schema.GroupVersion, types ...Objec
// the struct becomes the "kind" field when encoding. Version may not be empty - use the
// APIVersionInternal constant if you have a type that does not have a formal version.
func (s *Scheme) AddKnownTypes(gv schema.GroupVersion, types ...Object) {
if len(gv.Version) == 0 {
panic(fmt.Sprintf("version is required on all types: %s %v", gv, types[0]))
}
for _, obj := range types {
t := reflect.TypeOf(obj)
if t.Kind() != reflect.Ptr {
panic("All types must be pointers to structs.")
}
t = t.Elem()
if t.Kind() != reflect.Struct {
panic("All types must be pointers to structs.")
}

gvk := gv.WithKind(t.Name())
s.gvkToType[gvk] = t
s.typeToGVK[t] = append(s.typeToGVK[t], gvk)
s.AddKnownTypeWithName(gv.WithKind(t.Name()), obj)
}
}

Expand Down

0 comments on commit 6050f59

Please sign in to comment.