diff --git a/apis/kubedb/v1alpha2/constants.go b/apis/kubedb/v1alpha2/constants.go index 5815c44853..f55f3a1eef 100644 --- a/apis/kubedb/v1alpha2/constants.go +++ b/apis/kubedb/v1alpha2/constants.go @@ -579,6 +579,7 @@ const ( PgpoolContainerName = "pgpool" PgpoolDefaultServicePort = 9999 PgpoolMonitoringDefaultServicePort = 9719 + PgpoolPcpPort = 9595 PgpoolExporterDatabase = "postgres" EnvPgpoolExporterDatabase = "POSTGRES_DATABASE" EnvPgpoolService = "PGPOOL_SERVICE" @@ -596,6 +597,8 @@ const ( PgpoolRootUser = "postgres" PgpoolPrimaryServicePortName = "primary" PgpoolDatabasePortName = "db" + PgpoolPcpPortName = "pcp" + PgpoolCustomConfigFile = "pgpool.conf" // ========================================== ZooKeeper Constants =================================================// KubeDBZooKeeperRoleName = "kubedb:zookeeper-version-reader" diff --git a/apis/kubedb/v1alpha2/pgpool_webhook.go b/apis/kubedb/v1alpha2/pgpool_webhook.go index 018ece3b6f..c99bb086e6 100644 --- a/apis/kubedb/v1alpha2/pgpool_webhook.go +++ b/apis/kubedb/v1alpha2/pgpool_webhook.go @@ -121,6 +121,36 @@ func (p *Pgpool) ValidateCreateOrUpdate() field.ErrorList { )) } + if p.Spec.ConfigSecret != nil && (p.Spec.InitConfiguration != nil && p.Spec.InitConfiguration.PgpoolConfig != nil) { + errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"), + p.Name, + "use either `spec.configSecret` or `spec.initConfig`")) + errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("initConfig"), + p.Name, + "use either `spec.configSecret` or `spec.initConfig`")) + } + + if p.Spec.ConfigSecret != nil { + secret := core.Secret{} + err := DefaultClient.Get(context.TODO(), types.NamespacedName{ + Name: p.Spec.ConfigSecret.Name, + Namespace: p.Namespace, + }, &secret) + if err != nil { + errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"), + p.Name, + err.Error(), + )) + } + _, ok := secret.Data[PgpoolCustomConfigFile] + if !ok { + errorList = append(errorList, field.Invalid(field.NewPath("spec").Child("configSecret"), + p.Name, + fmt.Sprintf("`%v` is missing", PgpoolCustomConfigFile), + )) + } + } + apb := appcat.AppBinding{} err := DefaultClient.Get(context.TODO(), types.NamespacedName{ Name: p.Spec.PostgresRef.Name, diff --git a/apis/ops/v1alpha1/openapi_generated.go b/apis/ops/v1alpha1/openapi_generated.go index fe6b3f9d5a..846b558f42 100644 --- a/apis/ops/v1alpha1/openapi_generated.go +++ b/apis/ops/v1alpha1/openapi_generated.go @@ -556,6 +556,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgBouncerReplicaReadinessCriteria": schema_apimachinery_apis_ops_v1alpha1_PgBouncerReplicaReadinessCriteria(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgBouncerUpdateVersionSpec": schema_apimachinery_apis_ops_v1alpha1_PgBouncerUpdateVersionSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgBouncerVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_PgBouncerVerticalScalingSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolCustomConfigurationSpec": schema_apimachinery_apis_ops_v1alpha1_PgpoolCustomConfigurationSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequest": schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequest(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequestList": schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequestList(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequestSpec": schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequestSpec(ref), + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolVerticalScalingSpec": schema_apimachinery_apis_ops_v1alpha1_PgpoolVerticalScalingSpec(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.PodResources": schema_apimachinery_apis_ops_v1alpha1_PodResources(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.PostgresCustomConfiguration": schema_apimachinery_apis_ops_v1alpha1_PostgresCustomConfiguration(ref), "kubedb.dev/apimachinery/apis/ops/v1alpha1.PostgresCustomConfigurationSpec": schema_apimachinery_apis_ops_v1alpha1_PostgresCustomConfigurationSpec(ref), @@ -26694,6 +26699,228 @@ func schema_apimachinery_apis_ops_v1alpha1_PgBouncerVerticalScalingSpec(ref comm } } +func schema_apimachinery_apis_ops_v1alpha1_PgpoolCustomConfigurationSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PgpoolCustomConfigurationSpec is the spec for Reconfiguring the Pgpool Settings", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "configSecret": { + SchemaProps: spec.SchemaProps{ + Description: "ConfigSecret is an optional field to provide custom configuration file for Pgpool.", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "applyConfig": { + SchemaProps: spec.SchemaProps{ + Description: "ApplyConfig is an optional field to provide Pgpool configuration. Provided configuration will be applied to config files stored in ConfigSecret. If the ConfigSecret is missing, the operator will create a new k8s secret by the following naming convention: {db-name}-config or use the previous init config if it exists. Expected input format: applyConfig:\n pgpool.conf: |-\n memory_cache_enabled = off", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "removeCustomConfig": { + SchemaProps: spec.SchemaProps{ + Description: "If set to \"true\", the user provided configuration via custom config and init config will be removed. Then Pgpool will start with default configuration that is generated by the operator.", + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequest(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), + }, + }, + "spec": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequestSpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.OpsRequestStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kubedb.dev/apimachinery/apis/ops/v1alpha1.OpsRequestStatus", "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequestSpec"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequestList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PgpoolOpsRequestList is a list of PgpoolOpsRequests", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "kind": { + SchemaProps: spec.SchemaProps{ + Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", + Type: []string{"string"}, + Format: "", + }, + }, + "apiVersion": { + SchemaProps: spec.SchemaProps{ + Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", + Type: []string{"string"}, + Format: "", + }, + }, + "metadata": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), + }, + }, + "items": { + SchemaProps: spec.SchemaProps{ + Description: "Items is a list of PgpoolOpsRequest CRD objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequest"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolOpsRequest"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_PgpoolOpsRequestSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PgpoolOpsRequestSpec is the spec for PgpoolOpsRequest", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "databaseRef": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the Pgpool reference", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + "type": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the ops request type: UpdateVersion, HorizontalScaling, VerticalScaling etc.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "verticalScaling": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for vertical scaling", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolVerticalScalingSpec"), + }, + }, + "configuration": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for custom configuration of Pgpool", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolCustomConfigurationSpec"), + }, + }, + "restart": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies information necessary for restarting database", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"), + }, + }, + "timeout": { + SchemaProps: spec.SchemaProps{ + Description: "Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.", + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.Duration"), + }, + }, + "apply": { + SchemaProps: spec.SchemaProps{ + Description: "ApplyOption is to control the execution of OpsRequest depending on the database state.", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"databaseRef", "type"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/apimachinery/pkg/apis/meta/v1.Duration", "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolCustomConfigurationSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.PgpoolVerticalScalingSpec", "kubedb.dev/apimachinery/apis/ops/v1alpha1.RestartSpec"}, + } +} + +func schema_apimachinery_apis_ops_v1alpha1_PgpoolVerticalScalingSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "PgpoolVerticalScalingSpec contains the vertical scaling information of a Pgpool cluster", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "node": { + SchemaProps: spec.SchemaProps{ + Description: "Resource spec for nodes", + Ref: ref("kubedb.dev/apimachinery/apis/ops/v1alpha1.PodResources"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/ops/v1alpha1.PodResources"}, + } +} + func schema_apimachinery_apis_ops_v1alpha1_PodResources(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/ops/v1alpha1/pgpool_ops_helpers.go b/apis/ops/v1alpha1/pgpool_ops_helpers.go new file mode 100644 index 0000000000..169582d1b7 --- /dev/null +++ b/apis/ops/v1alpha1/pgpool_ops_helpers.go @@ -0,0 +1,76 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "fmt" + + "kubedb.dev/apimachinery/apis" + "kubedb.dev/apimachinery/apis/ops" + "kubedb.dev/apimachinery/crds" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "kmodules.xyz/client-go/apiextensions" +) + +func (r *PgpoolOpsRequest) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { + return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralPgpoolOpsRequest)) +} + +var _ apis.ResourceInfo = &PgpoolOpsRequest{} + +func (r *PgpoolOpsRequest) ResourceFQN() string { + return fmt.Sprintf("%s.%s", ResourcePluralPgpoolOpsRequest, ops.GroupName) +} + +func (r *PgpoolOpsRequest) ResourceShortCode() string { + return ResourceCodePgpoolOpsRequest +} + +func (r *PgpoolOpsRequest) ResourceKind() string { + return ResourceKindPgpoolOpsRequest +} + +func (r *PgpoolOpsRequest) ResourceSingular() string { + return ResourceSingularPgpoolOpsRequest +} + +func (r *PgpoolOpsRequest) ResourcePlural() string { + return ResourcePluralPgpoolOpsRequest +} + +var _ Accessor = &PgpoolOpsRequest{} + +func (r *PgpoolOpsRequest) GetObjectMeta() metav1.ObjectMeta { + return r.ObjectMeta +} + +func (r *PgpoolOpsRequest) GetDBRefName() string { + return r.Spec.DatabaseRef.Name +} + +func (r *PgpoolOpsRequest) GetRequestType() any { + return r.Spec.Type +} + +func (r *PgpoolOpsRequest) GetStatus() OpsRequestStatus { + return r.Status +} + +func (r *PgpoolOpsRequest) SetStatus(s OpsRequestStatus) { + r.Status = s +} diff --git a/apis/ops/v1alpha1/pgpool_ops_types.go b/apis/ops/v1alpha1/pgpool_ops_types.go new file mode 100644 index 0000000000..de87cd6207 --- /dev/null +++ b/apis/ops/v1alpha1/pgpool_ops_types.go @@ -0,0 +1,109 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//go:generate go-enum --mustparse --names --values +package v1alpha1 + +import ( + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ResourceCodePgpoolOpsRequest = "ppops" + ResourceKindPgpoolOpsRequest = "PgpoolOpsRequest" + ResourceSingularPgpoolOpsRequest = "pgpoolopsrequest" + ResourcePluralPgpoolOpsRequest = "pgpoolopsrequests" +) + +// PgpoolDBOpsRequest defines a Pgpool DBA operation. + +// +genclient +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=pgpoolopsrequests,singular=pgpoolopsrequest,shortName=ppops,categories={datastore,kubedb,appscode} +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type" +// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +type PgpoolOpsRequest struct { + metav1.TypeMeta `json:",inline,omitempty"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec PgpoolOpsRequestSpec `json:"spec,omitempty"` + Status OpsRequestStatus `json:"status,omitempty"` +} + +// PgpoolOpsRequestSpec is the spec for PgpoolOpsRequest +type PgpoolOpsRequestSpec struct { + // Specifies the Pgpool reference + DatabaseRef core.LocalObjectReference `json:"databaseRef"` + // Specifies the ops request type: UpdateVersion, HorizontalScaling, VerticalScaling etc. + Type PgpoolOpsRequestType `json:"type"` + // Specifies information necessary for vertical scaling + VerticalScaling *PgpoolVerticalScalingSpec `json:"verticalScaling,omitempty"` + // Specifies information necessary for custom configuration of Pgpool + Configuration *PgpoolCustomConfigurationSpec `json:"configuration,omitempty"` + // Specifies information necessary for restarting database + Restart *RestartSpec `json:"restart,omitempty"` + // Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure. + Timeout *metav1.Duration `json:"timeout,omitempty"` + // ApplyOption is to control the execution of OpsRequest depending on the database state. + // +kubebuilder:default="IfReady" + Apply ApplyOption `json:"apply,omitempty"` +} + +// +kubebuilder:validation:Enum=VerticalScaling;Reconfigure;Restart +// ENUM(VerticalScaling, Restart, Reconfigure) +type PgpoolOpsRequestType string + +// PgpoolVerticalScalingSpec contains the vertical scaling information of a Pgpool cluster +type PgpoolVerticalScalingSpec struct { + // Resource spec for nodes + Node *PodResources `json:"node,omitempty"` +} + +// PgpoolCustomConfigurationSpec is the spec for Reconfiguring the Pgpool Settings +type PgpoolCustomConfigurationSpec struct { + // ConfigSecret is an optional field to provide custom configuration file for Pgpool. + // +optional + ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"` + // ApplyConfig is an optional field to provide Pgpool configuration. + // Provided configuration will be applied to config files stored in ConfigSecret. + // If the ConfigSecret is missing, the operator will create a new k8s secret by the + // following naming convention: {db-name}-config or use the previous init config if it exists. + // Expected input format: + // applyConfig: + // pgpool.conf: |- + // memory_cache_enabled = off + // +optional + ApplyConfig map[string]string `json:"applyConfig,omitempty"` + // If set to "true", the user provided configuration via custom config and init config will be removed. + // Then Pgpool will start with default configuration that is generated by the operator. + // +optional + RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PgpoolOpsRequestList is a list of PgpoolOpsRequests +type PgpoolOpsRequestList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is a list of PgpoolOpsRequest CRD objects + Items []PgpoolOpsRequest `json:"items,omitempty"` +} diff --git a/apis/ops/v1alpha1/pgpool_ops_types_enum.go b/apis/ops/v1alpha1/pgpool_ops_types_enum.go new file mode 100644 index 0000000000..b787338018 --- /dev/null +++ b/apis/ops/v1alpha1/pgpool_ops_types_enum.go @@ -0,0 +1,80 @@ +// Code generated by go-enum DO NOT EDIT. +// Version: +// Revision: +// Build Date: +// Built By: + +package v1alpha1 + +import ( + "fmt" + "strings" +) + +const ( + // PgpoolOpsRequestTypeVerticalScaling is a PgpoolOpsRequestType of type VerticalScaling. + PgpoolOpsRequestTypeVerticalScaling PgpoolOpsRequestType = "VerticalScaling" + // PgpoolOpsRequestTypeRestart is a PgpoolOpsRequestType of type Restart. + PgpoolOpsRequestTypeRestart PgpoolOpsRequestType = "Restart" + // PgpoolOpsRequestTypeReconfigure is a PgpoolOpsRequestType of type Reconfigure. + PgpoolOpsRequestTypeReconfigure PgpoolOpsRequestType = "Reconfigure" +) + +var ErrInvalidPgpoolOpsRequestType = fmt.Errorf("not a valid PgpoolOpsRequestType, try [%s]", strings.Join(_PgpoolOpsRequestTypeNames, ", ")) + +var _PgpoolOpsRequestTypeNames = []string{ + string(PgpoolOpsRequestTypeVerticalScaling), + string(PgpoolOpsRequestTypeRestart), + string(PgpoolOpsRequestTypeReconfigure), +} + +// PgpoolOpsRequestTypeNames returns a list of possible string values of PgpoolOpsRequestType. +func PgpoolOpsRequestTypeNames() []string { + tmp := make([]string, len(_PgpoolOpsRequestTypeNames)) + copy(tmp, _PgpoolOpsRequestTypeNames) + return tmp +} + +// PgpoolOpsRequestTypeValues returns a list of the values for PgpoolOpsRequestType +func PgpoolOpsRequestTypeValues() []PgpoolOpsRequestType { + return []PgpoolOpsRequestType{ + PgpoolOpsRequestTypeVerticalScaling, + PgpoolOpsRequestTypeRestart, + PgpoolOpsRequestTypeReconfigure, + } +} + +// String implements the Stringer interface. +func (x PgpoolOpsRequestType) String() string { + return string(x) +} + +// IsValid provides a quick way to determine if the typed value is +// part of the allowed enumerated values +func (x PgpoolOpsRequestType) IsValid() bool { + _, err := ParsePgpoolOpsRequestType(string(x)) + return err == nil +} + +var _PgpoolOpsRequestTypeValue = map[string]PgpoolOpsRequestType{ + "VerticalScaling": PgpoolOpsRequestTypeVerticalScaling, + "Restart": PgpoolOpsRequestTypeRestart, + "Reconfigure": PgpoolOpsRequestTypeReconfigure, +} + +// ParsePgpoolOpsRequestType attempts to convert a string to a PgpoolOpsRequestType. +func ParsePgpoolOpsRequestType(name string) (PgpoolOpsRequestType, error) { + if x, ok := _PgpoolOpsRequestTypeValue[name]; ok { + return x, nil + } + return PgpoolOpsRequestType(""), fmt.Errorf("%s is %w", name, ErrInvalidPgpoolOpsRequestType) +} + +// MustParsePgpoolOpsRequestType converts a string to a PgpoolOpsRequestType, and panics if is not valid. +func MustParsePgpoolOpsRequestType(name string) PgpoolOpsRequestType { + val, err := ParsePgpoolOpsRequestType(name) + if err != nil { + panic(err) + } + return val +} diff --git a/apis/ops/v1alpha1/register.go b/apis/ops/v1alpha1/register.go index a24601ce7d..72c4dee088 100644 --- a/apis/ops/v1alpha1/register.go +++ b/apis/ops/v1alpha1/register.go @@ -72,6 +72,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PerconaXtraDBOpsRequestList{}, &PostgresOpsRequest{}, &PostgresOpsRequestList{}, + &PgpoolOpsRequest{}, + &PgpoolOpsRequestList{}, &ProxySQLOpsRequest{}, &ProxySQLOpsRequestList{}, &RabbitMQOpsRequest{}, diff --git a/apis/ops/v1alpha1/zz_generated.deepcopy.go b/apis/ops/v1alpha1/zz_generated.deepcopy.go index 6e2027b661..d7ae08c6b3 100644 --- a/apis/ops/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ops/v1alpha1/zz_generated.deepcopy.go @@ -2944,6 +2944,153 @@ func (in *PgBouncerVerticalScalingSpec) DeepCopy() *PgBouncerVerticalScalingSpec return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PgpoolCustomConfigurationSpec) DeepCopyInto(out *PgpoolCustomConfigurationSpec) { + *out = *in + if in.ConfigSecret != nil { + in, out := &in.ConfigSecret, &out.ConfigSecret + *out = new(v1.LocalObjectReference) + **out = **in + } + if in.ApplyConfig != nil { + in, out := &in.ApplyConfig, &out.ApplyConfig + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PgpoolCustomConfigurationSpec. +func (in *PgpoolCustomConfigurationSpec) DeepCopy() *PgpoolCustomConfigurationSpec { + if in == nil { + return nil + } + out := new(PgpoolCustomConfigurationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PgpoolOpsRequest) DeepCopyInto(out *PgpoolOpsRequest) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PgpoolOpsRequest. +func (in *PgpoolOpsRequest) DeepCopy() *PgpoolOpsRequest { + if in == nil { + return nil + } + out := new(PgpoolOpsRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PgpoolOpsRequest) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PgpoolOpsRequestList) DeepCopyInto(out *PgpoolOpsRequestList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PgpoolOpsRequest, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PgpoolOpsRequestList. +func (in *PgpoolOpsRequestList) DeepCopy() *PgpoolOpsRequestList { + if in == nil { + return nil + } + out := new(PgpoolOpsRequestList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PgpoolOpsRequestList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PgpoolOpsRequestSpec) DeepCopyInto(out *PgpoolOpsRequestSpec) { + *out = *in + out.DatabaseRef = in.DatabaseRef + if in.VerticalScaling != nil { + in, out := &in.VerticalScaling, &out.VerticalScaling + *out = new(PgpoolVerticalScalingSpec) + (*in).DeepCopyInto(*out) + } + if in.Configuration != nil { + in, out := &in.Configuration, &out.Configuration + *out = new(PgpoolCustomConfigurationSpec) + (*in).DeepCopyInto(*out) + } + if in.Restart != nil { + in, out := &in.Restart, &out.Restart + *out = new(RestartSpec) + **out = **in + } + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(metav1.Duration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PgpoolOpsRequestSpec. +func (in *PgpoolOpsRequestSpec) DeepCopy() *PgpoolOpsRequestSpec { + if in == nil { + return nil + } + out := new(PgpoolOpsRequestSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PgpoolVerticalScalingSpec) DeepCopyInto(out *PgpoolVerticalScalingSpec) { + *out = *in + if in.Node != nil { + in, out := &in.Node, &out.Node + *out = new(PodResources) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PgpoolVerticalScalingSpec. +func (in *PgpoolVerticalScalingSpec) DeepCopy() *PgpoolVerticalScalingSpec { + if in == nil { + return nil + } + out := new(PgpoolVerticalScalingSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PodResources) DeepCopyInto(out *PodResources) { *out = *in diff --git a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go index bb8ff1fd1e..c888a36e4b 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_ops_client.go @@ -65,6 +65,10 @@ func (c *FakeOpsV1alpha1) PgBouncerOpsRequests(namespace string) v1alpha1.PgBoun return &FakePgBouncerOpsRequests{c, namespace} } +func (c *FakeOpsV1alpha1) PgpoolOpsRequests(namespace string) v1alpha1.PgpoolOpsRequestInterface { + return &FakePgpoolOpsRequests{c, namespace} +} + func (c *FakeOpsV1alpha1) PostgresOpsRequests(namespace string) v1alpha1.PostgresOpsRequestInterface { return &FakePostgresOpsRequests{c, namespace} } diff --git a/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_pgpoolopsrequest.go b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_pgpoolopsrequest.go new file mode 100644 index 0000000000..3d50cc39fb --- /dev/null +++ b/client/clientset/versioned/typed/ops/v1alpha1/fake/fake_pgpoolopsrequest.go @@ -0,0 +1,142 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakePgpoolOpsRequests implements PgpoolOpsRequestInterface +type FakePgpoolOpsRequests struct { + Fake *FakeOpsV1alpha1 + ns string +} + +var pgpoolopsrequestsResource = v1alpha1.SchemeGroupVersion.WithResource("pgpoolopsrequests") + +var pgpoolopsrequestsKind = v1alpha1.SchemeGroupVersion.WithKind("PgpoolOpsRequest") + +// Get takes name of the pgpoolOpsRequest, and returns the corresponding pgpoolOpsRequest object, and an error if there is any. +func (c *FakePgpoolOpsRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(pgpoolopsrequestsResource, c.ns, name), &v1alpha1.PgpoolOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PgpoolOpsRequest), err +} + +// List takes label and field selectors, and returns the list of PgpoolOpsRequests that match those selectors. +func (c *FakePgpoolOpsRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PgpoolOpsRequestList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(pgpoolopsrequestsResource, pgpoolopsrequestsKind, c.ns, opts), &v1alpha1.PgpoolOpsRequestList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PgpoolOpsRequestList{ListMeta: obj.(*v1alpha1.PgpoolOpsRequestList).ListMeta} + for _, item := range obj.(*v1alpha1.PgpoolOpsRequestList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested pgpoolOpsRequests. +func (c *FakePgpoolOpsRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(pgpoolopsrequestsResource, c.ns, opts)) + +} + +// Create takes the representation of a pgpoolOpsRequest and creates it. Returns the server's representation of the pgpoolOpsRequest, and an error, if there is any. +func (c *FakePgpoolOpsRequests) Create(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.CreateOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(pgpoolopsrequestsResource, c.ns, pgpoolOpsRequest), &v1alpha1.PgpoolOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PgpoolOpsRequest), err +} + +// Update takes the representation of a pgpoolOpsRequest and updates it. Returns the server's representation of the pgpoolOpsRequest, and an error, if there is any. +func (c *FakePgpoolOpsRequests) Update(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(pgpoolopsrequestsResource, c.ns, pgpoolOpsRequest), &v1alpha1.PgpoolOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PgpoolOpsRequest), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakePgpoolOpsRequests) UpdateStatus(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (*v1alpha1.PgpoolOpsRequest, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(pgpoolopsrequestsResource, "status", c.ns, pgpoolOpsRequest), &v1alpha1.PgpoolOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PgpoolOpsRequest), err +} + +// Delete takes name of the pgpoolOpsRequest and deletes it. Returns an error if one occurs. +func (c *FakePgpoolOpsRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(pgpoolopsrequestsResource, c.ns, name, opts), &v1alpha1.PgpoolOpsRequest{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePgpoolOpsRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(pgpoolopsrequestsResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.PgpoolOpsRequestList{}) + return err +} + +// Patch applies the patch and returns the patched pgpoolOpsRequest. +func (c *FakePgpoolOpsRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PgpoolOpsRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(pgpoolopsrequestsResource, c.ns, name, pt, data, subresources...), &v1alpha1.PgpoolOpsRequest{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PgpoolOpsRequest), err +} diff --git a/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go index ff6cfc5221..9ed69070e3 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/generated_expansion.go @@ -36,6 +36,8 @@ type PerconaXtraDBOpsRequestExpansion interface{} type PgBouncerOpsRequestExpansion interface{} +type PgpoolOpsRequestExpansion interface{} + type PostgresOpsRequestExpansion interface{} type ProxySQLOpsRequestExpansion interface{} diff --git a/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go b/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go index 26c593c69d..c2e6d5e744 100644 --- a/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go +++ b/client/clientset/versioned/typed/ops/v1alpha1/ops_client.go @@ -38,6 +38,7 @@ type OpsV1alpha1Interface interface { MySQLOpsRequestsGetter PerconaXtraDBOpsRequestsGetter PgBouncerOpsRequestsGetter + PgpoolOpsRequestsGetter PostgresOpsRequestsGetter ProxySQLOpsRequestsGetter RabbitMQOpsRequestsGetter @@ -87,6 +88,10 @@ func (c *OpsV1alpha1Client) PgBouncerOpsRequests(namespace string) PgBouncerOpsR return newPgBouncerOpsRequests(c, namespace) } +func (c *OpsV1alpha1Client) PgpoolOpsRequests(namespace string) PgpoolOpsRequestInterface { + return newPgpoolOpsRequests(c, namespace) +} + func (c *OpsV1alpha1Client) PostgresOpsRequests(namespace string) PostgresOpsRequestInterface { return newPostgresOpsRequests(c, namespace) } diff --git a/client/clientset/versioned/typed/ops/v1alpha1/pgpoolopsrequest.go b/client/clientset/versioned/typed/ops/v1alpha1/pgpoolopsrequest.go new file mode 100644 index 0000000000..4706181006 --- /dev/null +++ b/client/clientset/versioned/typed/ops/v1alpha1/pgpoolopsrequest.go @@ -0,0 +1,196 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + scheme "kubedb.dev/apimachinery/client/clientset/versioned/scheme" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// PgpoolOpsRequestsGetter has a method to return a PgpoolOpsRequestInterface. +// A group's client should implement this interface. +type PgpoolOpsRequestsGetter interface { + PgpoolOpsRequests(namespace string) PgpoolOpsRequestInterface +} + +// PgpoolOpsRequestInterface has methods to work with PgpoolOpsRequest resources. +type PgpoolOpsRequestInterface interface { + Create(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.CreateOptions) (*v1alpha1.PgpoolOpsRequest, error) + Update(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (*v1alpha1.PgpoolOpsRequest, error) + UpdateStatus(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (*v1alpha1.PgpoolOpsRequest, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.PgpoolOpsRequest, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.PgpoolOpsRequestList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PgpoolOpsRequest, err error) + PgpoolOpsRequestExpansion +} + +// pgpoolOpsRequests implements PgpoolOpsRequestInterface +type pgpoolOpsRequests struct { + client rest.Interface + ns string +} + +// newPgpoolOpsRequests returns a PgpoolOpsRequests +func newPgpoolOpsRequests(c *OpsV1alpha1Client, namespace string) *pgpoolOpsRequests { + return &pgpoolOpsRequests{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the pgpoolOpsRequest, and returns the corresponding pgpoolOpsRequest object, and an error if there is any. +func (c *pgpoolOpsRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + result = &v1alpha1.PgpoolOpsRequest{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PgpoolOpsRequests that match those selectors. +func (c *pgpoolOpsRequests) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.PgpoolOpsRequestList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PgpoolOpsRequestList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested pgpoolOpsRequests. +func (c *pgpoolOpsRequests) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a pgpoolOpsRequest and creates it. Returns the server's representation of the pgpoolOpsRequest, and an error, if there is any. +func (c *pgpoolOpsRequests) Create(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.CreateOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + result = &v1alpha1.PgpoolOpsRequest{} + err = c.client.Post(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pgpoolOpsRequest). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a pgpoolOpsRequest and updates it. Returns the server's representation of the pgpoolOpsRequest, and an error, if there is any. +func (c *pgpoolOpsRequests) Update(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + result = &v1alpha1.PgpoolOpsRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + Name(pgpoolOpsRequest.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pgpoolOpsRequest). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *pgpoolOpsRequests) UpdateStatus(ctx context.Context, pgpoolOpsRequest *v1alpha1.PgpoolOpsRequest, opts v1.UpdateOptions) (result *v1alpha1.PgpoolOpsRequest, err error) { + result = &v1alpha1.PgpoolOpsRequest{} + err = c.client.Put(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + Name(pgpoolOpsRequest.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(pgpoolOpsRequest). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the pgpoolOpsRequest and deletes it. Returns an error if one occurs. +func (c *pgpoolOpsRequests) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *pgpoolOpsRequests) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched pgpoolOpsRequest. +func (c *pgpoolOpsRequests) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.PgpoolOpsRequest, err error) { + result = &v1alpha1.PgpoolOpsRequest{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("pgpoolopsrequests"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/informers/externalversions/generic.go b/client/informers/externalversions/generic.go index 578f807612..2b604e111a 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -228,6 +228,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().PerconaXtraDBOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("pgbounceropsrequests"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().PgBouncerOpsRequests().Informer()}, nil + case opsv1alpha1.SchemeGroupVersion.WithResource("pgpoolopsrequests"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().PgpoolOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("postgresopsrequests"): return &genericInformer{resource: resource.GroupResource(), informer: f.Ops().V1alpha1().PostgresOpsRequests().Informer()}, nil case opsv1alpha1.SchemeGroupVersion.WithResource("proxysqlopsrequests"): diff --git a/client/informers/externalversions/ops/v1alpha1/interface.go b/client/informers/externalversions/ops/v1alpha1/interface.go index 3a21478cca..3944ee3fdb 100644 --- a/client/informers/externalversions/ops/v1alpha1/interface.go +++ b/client/informers/externalversions/ops/v1alpha1/interface.go @@ -42,6 +42,8 @@ type Interface interface { PerconaXtraDBOpsRequests() PerconaXtraDBOpsRequestInformer // PgBouncerOpsRequests returns a PgBouncerOpsRequestInformer. PgBouncerOpsRequests() PgBouncerOpsRequestInformer + // PgpoolOpsRequests returns a PgpoolOpsRequestInformer. + PgpoolOpsRequests() PgpoolOpsRequestInformer // PostgresOpsRequests returns a PostgresOpsRequestInformer. PostgresOpsRequests() PostgresOpsRequestInformer // ProxySQLOpsRequests returns a ProxySQLOpsRequestInformer. @@ -112,6 +114,11 @@ func (v *version) PgBouncerOpsRequests() PgBouncerOpsRequestInformer { return &pgBouncerOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// PgpoolOpsRequests returns a PgpoolOpsRequestInformer. +func (v *version) PgpoolOpsRequests() PgpoolOpsRequestInformer { + return &pgpoolOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PostgresOpsRequests returns a PostgresOpsRequestInformer. func (v *version) PostgresOpsRequests() PostgresOpsRequestInformer { return &postgresOpsRequestInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/client/informers/externalversions/ops/v1alpha1/pgpoolopsrequest.go b/client/informers/externalversions/ops/v1alpha1/pgpoolopsrequest.go new file mode 100644 index 0000000000..0d493f98ec --- /dev/null +++ b/client/informers/externalversions/ops/v1alpha1/pgpoolopsrequest.go @@ -0,0 +1,91 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + opsv1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + versioned "kubedb.dev/apimachinery/client/clientset/versioned" + internalinterfaces "kubedb.dev/apimachinery/client/informers/externalversions/internalinterfaces" + v1alpha1 "kubedb.dev/apimachinery/client/listers/ops/v1alpha1" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// PgpoolOpsRequestInformer provides access to a shared informer and lister for +// PgpoolOpsRequests. +type PgpoolOpsRequestInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PgpoolOpsRequestLister +} + +type pgpoolOpsRequestInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPgpoolOpsRequestInformer constructs a new informer for PgpoolOpsRequest type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPgpoolOpsRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPgpoolOpsRequestInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPgpoolOpsRequestInformer constructs a new informer for PgpoolOpsRequest type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPgpoolOpsRequestInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpsV1alpha1().PgpoolOpsRequests(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OpsV1alpha1().PgpoolOpsRequests(namespace).Watch(context.TODO(), options) + }, + }, + &opsv1alpha1.PgpoolOpsRequest{}, + resyncPeriod, + indexers, + ) +} + +func (f *pgpoolOpsRequestInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPgpoolOpsRequestInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *pgpoolOpsRequestInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&opsv1alpha1.PgpoolOpsRequest{}, f.defaultInformer) +} + +func (f *pgpoolOpsRequestInformer) Lister() v1alpha1.PgpoolOpsRequestLister { + return v1alpha1.NewPgpoolOpsRequestLister(f.Informer().GetIndexer()) +} diff --git a/client/listers/ops/v1alpha1/expansion_generated.go b/client/listers/ops/v1alpha1/expansion_generated.go index 4b36c9fca1..7d05b1aeaf 100644 --- a/client/listers/ops/v1alpha1/expansion_generated.go +++ b/client/listers/ops/v1alpha1/expansion_generated.go @@ -90,6 +90,14 @@ type PgBouncerOpsRequestListerExpansion interface{} // PgBouncerOpsRequestNamespaceLister. type PgBouncerOpsRequestNamespaceListerExpansion interface{} +// PgpoolOpsRequestListerExpansion allows custom methods to be added to +// PgpoolOpsRequestLister. +type PgpoolOpsRequestListerExpansion interface{} + +// PgpoolOpsRequestNamespaceListerExpansion allows custom methods to be added to +// PgpoolOpsRequestNamespaceLister. +type PgpoolOpsRequestNamespaceListerExpansion interface{} + // PostgresOpsRequestListerExpansion allows custom methods to be added to // PostgresOpsRequestLister. type PostgresOpsRequestListerExpansion interface{} diff --git a/client/listers/ops/v1alpha1/pgpoolopsrequest.go b/client/listers/ops/v1alpha1/pgpoolopsrequest.go new file mode 100644 index 0000000000..1d169f4538 --- /dev/null +++ b/client/listers/ops/v1alpha1/pgpoolopsrequest.go @@ -0,0 +1,100 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "kubedb.dev/apimachinery/apis/ops/v1alpha1" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// PgpoolOpsRequestLister helps list PgpoolOpsRequests. +// All objects returned here must be treated as read-only. +type PgpoolOpsRequestLister interface { + // List lists all PgpoolOpsRequests in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PgpoolOpsRequest, err error) + // PgpoolOpsRequests returns an object that can list and get PgpoolOpsRequests. + PgpoolOpsRequests(namespace string) PgpoolOpsRequestNamespaceLister + PgpoolOpsRequestListerExpansion +} + +// pgpoolOpsRequestLister implements the PgpoolOpsRequestLister interface. +type pgpoolOpsRequestLister struct { + indexer cache.Indexer +} + +// NewPgpoolOpsRequestLister returns a new PgpoolOpsRequestLister. +func NewPgpoolOpsRequestLister(indexer cache.Indexer) PgpoolOpsRequestLister { + return &pgpoolOpsRequestLister{indexer: indexer} +} + +// List lists all PgpoolOpsRequests in the indexer. +func (s *pgpoolOpsRequestLister) List(selector labels.Selector) (ret []*v1alpha1.PgpoolOpsRequest, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PgpoolOpsRequest)) + }) + return ret, err +} + +// PgpoolOpsRequests returns an object that can list and get PgpoolOpsRequests. +func (s *pgpoolOpsRequestLister) PgpoolOpsRequests(namespace string) PgpoolOpsRequestNamespaceLister { + return pgpoolOpsRequestNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PgpoolOpsRequestNamespaceLister helps list and get PgpoolOpsRequests. +// All objects returned here must be treated as read-only. +type PgpoolOpsRequestNamespaceLister interface { + // List lists all PgpoolOpsRequests in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.PgpoolOpsRequest, err error) + // Get retrieves the PgpoolOpsRequest from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.PgpoolOpsRequest, error) + PgpoolOpsRequestNamespaceListerExpansion +} + +// pgpoolOpsRequestNamespaceLister implements the PgpoolOpsRequestNamespaceLister +// interface. +type pgpoolOpsRequestNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PgpoolOpsRequests in the indexer for a given namespace. +func (s pgpoolOpsRequestNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PgpoolOpsRequest, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PgpoolOpsRequest)) + }) + return ret, err +} + +// Get retrieves the PgpoolOpsRequest from the indexer for a given namespace and name. +func (s pgpoolOpsRequestNamespaceLister) Get(name string) (*v1alpha1.PgpoolOpsRequest, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("pgpoolopsrequest"), name) + } + return obj.(*v1alpha1.PgpoolOpsRequest), nil +} diff --git a/crds/ops.kubedb.com_pgpoolopsrequests.yaml b/crds/ops.kubedb.com_pgpoolopsrequests.yaml new file mode 100644 index 0000000000..98f8ff23bb --- /dev/null +++ b/crds/ops.kubedb.com_pgpoolopsrequests.yaml @@ -0,0 +1,199 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: kubedb + name: pgpoolopsrequests.ops.kubedb.com +spec: + group: ops.kubedb.com + names: + categories: + - datastore + - kubedb + - appscode + kind: PgpoolOpsRequest + listKind: PgpoolOpsRequestList + plural: pgpoolopsrequests + shortNames: + - ppops + singular: pgpoolopsrequest + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.type + name: Type + type: string + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + apply: + default: IfReady + enum: + - IfReady + - Always + type: string + configuration: + properties: + applyConfig: + additionalProperties: + type: string + type: object + configSecret: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + removeCustomConfig: + type: boolean + type: object + databaseRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + restart: + type: object + timeout: + type: string + type: + enum: + - VerticalScaling + - Reconfigure + - Restart + type: string + verticalScaling: + properties: + node: + properties: + nodeSelectionPolicy: + enum: + - LabelSelector + - Taint + type: string + resources: + properties: + claims: + items: + properties: + name: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + topology: + properties: + key: + type: string + value: + type: string + required: + - key + - value + type: object + type: object + type: object + required: + - databaseRef + - type + type: object + status: + properties: + conditions: + items: + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + observedGeneration: + format: int64 + type: integer + reason: + type: string + severity: + type: string + status: + type: string + type: + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + observedGeneration: + format: int64 + type: integer + pausedBackups: + items: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - name + type: object + type: array + phase: + enum: + - Pending + - Progressing + - Successful + - WaitingForApproval + - Failed + - Approved + - Denied + - Skipped + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {}