Move service annotation patch template into the constants.

This commit is contained in:
Oleksii Kliukin 2017-06-12 10:02:13 +02:00 committed by Oleksii Kliukin
parent 17826ee434
commit 987990fb0e
2 changed files with 3 additions and 1 deletions

View File

@ -70,7 +70,8 @@ func metadataAnnotationsPatch(annotations map[string]string) string {
annotationsList = append(annotationsList, fmt.Sprintf(`"%s":"%s"`, name, value)) annotationsList = append(annotationsList, fmt.Sprintf(`"%s":"%s"`, name, value))
} }
annotationsString := strings.Join(annotationsList, ",") annotationsString := strings.Join(annotationsList, ",")
return fmt.Sprintf(`{"metadata":{"annotations": {"$patch":"replace", %s}}}`, annotationsString) // TODO: perhaps use patchStrategy:"replace" json annotation instead of constructing the patch literally.
return fmt.Sprintf(constants.ServiceMetadataAnnotationFormat, annotationsString)
} }
func (c *Cluster) logStatefulSetChanges(old, new *v1beta1.StatefulSet, isUpdate bool, reasons []string) { func (c *Cluster) logStatefulSetChanges(old, new *v1beta1.StatefulSet, isUpdate bool, reasons []string) {

View File

@ -7,4 +7,5 @@ const (
ElbTimeoutAnnotationValue = "3600" ElbTimeoutAnnotationValue = "3600"
KubeIAmAnnotation = "iam.amazonaws.com/role" KubeIAmAnnotation = "iam.amazonaws.com/role"
VolumeStorateProvisionerAnnotation = "pv.kubernetes.io/provisioned-by" VolumeStorateProvisionerAnnotation = "pv.kubernetes.io/provisioned-by"
ServiceMetadataAnnotationFormat = `{"metadata":{"annotations": {"$patch":"replace", %s}}}`
) )