// DropRoundTripHorizontalPodAutoscalerAnnotations removes any annotations used to serialize round-tripped fields from later API versions, // and returns false if no changes were made and the original input object was returned. // It should always be called when converting internal -> external versions, prior // to setting any of the custom annotations: // // annotations, copiedAnnotations := DropRoundTripHorizontalPodAutoscalerAnnotations(externalObj.Annotations) // externalObj.Annotations = annotations // // if internal.SomeField != nil { // if !copiedAnnotations { // externalObj.Annotations = DeepCopyStringMap(externalObj.Annotations) // copiedAnnotations = true // } // externalObj.Annotations[...] = json.Marshal(...) // } func DropRoundTripHorizontalPodAutoscalerAnnotations(in map[string]string) (out map[string]string, copied bool) { … } // DeepCopyStringMap returns a copy of the input map. // If input is nil, an empty map is returned. func DeepCopyStringMap(in map[string]string) map[string]string { … }