Merge pull request #23472 from wojtek-t/fix_object_meta_for

Automatic merge from submit-queue

Switch from api.ObjectMetaFor to meta.Accessor in most of places

Fix #23278

@smarterclayton @lavalamp
This commit is contained in:
k8s-merge-robot
2016-04-02 02:33:40 -07:00
17 changed files with 160 additions and 108 deletions

View File

@@ -28,7 +28,6 @@ import (
"strings"
"time"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/unversioned"
@@ -476,14 +475,16 @@ func GetRecordFlag(cmd *cobra.Command) bool {
// RecordChangeCause annotate change-cause to input runtime object.
func RecordChangeCause(obj runtime.Object, changeCause string) error {
meta, err := api.ObjectMetaFor(obj)
accessor, err := meta.Accessor(obj)
if err != nil {
return err
}
if meta.Annotations == nil {
meta.Annotations = make(map[string]string)
annotations := accessor.GetAnnotations()
if annotations == nil {
annotations = make(map[string]string)
}
meta.Annotations[kubectl.ChangeCauseAnnotation] = changeCause
annotations[kubectl.ChangeCauseAnnotation] = changeCause
accessor.SetAnnotations(annotations)
return nil
}