func GetModifiedConfiguration(info *resource.Info, annotate bool, codec runtime.Encoder) ([]byte, error) {
	var modified []byte
	if info.VersionedObject != nil {
		accessor, err := meta.Accessor(info.VersionedObject)
		if err != nil {
			return nil, err
		}
		annotations := accessor.GetAnnotations()
		if annotations == nil {
			annotations = map[string]string{}
		}
		original := annotations[LastAppliedConfigAnnotation]
		delete(annotations, LastAppliedConfigAnnotation)
		accessor.SetAnnotations(annotations)
		modified, err = json.Marshal(info.VersionedObject)
		if err != nil {
			return nil, err
		}
		if annotate {
			annotations[LastAppliedConfigAnnotation] = string(modified)
			accessor.SetAnnotations(annotations)
			modified, err = json.Marshal(info.VersionedObject)
			if err != nil {
				return nil, err
			}
		}
		annotations[LastAppliedConfigAnnotation] = original
		accessor.SetAnnotations(annotations)
	} else {
		accessor := info.Mapping.MetadataAccessor
		annotations, err := accessor.Annotations(info.Object)
		if err != nil {
			return nil, err
		}
		if annotations == nil {
			annotations = map[string]string{}
		}
		original := annotations[LastAppliedConfigAnnotation]
		delete(annotations, LastAppliedConfigAnnotation)
		if err := accessor.SetAnnotations(info.Object, annotations); err != nil {
			return nil, err
		}
		modified, err = runtime.Encode(codec, info.Object)
		if err != nil {
			return nil, err
		}
		if annotate {
			annotations[LastAppliedConfigAnnotation] = string(modified)
			if err := info.Mapping.MetadataAccessor.SetAnnotations(info.Object, annotations); err != nil {
				return nil, err
			}
			modified, err = runtime.Encode(codec, info.Object)
			if err != nil {
				return nil, err
			}
		}
		annotations[LastAppliedConfigAnnotation] = original
		if err := info.Mapping.MetadataAccessor.SetAnnotations(info.Object, annotations); err != nil {
			return nil, err
		}
	}
	return modified, nil
}
GetModifiedConfiguration retrieves the modified configuration of the object.
If annotate is true, it embeds the result as an anotation in the modified
configuration. If an object was read from the command input, it will use that
version of the object. Otherwise, it will use the version from the server.
package kubectl
import (
	"encoding/json"
	"k8s.io/kubernetes/pkg/api/meta"
	"k8s.io/kubernetes/pkg/kubectl/resource"
	"k8s.io/kubernetes/pkg/runtime"
)
type debugError interface {
	DebugError() (msg string, args []interface{})
}
const LastAppliedConfigAnnotation = kubectlAnnotationPrefix + "last-applied-configuration"
func GetOriginalConfiguration(info *resource.Info) ([]byte, error) {
	annotations, err := info.Mapping.MetadataAccessor.Annotations(info.Object)
	if err != nil {
		return nil, err
	}
	if annotations == nil {
		return nil, nil
	}
	original, ok := annotations[LastAppliedConfigAnnotation]
	if !ok {
		return nil, nil
	}
	return []byte(original), nil
}
func SetOriginalConfiguration(info *resource.Info, original []byte) error {
	if len(original) < 1 {
		return nil
	}
	accessor := info.Mapping.MetadataAccessor
	annotations, err := accessor.Annotations(info.Object)
	if err != nil {
		return err
	}
	if annotations == nil {
		annotations = map[string]string{}
	}
	annotations[LastAppliedConfigAnnotation] = string(original)
	if err := info.Mapping.MetadataAccessor.SetAnnotations(info.Object, annotations); err != nil {
		return err
	}
	return nil
}