forked from LaconicNetwork/kompose
switch from godep to glide
This commit is contained in:
+38
-1
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"reflect"
|
||||
|
||||
kapi "k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
@@ -115,6 +116,42 @@ func (o *ResourceQuotasStatusByNamespace) OrderedKeys() *list.List {
|
||||
return o.orderedMap.OrderedKeys()
|
||||
}
|
||||
|
||||
// DeepCopy implements a custom copy to correctly handle unexported fields
|
||||
// Must match "func (t T) DeepCopy() T" for the deep copy generator to use it
|
||||
func (o ResourceQuotasStatusByNamespace) DeepCopy() ResourceQuotasStatusByNamespace {
|
||||
out := ResourceQuotasStatusByNamespace{}
|
||||
for e := o.OrderedKeys().Front(); e != nil; e = e.Next() {
|
||||
namespace := e.Value.(string)
|
||||
instatus, _ := o.Get(namespace)
|
||||
if outstatus, err := kapi.Scheme.DeepCopy(instatus); err != nil {
|
||||
panic(err) // should never happen
|
||||
} else {
|
||||
out.Insert(namespace, outstatus.(kapi.ResourceQuotaStatus))
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Tell the reflection package how to compare our unexported type
|
||||
if err := kapi.Semantic.AddFuncs(
|
||||
func(o1, o2 ResourceQuotasStatusByNamespace) bool {
|
||||
return reflect.DeepEqual(o1.orderedMap, o2.orderedMap)
|
||||
},
|
||||
func(o1, o2 *ResourceQuotasStatusByNamespace) bool {
|
||||
if o1 == nil && o2 == nil {
|
||||
return true
|
||||
}
|
||||
if (o1 == nil) != (o2 == nil) {
|
||||
return false
|
||||
}
|
||||
return reflect.DeepEqual(o1.orderedMap, o2.orderedMap)
|
||||
},
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// orderedMap is a very simple ordering a map tracking insertion order. It allows fast and stable serializations
|
||||
// for our encoding. You could probably do something fancier with pointers to interfaces, but I didn't.
|
||||
type orderedMap struct {
|
||||
@@ -159,7 +196,7 @@ func (o *orderedMap) Remove(key string) {
|
||||
// OrderedKeys returns back the ordered keys. This can be used to build a stable serialization
|
||||
func (o *orderedMap) OrderedKeys() *list.List {
|
||||
if o.orderedKeys == nil {
|
||||
o.orderedKeys = list.New()
|
||||
return list.New()
|
||||
}
|
||||
return o.orderedKeys
|
||||
}
|
||||
|
||||
+1
-3
@@ -156,9 +156,7 @@ func DeepCopy_api_ClusterResourceQuotaStatus(in interface{}, out interface{}, c
|
||||
if err := pkg_api.DeepCopy_api_ResourceQuotaStatus(&in.Total, &out.Total, c); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := DeepCopy_api_ResourceQuotasStatusByNamespace(&in.Namespaces, &out.Namespaces, c); err != nil {
|
||||
return err
|
||||
}
|
||||
out.Namespaces = in.Namespaces.DeepCopy()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user