Move all operator-related constants together.
This commit is contained in:
		
							parent
							
								
									55dbacdfa6
								
							
						
					
					
						commit
						7529b84b93
					
				|  | @ -33,4 +33,8 @@ const ( | ||||||
| 
 | 
 | ||||||
| 	OAuthTokenSecretName     = "postgresql-operator" | 	OAuthTokenSecretName     = "postgresql-operator" | ||||||
| 	ServiceAccountName       = "operator" | 	ServiceAccountName       = "operator" | ||||||
|  | 	DataVolumeName           = "pgdata" | ||||||
|  | 	ZalandoDnsNameAnnotation = "zalando.org/dnsname" | ||||||
|  | 	// TODO: move DbHostedZone to operator configuration
 | ||||||
|  | 	DbHostedZone = "db.example.com" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | @ -15,15 +15,6 @@ import ( | ||||||
| 	"github.bus.zalan.do/acid/postgres-operator/pkg/util/constants" | 	"github.bus.zalan.do/acid/postgres-operator/pkg/util/constants" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( |  | ||||||
| 	superuserName            = "postgres" |  | ||||||
| 	replicationUsername      = "replication" |  | ||||||
| 	dataVolumeName           = "pgdata" |  | ||||||
| 	zalandoDnsNameAnnotation = "zalando.org/dnsname" |  | ||||||
| 	// TODO: move DbHostedZone to operator configuration
 |  | ||||||
| 	DbHostedZone = "db.example.com" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func credentialSecretName(clusterName, username string) string { | func credentialSecretName(clusterName, username string) string { | ||||||
| 	return fmt.Sprintf( | 	return fmt.Sprintf( | ||||||
| 		constants.UserSecretTemplate, | 		constants.UserSecretTemplate, | ||||||
|  | @ -90,7 +81,7 @@ func PodTemplate(cluster spec.ClusterName, resourceList *v1.ResourceList, docker | ||||||
| 			ValueFrom: &v1.EnvVarSource{ | 			ValueFrom: &v1.EnvVarSource{ | ||||||
| 				SecretKeyRef: &v1.SecretKeySelector{ | 				SecretKeyRef: &v1.SecretKeySelector{ | ||||||
| 					LocalObjectReference: v1.LocalObjectReference{ | 					LocalObjectReference: v1.LocalObjectReference{ | ||||||
| 						Name: credentialSecretName(cluster.Name, superuserName), | 						Name: credentialSecretName(cluster.Name, constants.SuperuserName), | ||||||
| 					}, | 					}, | ||||||
| 					Key: "password", | 					Key: "password", | ||||||
| 				}, | 				}, | ||||||
|  | @ -101,7 +92,7 @@ func PodTemplate(cluster spec.ClusterName, resourceList *v1.ResourceList, docker | ||||||
| 			ValueFrom: &v1.EnvVarSource{ | 			ValueFrom: &v1.EnvVarSource{ | ||||||
| 				SecretKeyRef: &v1.SecretKeySelector{ | 				SecretKeyRef: &v1.SecretKeySelector{ | ||||||
| 					LocalObjectReference: v1.LocalObjectReference{ | 					LocalObjectReference: v1.LocalObjectReference{ | ||||||
| 						Name: credentialSecretName(cluster.Name, replicationUsername), | 						Name: credentialSecretName(cluster.Name, constants.ReplicationUsername), | ||||||
| 					}, | 					}, | ||||||
| 					Key: "password", | 					Key: "password", | ||||||
| 				}, | 				}, | ||||||
|  | @ -156,7 +147,7 @@ bootstrap: | ||||||
| 		}, | 		}, | ||||||
| 		VolumeMounts: []v1.VolumeMount{ | 		VolumeMounts: []v1.VolumeMount{ | ||||||
| 			{ | 			{ | ||||||
| 				Name:      dataVolumeName, | 				Name:      constants.DataVolumeName, | ||||||
| 				MountPath: "/home/postgres/pgdata", //TODO: fetch from manifesto
 | 				MountPath: "/home/postgres/pgdata", //TODO: fetch from manifesto
 | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -184,7 +175,7 @@ bootstrap: | ||||||
| 
 | 
 | ||||||
| func VolumeClaimTemplate(volumeSize, volumeStorageClass string) *v1.PersistentVolumeClaim { | func VolumeClaimTemplate(volumeSize, volumeStorageClass string) *v1.PersistentVolumeClaim { | ||||||
| 	metadata := v1.ObjectMeta{ | 	metadata := v1.ObjectMeta{ | ||||||
| 		Name: dataVolumeName, | 		Name: constants.DataVolumeName, | ||||||
| 	} | 	} | ||||||
| 	if volumeStorageClass != "" { | 	if volumeStorageClass != "" { | ||||||
| 		// TODO: check if storage class exists
 | 		// TODO: check if storage class exists
 | ||||||
|  | @ -258,7 +249,9 @@ func Service(cluster spec.ClusterName, teamName string, allowedSourceRanges []st | ||||||
| 			Name:      cluster.Name, | 			Name:      cluster.Name, | ||||||
| 			Namespace: cluster.Namespace, | 			Namespace: cluster.Namespace, | ||||||
| 			Labels:    labelsSet(cluster.Name), | 			Labels:    labelsSet(cluster.Name), | ||||||
| 			Annotations: map[string]string{zalandoDnsNameAnnotation: util.ClusterDNSName(cluster.Name, teamName, DbHostedZone)}, | 			Annotations: map[string]string{ | ||||||
|  | 				constants.ZalandoDnsNameAnnotation: util.ClusterDNSName(cluster.Name, teamName, constants.DbHostedZone), | ||||||
|  | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		Spec: v1.ServiceSpec{ | 		Spec: v1.ServiceSpec{ | ||||||
| 			Type:  v1.ServiceTypeLoadBalancer, | 			Type:  v1.ServiceTypeLoadBalancer, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue