code: func getPatch(set *apps.StatefulSet) ([]byte, error) {
  	str, err := runtime.Encode(patchCodec, set)
  	if err != nil {
  		return nil, err
  	}
  	var raw map[string]interface{}
  	json.Unmarshal([]byte(str), &raw)
  	objCopy := make(map[string]interface{})
  	specCopy := make(map[string]interface{})
  	spec := raw["spec"].(map[string]interface{})
  	template := spec["template"].(map[string]interface{})
  	specCopy["template"] = template
  	template["$patch"] = "replace"
  	objCopy["spec"] = specCopy
  	patch, err := json.Marshal(objCopy)
  	return patch, err
  }
docs: // getPatch returns a strategic merge patch that can be applied to restore a StatefulSet to a
  // previous version. If the returned error is nil the patch is valid. The current state that we save is just the
  // PodSpecTemplate. We can modify this later to encompass more state (or less) and remain compatible with previously
  // recorded patches.