diff --git a/vendor.conf b/vendor.conf index ad872886..3fc74adf 100644 --- a/vendor.conf +++ b/vendor.conf @@ -3,5 +3,5 @@ github.com/rancher/types k8s.io/kubernetes v1.8.3 transitive=true,staging=true bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git -github.com/rancher/norman 905797b50f5617765df971412c22fdc5cb84d847 +github.com/rancher/norman f7f989c4e250c6713cb6bed96849ff9b48e4692e golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5 diff --git a/vendor/github.com/rancher/norman/condition/condition.go b/vendor/github.com/rancher/norman/condition/condition.go index 882ac8d6..31884f1d 100644 --- a/vendor/github.com/rancher/norman/condition/condition.go +++ b/vendor/github.com/rancher/norman/condition/condition.go @@ -56,13 +56,12 @@ func (c Cond) ReasonAndMessageFromError(obj runtime.Object, err error) { return } cond := findOrCreateCond(obj, string(c)) - getFieldValue(cond, "Message").SetString(err.Error()) + setValue(cond, "Message", err.Error()) if ce, ok := err.(*conditionError); ok { - getFieldValue(cond, "Reason").SetString(ce.reason) + setValue(cond, "Reason", ce.reason) } else { - getFieldValue(cond, "Reason").SetString("Error") + setValue(cond, "Reason", "Error") } - touchTS(cond) } func (c Cond) GetReason(obj runtime.Object) string { @@ -151,8 +150,15 @@ func getStatus(obj interface{}, condName string) string { func setStatus(obj interface{}, condName, status string) { cond := findOrCreateCond(obj, condName) - getFieldValue(cond, "Status").SetString(status) - touchTS(cond) + setValue(cond, "Status", status) +} + +func setValue(cond reflect.Value, fieldName, newValue string) { + value := getFieldValue(cond, fieldName) + if value.String() != newValue { + value.SetString(newValue) + touchTS(cond) + } } func findOrCreateCond(obj interface{}, condName string) reflect.Value { diff --git a/vendor/github.com/rancher/norman/lifecycle/object.go b/vendor/github.com/rancher/norman/lifecycle/object.go index 43b92f31..7781587f 100644 --- a/vendor/github.com/rancher/norman/lifecycle/object.go +++ b/vendor/github.com/rancher/norman/lifecycle/object.go @@ -57,8 +57,8 @@ func (o *objectLifecycleAdapter) sync(key string, obj runtime.Object) error { return err } - obj = obj.DeepCopyObject() - newObj, err := o.lifecycle.Updated(obj) + copyObj := obj.DeepCopyObject() + newObj, err := o.lifecycle.Updated(copyObj) o.update(metadata.GetName(), obj, newObj) return err } @@ -80,19 +80,19 @@ func (o *objectLifecycleAdapter) finalize(metadata metav1.Object, obj runtime.Ob return false, nil } - obj = obj.DeepCopyObject() - if newObj, err := o.lifecycle.Finalize(obj); err != nil { + copyObj := obj.DeepCopyObject() + if newObj, err := o.lifecycle.Finalize(copyObj); err != nil { o.update(metadata.GetName(), obj, newObj) return false, err } else if newObj != nil { - obj = newObj + copyObj = newObj } - if err := removeFinalizer(o.constructFinalizerKey(), obj); err != nil { + if err := removeFinalizer(o.constructFinalizerKey(), copyObj); err != nil { return false, err } - _, err := o.objectClient.Update(metadata.GetName(), obj) + _, err := o.objectClient.Update(metadata.GetName(), copyObj) return false, err } @@ -130,21 +130,20 @@ func (o *objectLifecycleAdapter) create(metadata metav1.Object, obj runtime.Obje return true, nil } - // addFinalizer will always return a DeepCopy - obj, err := o.addFinalizer(obj) + copyObj := obj.DeepCopyObject() + copyObj, err := o.addFinalizer(copyObj) if err != nil { return false, err } - orig := obj.DeepCopyObject() - if newObj, err := o.lifecycle.Create(obj); err != nil { - o.update(metadata.GetName(), orig, newObj) + if newObj, err := o.lifecycle.Create(copyObj); err != nil { + o.update(metadata.GetName(), obj, newObj) return false, err } else if newObj != nil { - obj = newObj + copyObj = newObj } - return false, o.setInitialized(obj) + return false, o.setInitialized(copyObj) } func (o *objectLifecycleAdapter) isInitialized(metadata metav1.Object) bool { @@ -170,8 +169,6 @@ func (o *objectLifecycleAdapter) setInitialized(obj runtime.Object) error { } func (o *objectLifecycleAdapter) addFinalizer(obj runtime.Object) (runtime.Object, error) { - obj = obj.DeepCopyObject() - metadata, err := meta.Accessor(obj) if err != nil { return nil, err diff --git a/vendor/github.com/rancher/norman/types/reflection.go b/vendor/github.com/rancher/norman/types/reflection.go index 44b4b926..550b7692 100644 --- a/vendor/github.com/rancher/norman/types/reflection.go +++ b/vendor/github.com/rancher/norman/types/reflection.go @@ -74,11 +74,13 @@ func (s *Schemas) Import(version *APIVersion, obj interface{}, externalOverrides func (s *Schemas) newSchemaFromType(version *APIVersion, t reflect.Type, typeName string) (*Schema, error) { schema := &Schema{ - ID: typeName, - Version: *version, - CodeName: t.Name(), - PkgName: t.PkgPath(), - ResourceFields: map[string]Field{}, + ID: typeName, + Version: *version, + CodeName: t.Name(), + PkgName: t.PkgPath(), + ResourceFields: map[string]Field{}, + ResourceActions: map[string]Action{}, + CollectionActions: map[string]Action{}, } if err := s.readFields(schema, t); err != nil { diff --git a/vendor/github.com/rancher/norman/types/server_types.go b/vendor/github.com/rancher/norman/types/server_types.go index 663a702a..66f27451 100644 --- a/vendor/github.com/rancher/norman/types/server_types.go +++ b/vendor/github.com/rancher/norman/types/server_types.go @@ -20,6 +20,10 @@ type RawResource struct { ActionLinks bool `json:"-"` } +func (r *RawResource) AddAction(apiContext *APIContext, name string) { + r.Actions[name] = apiContext.URLBuilder.Action(name, r) +} + func (r *RawResource) MarshalJSON() ([]byte, error) { data := map[string]interface{}{} for k, v := range r.Values {