Fix golint failures
* Fix golint fails based on the original work from the user u5surf * Skip installing Docker as CDP now have one pre-installed (repairs builds on CDP)
This commit is contained in:
		
							parent
							
								
									f7058c754d
								
							
						
					
					
						commit
						4b5d3cd121
					
				|  | @ -47,14 +47,14 @@ func init() { | ||||||
| 		log.Printf("Fully qualified configmap name: %v", config.ConfigMapName) | 		log.Printf("Fully qualified configmap name: %v", config.ConfigMapName) | ||||||
| 
 | 
 | ||||||
| 	} | 	} | ||||||
| 	if crd_interval := os.Getenv("CRD_READY_WAIT_INTERVAL"); crd_interval != "" { | 	if crdInterval := os.Getenv("CRD_READY_WAIT_INTERVAL"); crdInterval != "" { | ||||||
| 		config.CRDReadyWaitInterval = mustParseDuration(crd_interval) | 		config.CRDReadyWaitInterval = mustParseDuration(crdInterval) | ||||||
| 	} else { | 	} else { | ||||||
| 		config.CRDReadyWaitInterval = 4 * time.Second | 		config.CRDReadyWaitInterval = 4 * time.Second | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if crd_timeout := os.Getenv("CRD_READY_WAIT_TIMEOUT"); crd_timeout != "" { | 	if crdTimeout := os.Getenv("CRD_READY_WAIT_TIMEOUT"); crdTimeout != "" { | ||||||
| 		config.CRDReadyWaitTimeout = mustParseDuration(crd_timeout) | 		config.CRDReadyWaitTimeout = mustParseDuration(crdTimeout) | ||||||
| 	} else { | 	} else { | ||||||
| 		config.CRDReadyWaitTimeout = 30 * time.Second | 		config.CRDReadyWaitTimeout = 30 * time.Second | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -20,9 +20,6 @@ pipeline: | ||||||
|             mv go /usr/local |             mv go /usr/local | ||||||
|             ln -s /usr/local/go/bin/go /usr/bin/go |             ln -s /usr/local/go/bin/go /usr/bin/go | ||||||
|             go version |             go version | ||||||
|         - desc: 'Install Docker' |  | ||||||
|           cmd: | |  | ||||||
|             curl -fLOsS https://delivery.cloud.zalando.com/utils/ensure-docker && sh ensure-docker && rm ensure-docker |  | ||||||
|         - desc: 'Symlink sources into the GOPATH' |         - desc: 'Symlink sources into the GOPATH' | ||||||
|           cmd: | |           cmd: | | ||||||
|             mkdir -p $OPERATOR_TOP_DIR |             mkdir -p $OPERATOR_TOP_DIR | ||||||
|  |  | ||||||
|  | @ -308,12 +308,12 @@ In the CRD-based configuration they are grouped under the `load_balancer` key. | ||||||
|   replaced with the hosted zone (the value of the `db_hosted_zone` parameter). |   replaced with the hosted zone (the value of the `db_hosted_zone` parameter). | ||||||
|   No other placeholders are allowed. |   No other placeholders are allowed. | ||||||
| 
 | 
 | ||||||
| ## AWS or GSC interaction | ## AWS or GCP interaction | ||||||
| 
 | 
 | ||||||
| The options in this group configure operator interactions with non-Kubernetes | The options in this group configure operator interactions with non-Kubernetes | ||||||
| objects from AWS or Google cloud. They have no effect unless you are using | objects from Amazon Web Services (AWS) or Google Cloud Platform (GCP). They have no effect unless you are using | ||||||
| either. In the CRD-based configuration those options are grouped under the | either. In the CRD-based configuration those options are grouped under the | ||||||
| `aws_or_gcp` key. | `aws_or_gcp` key. Note the GCP integration is not yet officially supported. | ||||||
| 
 | 
 | ||||||
| * **wal_s3_bucket** | * **wal_s3_bucket** | ||||||
|   S3 bucket to use for shipping WAL segments with WAL-E. A bucket has to be |   S3 bucket to use for shipping WAL segments with WAL-E. A bucket has to be | ||||||
|  |  | ||||||
|  | @ -1,10 +1,7 @@ | ||||||
| package v1 | package v1 | ||||||
| 
 | 
 | ||||||
|  | // 	ClusterStatusUnknown etc : status of a Postgres cluster known to the operator
 | ||||||
| const ( | const ( | ||||||
| 	serviceNameMaxLength   = 63 |  | ||||||
| 	clusterNameMaxLength   = serviceNameMaxLength - len("-repl") |  | ||||||
| 	serviceNameRegexString = `^[a-z]([-a-z0-9]*[a-z0-9])?$` |  | ||||||
| 
 |  | ||||||
| 	ClusterStatusUnknown      PostgresStatus = "" | 	ClusterStatusUnknown      PostgresStatus = "" | ||||||
| 	ClusterStatusCreating     PostgresStatus = "Creating" | 	ClusterStatusCreating     PostgresStatus = "Creating" | ||||||
| 	ClusterStatusUpdating     PostgresStatus = "Updating" | 	ClusterStatusUpdating     PostgresStatus = "Updating" | ||||||
|  | @ -14,3 +11,9 @@ const ( | ||||||
| 	ClusterStatusRunning      PostgresStatus = "Running" | 	ClusterStatusRunning      PostgresStatus = "Running" | ||||||
| 	ClusterStatusInvalid      PostgresStatus = "Invalid" | 	ClusterStatusInvalid      PostgresStatus = "Invalid" | ||||||
| ) | ) | ||||||
|  | 
 | ||||||
|  | const ( | ||||||
|  | 	serviceNameMaxLength   = 63 | ||||||
|  | 	clusterNameMaxLength   = serviceNameMaxLength - len("-repl") | ||||||
|  | 	serviceNameRegexString = `^[a-z]([-a-z0-9]*[a-z0-9])?$` | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ import ( | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // CRDResource* define names necesssary for the k8s CRD API
 | ||||||
| const ( | const ( | ||||||
| 	PostgresCRDResourceKind   = "postgresql" | 	PostgresCRDResourceKind   = "postgresql" | ||||||
| 	PostgresCRDResourcePlural = "postgresqls" | 	PostgresCRDResourcePlural = "postgresqls" | ||||||
|  | @ -39,6 +40,7 @@ func buildCRD(name, kind, plural, short string) *apiextv1beta1.CustomResourceDef | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // PostgresCRD returns CustomResourceDefinition built from PostgresCRDResource
 | ||||||
| func PostgresCRD() *apiextv1beta1.CustomResourceDefinition { | func PostgresCRD() *apiextv1beta1.CustomResourceDefinition { | ||||||
| 	return buildCRD(PostgresCRDResouceName, | 	return buildCRD(PostgresCRDResouceName, | ||||||
| 		PostgresCRDResourceKind, | 		PostgresCRDResourceKind, | ||||||
|  | @ -46,6 +48,7 @@ func PostgresCRD() *apiextv1beta1.CustomResourceDefinition { | ||||||
| 		PostgresCRDResourceShort) | 		PostgresCRDResourceShort) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // ConfigurationCRD returns CustomResourceDefinition built from OperatorConfigCRDResource
 | ||||||
| func ConfigurationCRD() *apiextv1beta1.CustomResourceDefinition { | func ConfigurationCRD() *apiextv1beta1.CustomResourceDefinition { | ||||||
| 	return buildCRD(OperatorConfigCRDResourceName, | 	return buildCRD(OperatorConfigCRDResourceName, | ||||||
| 		OperatorConfigCRDResouceKind, | 		OperatorConfigCRDResouceKind, | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
|  | // Package v1 is the v1 version of the API.
 | ||||||
| // +k8s:deepcopy-gen=package,register
 | // +k8s:deepcopy-gen=package,register
 | ||||||
| 
 | 
 | ||||||
| // Package v1 is the v1 version of the API.
 |  | ||||||
| // +groupName=acid.zalan.do
 | // +groupName=acid.zalan.do
 | ||||||
| 
 | 
 | ||||||
| package v1 | package v1 | ||||||
|  |  | ||||||
|  | @ -104,6 +104,7 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // UnmarshalJSON convert to Duration from byte slice of json
 | ||||||
| func (d *Duration) UnmarshalJSON(b []byte) error { | func (d *Duration) UnmarshalJSON(b []byte) error { | ||||||
| 	var ( | 	var ( | ||||||
| 		v   interface{} | 		v   interface{} | ||||||
|  |  | ||||||
|  | @ -13,6 +13,8 @@ import ( | ||||||
| // +genclient:onlyVerbs=get
 | // +genclient:onlyVerbs=get
 | ||||||
| // +genclient:noStatus
 | // +genclient:noStatus
 | ||||||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | ||||||
|  | 
 | ||||||
|  | // OperatorConfiguration defines the specification for the OperatorConfiguration.
 | ||||||
| type OperatorConfiguration struct { | type OperatorConfiguration struct { | ||||||
| 	metav1.TypeMeta   `json:",inline"` | 	metav1.TypeMeta   `json:",inline"` | ||||||
| 	metav1.ObjectMeta `json:"metadata"` | 	metav1.ObjectMeta `json:"metadata"` | ||||||
|  | @ -21,6 +23,8 @@ type OperatorConfiguration struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | ||||||
|  | 
 | ||||||
|  | // OperatorConfigurationList is used in the k8s API calls
 | ||||||
| type OperatorConfigurationList struct { | type OperatorConfigurationList struct { | ||||||
| 	metav1.TypeMeta `json:",inline"` | 	metav1.TypeMeta `json:",inline"` | ||||||
| 	metav1.ListMeta `json:"metadata"` | 	metav1.ListMeta `json:"metadata"` | ||||||
|  | @ -28,11 +32,13 @@ type OperatorConfigurationList struct { | ||||||
| 	Items []OperatorConfiguration `json:"items"` | 	Items []OperatorConfiguration `json:"items"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // PostgresUsersConfiguration defines the system users of Postgres.
 | ||||||
| type PostgresUsersConfiguration struct { | type PostgresUsersConfiguration struct { | ||||||
| 	SuperUsername       string `json:"super_username,omitempty"` | 	SuperUsername       string `json:"super_username,omitempty"` | ||||||
| 	ReplicationUsername string `json:"replication_username,omitempty"` | 	ReplicationUsername string `json:"replication_username,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // KubernetesMetaConfiguration defines k8s conf required for all Postgres clusters and the operator itself
 | ||||||
| type KubernetesMetaConfiguration struct { | type KubernetesMetaConfiguration struct { | ||||||
| 	PodServiceAccountName string `json:"pod_service_account_name,omitempty"` | 	PodServiceAccountName string `json:"pod_service_account_name,omitempty"` | ||||||
| 	// TODO: change it to the proper json
 | 	// TODO: change it to the proper json
 | ||||||
|  | @ -55,6 +61,7 @@ type KubernetesMetaConfiguration struct { | ||||||
| 	PodPriorityClassName    string `json:"pod_priority_class_name,omitempty"` | 	PodPriorityClassName    string `json:"pod_priority_class_name,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // PostgresPodResourcesDefaults defines the spec of default resources
 | ||||||
| type PostgresPodResourcesDefaults struct { | type PostgresPodResourcesDefaults struct { | ||||||
| 	DefaultCPURequest    string `json:"default_cpu_request,omitempty"` | 	DefaultCPURequest    string `json:"default_cpu_request,omitempty"` | ||||||
| 	DefaultMemoryRequest string `json:"default_memory_request,omitempty"` | 	DefaultMemoryRequest string `json:"default_memory_request,omitempty"` | ||||||
|  | @ -62,6 +69,7 @@ type PostgresPodResourcesDefaults struct { | ||||||
| 	DefaultMemoryLimit   string `json:"default_memory_limit,omitempty"` | 	DefaultMemoryLimit   string `json:"default_memory_limit,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // OperatorTimeouts defines the timeout of ResourceCheck, PodWait, ReadyWait
 | ||||||
| type OperatorTimeouts struct { | type OperatorTimeouts struct { | ||||||
| 	ResourceCheckInterval  Duration `json:"resource_check_interval,omitempty"` | 	ResourceCheckInterval  Duration `json:"resource_check_interval,omitempty"` | ||||||
| 	ResourceCheckTimeout   Duration `json:"resource_check_timeout,omitempty"` | 	ResourceCheckTimeout   Duration `json:"resource_check_timeout,omitempty"` | ||||||
|  | @ -71,6 +79,7 @@ type OperatorTimeouts struct { | ||||||
| 	ReadyWaitTimeout       Duration `json:"ready_wait_timeout,omitempty"` | 	ReadyWaitTimeout       Duration `json:"ready_wait_timeout,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // LoadBalancerConfiguration defines the LB configuration
 | ||||||
| type LoadBalancerConfiguration struct { | type LoadBalancerConfiguration struct { | ||||||
| 	DbHostedZone              string                `json:"db_hosted_zone,omitempty"` | 	DbHostedZone              string                `json:"db_hosted_zone,omitempty"` | ||||||
| 	EnableMasterLoadBalancer  bool                  `json:"enable_master_load_balancer,omitempty"` | 	EnableMasterLoadBalancer  bool                  `json:"enable_master_load_balancer,omitempty"` | ||||||
|  | @ -79,6 +88,8 @@ type LoadBalancerConfiguration struct { | ||||||
| 	ReplicaDNSNameFormat      config.StringTemplate `json:"replica_dns_name_format,omitempty"` | 	ReplicaDNSNameFormat      config.StringTemplate `json:"replica_dns_name_format,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // AWSGCPConfiguration defines the configuration for AWS
 | ||||||
|  | // TODO complete Google Cloud Platform (GCP) configuration
 | ||||||
| type AWSGCPConfiguration struct { | type AWSGCPConfiguration struct { | ||||||
| 	WALES3Bucket string `json:"wal_s3_bucket,omitempty"` | 	WALES3Bucket string `json:"wal_s3_bucket,omitempty"` | ||||||
| 	AWSRegion    string `json:"aws_region,omitempty"` | 	AWSRegion    string `json:"aws_region,omitempty"` | ||||||
|  | @ -86,11 +97,13 @@ type AWSGCPConfiguration struct { | ||||||
| 	KubeIAMRole  string `json:"kube_iam_role,omitempty"` | 	KubeIAMRole  string `json:"kube_iam_role,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // OperatorDebugConfiguration defines options for the debug mode
 | ||||||
| type OperatorDebugConfiguration struct { | type OperatorDebugConfiguration struct { | ||||||
| 	DebugLogging   bool `json:"debug_logging,omitempty"` | 	DebugLogging   bool `json:"debug_logging,omitempty"` | ||||||
| 	EnableDBAccess bool `json:"enable_database_access,omitempty"` | 	EnableDBAccess bool `json:"enable_database_access,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // TeamsAPIConfiguration defines the configration of TeamsAPI
 | ||||||
| type TeamsAPIConfiguration struct { | type TeamsAPIConfiguration struct { | ||||||
| 	EnableTeamsAPI           bool              `json:"enable_teams_api,omitempty"` | 	EnableTeamsAPI           bool              `json:"enable_teams_api,omitempty"` | ||||||
| 	TeamsAPIUrl              string            `json:"teams_api_url,omitempty"` | 	TeamsAPIUrl              string            `json:"teams_api_url,omitempty"` | ||||||
|  | @ -103,12 +116,14 @@ type TeamsAPIConfiguration struct { | ||||||
| 	PostgresSuperuserTeams   []string          `json:"postgres_superuser_teams,omitempty"` | 	PostgresSuperuserTeams   []string          `json:"postgres_superuser_teams,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // LoggingRESTAPIConfiguration defines Logging API conf
 | ||||||
| type LoggingRESTAPIConfiguration struct { | type LoggingRESTAPIConfiguration struct { | ||||||
| 	APIPort               int `json:"api_port,omitempty"` | 	APIPort               int `json:"api_port,omitempty"` | ||||||
| 	RingLogLines          int `json:"ring_log_lines,omitempty"` | 	RingLogLines          int `json:"ring_log_lines,omitempty"` | ||||||
| 	ClusterHistoryEntries int `json:"cluster_history_entries,omitempty"` | 	ClusterHistoryEntries int `json:"cluster_history_entries,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // ScalyrConfiguration defines the configuration for ScalyrAPI
 | ||||||
| type ScalyrConfiguration struct { | type ScalyrConfiguration struct { | ||||||
| 	ScalyrAPIKey        string `json:"scalyr_api_key,omitempty"` | 	ScalyrAPIKey        string `json:"scalyr_api_key,omitempty"` | ||||||
| 	ScalyrImage         string `json:"scalyr_image,omitempty"` | 	ScalyrImage         string `json:"scalyr_image,omitempty"` | ||||||
|  | @ -119,6 +134,7 @@ type ScalyrConfiguration struct { | ||||||
| 	ScalyrMemoryLimit   string `json:"scalyr_memory_limit,omitempty"` | 	ScalyrMemoryLimit   string `json:"scalyr_memory_limit,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // OperatorConfigurationData defines the operation config
 | ||||||
| type OperatorConfigurationData struct { | type OperatorConfigurationData struct { | ||||||
| 	EtcdHost                   string                       `json:"etcd_host,omitempty"` | 	EtcdHost                   string                       `json:"etcd_host,omitempty"` | ||||||
| 	DockerImage                string                       `json:"docker_image,omitempty"` | 	DockerImage                string                       `json:"docker_image,omitempty"` | ||||||
|  | @ -141,6 +157,7 @@ type OperatorConfigurationData struct { | ||||||
| 	Scalyr                     ScalyrConfiguration          `json:"scalyr"` | 	Scalyr                     ScalyrConfiguration          `json:"scalyr"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // OperatorConfigurationUsers defines configration for super user
 | ||||||
| type OperatorConfigurationUsers struct { | type OperatorConfigurationUsers struct { | ||||||
| 	SuperUserName            string            `json:"superuser_name,omitempty"` | 	SuperUserName            string            `json:"superuser_name,omitempty"` | ||||||
| 	Replication              string            `json:"replication_user_name,omitempty"` | 	Replication              string            `json:"replication_user_name,omitempty"` | ||||||
|  | @ -148,4 +165,5 @@ type OperatorConfigurationUsers struct { | ||||||
| 	TeamAPIRoleConfiguration map[string]string `json:"team_api_role_configuration,omitempty"` | 	TeamAPIRoleConfiguration map[string]string `json:"team_api_role_configuration,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //Duration shortens this frequently used name
 | ||||||
| type Duration time.Duration | type Duration time.Duration | ||||||
|  |  | ||||||
|  | @ -9,7 +9,8 @@ import ( | ||||||
| 
 | 
 | ||||||
| // +genclient
 | // +genclient
 | ||||||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | ||||||
| //Postgresql defines PostgreSQL Custom Resource Definition Object.
 | 
 | ||||||
|  | // Postgresql defines PostgreSQL Custom Resource Definition Object.
 | ||||||
| type Postgresql struct { | type Postgresql struct { | ||||||
| 	metav1.TypeMeta   `json:",inline"` | 	metav1.TypeMeta   `json:",inline"` | ||||||
| 	metav1.ObjectMeta `json:"metadata,omitempty"` | 	metav1.ObjectMeta `json:"metadata,omitempty"` | ||||||
|  | @ -55,6 +56,7 @@ type PostgresSpec struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | ||||||
|  | 
 | ||||||
| // PostgresqlList defines a list of PostgreSQL clusters.
 | // PostgresqlList defines a list of PostgreSQL clusters.
 | ||||||
| type PostgresqlList struct { | type PostgresqlList struct { | ||||||
| 	metav1.TypeMeta `json:",inline"` | 	metav1.TypeMeta `json:",inline"` | ||||||
|  |  | ||||||
|  | @ -8,15 +8,20 @@ import ( | ||||||
| 	"github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" | 	"github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // APIVersion of the `postgresql` and `operator` CRDs
 | ||||||
| const ( | const ( | ||||||
| 	APIVersion = "v1" | 	APIVersion = "v1" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
| 	// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
 | 	// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
 | ||||||
|  | 
 | ||||||
|  | 	// An instance of runtime.SchemeBuilder, global for this package
 | ||||||
| 	SchemeBuilder      runtime.SchemeBuilder | 	SchemeBuilder      runtime.SchemeBuilder | ||||||
| 	localSchemeBuilder = &SchemeBuilder | 	localSchemeBuilder = &SchemeBuilder | ||||||
|  | 	//AddToScheme is localSchemeBuilder.AddToScheme
 | ||||||
| 	AddToScheme = localSchemeBuilder.AddToScheme | 	AddToScheme = localSchemeBuilder.AddToScheme | ||||||
|  | 	//SchemeGroupVersion has GroupName and APIVersion
 | ||||||
| 	SchemeGroupVersion = schema.GroupVersion{Group: acidzalando.GroupName, Version: APIVersion} | 	SchemeGroupVersion = schema.GroupVersion{Group: acidzalando.GroupName, Version: APIVersion} | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,6 +14,7 @@ var ( | ||||||
| 	serviceNameRegex = regexp.MustCompile(serviceNameRegexString) | 	serviceNameRegex = regexp.MustCompile(serviceNameRegexString) | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // Clone convenience wrapper around DeepCopy
 | ||||||
| func (p *Postgresql) Clone() *Postgresql { | func (p *Postgresql) Clone() *Postgresql { | ||||||
| 	if p == nil { | 	if p == nil { | ||||||
| 		return nil | 		return nil | ||||||
|  | @ -83,6 +84,7 @@ func validateCloneClusterDescription(clone *CloneDescription) error { | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Success of the current Status
 | ||||||
| func (status PostgresStatus) Success() bool { | func (status PostgresStatus) Success() bool { | ||||||
| 	return status != ClusterStatusAddFailed && | 	return status != ClusterStatusAddFailed && | ||||||
| 		status != ClusterStatusUpdateFailed && | 		status != ClusterStatusUpdateFailed && | ||||||
|  |  | ||||||
|  | @ -77,11 +77,7 @@ func (c *Cluster) deletePod(podName spec.NamespacedName) error { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if err := c.waitForPodDeletion(ch); err != nil { | 	return c.waitForPodDeletion(ch) | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return nil |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (c *Cluster) unregisterPodSubscriber(podName spec.NamespacedName) { | func (c *Cluster) unregisterPodSubscriber(podName spec.NamespacedName) { | ||||||
|  |  | ||||||
|  | @ -1,12 +1,13 @@ | ||||||
| package cluster | package cluster | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"time" | ||||||
|  | 
 | ||||||
| 	acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" | 	acidv1 "github.com/zalando-incubator/postgres-operator/pkg/apis/acid.zalan.do/v1" | ||||||
| 	"k8s.io/api/apps/v1beta1" | 	"k8s.io/api/apps/v1beta1" | ||||||
| 	"k8s.io/api/core/v1" | 	"k8s.io/api/core/v1" | ||||||
| 	policybeta1 "k8s.io/api/policy/v1beta1" | 	policybeta1 "k8s.io/api/policy/v1beta1" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"time" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // PostgresRole describes role of the node
 | // PostgresRole describes role of the node
 | ||||||
|  | @ -20,6 +21,7 @@ const ( | ||||||
| 	Replica PostgresRole = "replica" | 	Replica PostgresRole = "replica" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | // PodEventType represents the type of a pod-related event
 | ||||||
| type PodEventType string | type PodEventType string | ||||||
| 
 | 
 | ||||||
| // Possible values for the EventType
 | // Possible values for the EventType
 | ||||||
|  |  | ||||||
|  | @ -460,6 +460,7 @@ func (c *Cluster) setSpec(newSpec *acidv1.Postgresql) { | ||||||
| 	c.specMu.Unlock() | 	c.specMu.Unlock() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // GetSpec returns a copy of the operator-side spec of a Postgres cluster in a thread-safe manner
 | ||||||
| func (c *Cluster) GetSpec() (*acidv1.Postgresql, error) { | func (c *Cluster) GetSpec() (*acidv1.Postgresql, error) { | ||||||
| 	c.specMu.RLock() | 	c.specMu.RLock() | ||||||
| 	defer c.specMu.RUnlock() | 	defer c.specMu.RUnlock() | ||||||
|  |  | ||||||
|  | @ -126,6 +126,7 @@ func (n *NamespacedName) Decode(value string) error { | ||||||
| 	return n.DecodeWorker(value, GetOperatorNamespace()) | 	return n.DecodeWorker(value, GetOperatorNamespace()) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // UnmarshalJSON converts a byte slice to NamespacedName
 | ||||||
| func (n *NamespacedName) UnmarshalJSON(data []byte) error { | func (n *NamespacedName) UnmarshalJSON(data []byte) error { | ||||||
| 	result := NamespacedName{} | 	result := NamespacedName{} | ||||||
| 	var tmp string | 	var tmp string | ||||||
|  |  | ||||||
|  | @ -19,6 +19,7 @@ type fieldInfo struct { | ||||||
| 	Field   reflect.Value | 	Field   reflect.Value | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // StringTemplate is a convenience alias
 | ||||||
| type StringTemplate string | type StringTemplate string | ||||||
| 
 | 
 | ||||||
| func decoderFrom(field reflect.Value) (d decoder) { | func decoderFrom(field reflect.Value) (d decoder) { | ||||||
|  | @ -221,12 +222,14 @@ func getMapPairsFromString(value string) (pairs []string, err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Decode cast value to StringTemplate
 | ||||||
| func (f *StringTemplate) Decode(value string) error { | func (f *StringTemplate) Decode(value string) error { | ||||||
| 	*f = StringTemplate(value) | 	*f = StringTemplate(value) | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Format formatted string from StringTemplate
 | ||||||
| func (f *StringTemplate) Format(a ...string) string { | func (f *StringTemplate) Format(a ...string) string { | ||||||
| 	res := string(*f) | 	res := string(*f) | ||||||
| 
 | 
 | ||||||
|  | @ -237,6 +240,7 @@ func (f *StringTemplate) Format(a ...string) string { | ||||||
| 	return res | 	return res | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // MarshalJSON converts a StringTemplate to byte slice
 | ||||||
| func (f StringTemplate) MarshalJSON() ([]byte, error) { | func (f StringTemplate) MarshalJSON() ([]byte, error) { | ||||||
| 	return json.Marshal(string(f)) | 	return json.Marshal(string(f)) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -17,8 +17,10 @@ type Ticker struct { | ||||||
| 	ticker *time.Ticker | 	ticker *time.Ticker | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Stop is a convenience wrapper around ticker.Stop
 | ||||||
| func (t *Ticker) Stop() { t.ticker.Stop() } | func (t *Ticker) Stop() { t.ticker.Stop() } | ||||||
| 
 | 
 | ||||||
|  | // Tick is a convenience wrapper around ticker.C
 | ||||||
| func (t *Ticker) Tick() { <-t.ticker.C } | func (t *Ticker) Tick() { <-t.ticker.C } | ||||||
| 
 | 
 | ||||||
| // Retry is a wrapper around RetryWorker that provides a real RetryTicker
 | // Retry is a wrapper around RetryWorker that provides a real RetryTicker
 | ||||||
|  |  | ||||||
|  | @ -43,6 +43,7 @@ type httpClient interface { | ||||||
| 	Do(req *http.Request) (*http.Response, error) | 	Do(req *http.Request) (*http.Response, error) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // Interface to the TeamsAPIClient
 | ||||||
| type Interface interface { | type Interface interface { | ||||||
| 	TeamInfo(teamID, token string) (tm *Team, err error) | 	TeamInfo(teamID, token string) (tm *Team, err error) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue