Skip to content

Commit

Permalink
Add ProxySQLVersion types (kubedb#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
shudipta authored and tamalsaha committed Oct 6, 2019
1 parent 7fdba5b commit 7c01ece
Show file tree
Hide file tree
Showing 16 changed files with 1,391 additions and 0 deletions.
461 changes: 461 additions & 0 deletions api/crds/catalog.kubedb.com_proxysqlversions.yaml

Large diffs are not rendered by default.

199 changes: 199 additions & 0 deletions apis/catalog/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions apis/catalog/v1alpha1/proxysql_version_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package v1alpha1

import (
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
crdutils "kmodules.xyz/client-go/apiextensions/v1beta1"
"kubedb.dev/apimachinery/apis"
)

var _ apis.ResourceInfo = &ProxySQLVersion{}

func (p ProxySQLVersion) ResourceShortCode() string {
return ""
}

func (p ProxySQLVersion) ResourceKind() string {
return ResourceKindProxySQLVersion
}

func (p ProxySQLVersion) ResourceSingular() string {
return ResourceSingularProxySQLVersion
}

func (p ProxySQLVersion) ResourcePlural() string {
return ResourcePluralProxySQLVersion
}

func (p ProxySQLVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crdutils.NewCustomResourceDefinition(crdutils.Config{
Group: SchemeGroupVersion.Group,
Plural: ResourcePluralProxySQLVersion,
Singular: ResourceSingularProxySQLVersion,
Kind: ResourceKindProxySQLVersion,
Categories: []string{"datastore", "kubedb", "appscode"},
ResourceScope: string(apiextensions.ClusterScoped),
Versions: []apiextensions.CustomResourceDefinitionVersion{
{
Name: SchemeGroupVersion.Version,
Served: true,
Storage: true,
},
},
Labels: crdutils.Labels{
LabelsMap: map[string]string{"app": "kubedb"},
},
SpecDefinitionName: "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ProxySQLVersion",
EnableValidation: true,
GetOpenAPIDefinitions: GetOpenAPIDefinitions,
EnableStatusSubresource: false,
AdditionalPrinterColumns: []apiextensions.CustomResourceColumnDefinition{
{
Name: "Version",
Type: "string",
JSONPath: ".spec.version",
},
{
Name: "PROXYSQL_IMAGE",
Type: "string",
JSONPath: ".spec.proxysql.image",
},
{
Name: "Deprecated",
Type: "boolean",
JSONPath: ".spec.deprecated",
},
{
Name: "Age",
Type: "date",
JSONPath: ".metadata.creationTimestamp",
},
},
})
}
69 changes: 69 additions & 0 deletions apis/catalog/v1alpha1/proxysql_version_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

const (
ResourceKindProxySQLVersion = "ProxySQLVersion"
ResourceSingularProxySQLVersion = "proxysqlversion"
ResourcePluralProxySQLVersion = "proxysqlversions"
)

// ProxySQLVersion defines a ProxySQL load-balancer version.

// +genclient
// +genclient:nonNamespaced
// +genclient:skipVerbs=updateStatus
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=proxysqlversions,singular=proxysqlversion,scope=Cluster,categories={datastore,kubedb,appscode}
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
// +kubebuilder:printcolumn:name="DB_IMAGE",type="string",JSONPath=".spec.db.image"
// +kubebuilder:printcolumn:name="Deprecated",type="boolean",JSONPath=".spec.deprecated"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
type ProxySQLVersion struct {
metav1.TypeMeta `json:",inline,omitempty"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ProxySQLVersionSpec `json:"spec,omitempty"`
}

// ProxySQLVersionSpec is the spec for ProxySQL version
type ProxySQLVersionSpec struct {
// Version
Version string `json:"version"`
// Proxysql Image
Proxysql ProxySQLVersionProxysql `json:"proxysql"`
// Exporter Image
Exporter ProxySQLVersionExporter `json:"exporter"`
// Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded.
// +optional
Deprecated bool `json:"deprecated,omitempty"`
// PSP names
PodSecurityPolicies ProxySQLVersionPodSecurityPolicy `json:"podSecurityPolicies"`
}

// ProxySQLVersionProxysql is the proxysql image
type ProxySQLVersionProxysql struct {
Image string `json:"image"`
}

// ProxySQLVersionExporter is the image for the ProxySQL exporter
type ProxySQLVersionExporter struct {
Image string `json:"image"`
}

// ProxySQLVersionPodSecurityPolicy is the ProxySQL pod security policies
type ProxySQLVersionPodSecurityPolicy struct {
DatabasePolicyName string `json:"databasePolicyName"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ProxySQLVersionList is a list of ProxySQLVersions
type ProxySQLVersionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
// Items is a list of ProxySQLVersion CRD objects
Items []ProxySQLVersion `json:"items,omitempty"`
}
2 changes: 2 additions & 0 deletions apis/catalog/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&RedisVersionList{},
&EtcdVersion{},
&EtcdVersionList{},
&ProxySQLVersion{},
&ProxySQLVersionList{},
)

scheme.AddKnownTypes(SchemeGroupVersion,
Expand Down
Loading

0 comments on commit 7c01ece

Please sign in to comment.