func (a *Annotator) GetModifiedConfiguration(obj runtime.Object, annotate bool) ([]byte, error) {
	var modified []byte
	annots, err := a.metadataAccessor.Annotations(obj)
	if err != nil {
		return nil, err
	}
	if annots == nil {
		annots = map[string]string{}
	}
	original := annots[a.key]
	delete(annots, a.key)
	if err := a.metadataAccessor.SetAnnotations(obj, annots); err != nil {
		return nil, err
	}
	if len(annots) == 0 {
		a.metadataAccessor.SetAnnotations(obj, nil)
	}
	modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
	if err != nil {
		return nil, err
	}
	if annotate {
		annots[a.key], err = zipAndBase64EncodeAnnotation(modified)
		if err != nil {
			return nil, err
		}
		if err := a.metadataAccessor.SetAnnotations(obj, annots); err != nil {
			return nil, err
		}
		modified, err = json.ConfigCompatibleWithStandardLibrary.Marshal(obj)
		if err != nil {
			return nil, err
		}
	}
	annots[a.key] = original
	if err := a.metadataAccessor.SetAnnotations(obj, annots); 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 annotation 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 patch
import (
	"archive/zip"
	"bytes"
	"encoding/base64"
	"io/ioutil"
	"net/http"
	json "github.com/json-iterator/go"
	"k8s.io/apimachinery/pkg/api/meta"
	"k8s.io/apimachinery/pkg/runtime"
)
const LastAppliedConfig = "banzaicloud.com/last-applied"
var DefaultAnnotator = NewAnnotator(LastAppliedConfig)
type Annotator struct {
	metadataAccessor meta.MetadataAccessor
	key              string
}
func NewAnnotator(key string) *Annotator {
	return &Annotator{
		key:              key,
		metadataAccessor: meta.NewAccessor(),
	}
}
func (a *Annotator) GetOriginalConfiguration(obj runtime.Object) ([]byte, error) {
	annots, err := a.metadataAccessor.Annotations(obj)
	if err != nil {
		return nil, err
	}
	if annots == nil {
		return nil, nil
	}
	original, ok := annots[a.key]
	if !ok {
		return nil, nil
	}
	if decoded, err := base64.StdEncoding.DecodeString(original); err == nil {
		if http.DetectContentType(decoded) == "application/zip" {
			return unZipAnnotation(decoded)
		}
		return decoded, nil
	}
	return []byte(original), nil
}
func (a *Annotator) SetOriginalConfiguration(obj runtime.Object, original []byte) error {
	if len(original) < 1 {
		return nil
	}
	annots, err := a.metadataAccessor.Annotations(obj)
	if err != nil {
		return err
	}
	if annots == nil {
		annots = map[string]string{}
	}
	annots[a.key], err = zipAndBase64EncodeAnnotation(original)
	if err != nil {
		return err
	}
	return a.metadataAccessor.SetAnnotations(obj, annots)
}