From 8a5f4bd190b95197aca1821bcfcf8e207eb3c640 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Thu, 16 May 2024 15:11:57 +0600 Subject: [PATCH 1/7] Add Kafka Schema Registry APIs Signed-off-by: obaydullahmhs --- apis/kafka/v1alpha1/constants.go | 6 + apis/kafka/v1alpha1/openapi_generated.go | 235 ++ apis/kafka/v1alpha1/register.go | 2 + apis/kafka/v1alpha1/schemaregistry_helpers.go | 295 ++ apis/kafka/v1alpha1/schemaregistry_types.go | 118 + apis/kafka/v1alpha1/schemaregistry_webhook.go | 199 ++ apis/kafka/v1alpha1/zz_generated.deepcopy.go | 140 + .../kafka/v1alpha1/fake/fake_kafka_client.go | 4 + .../v1alpha1/fake/fake_schemaregistry.go | 142 + .../kafka/v1alpha1/generated_expansion.go | 2 + .../typed/kafka/v1alpha1/kafka_client.go | 5 + .../typed/kafka/v1alpha1/schemaregistry.go | 196 ++ client/informers/externalversions/generic.go | 2 + .../kafka/v1alpha1/interface.go | 7 + .../kafka/v1alpha1/schemaregistry.go | 91 + .../kafka/v1alpha1/expansion_generated.go | 8 + .../listers/kafka/v1alpha1/schemaregistry.go | 100 + crds/kafka.kubedb.com_schemaregistries.yaml | 3094 +++++++++++++++++ .../client-go/discovery/fake/discovery.go | 174 - vendor/modules.txt | 1 - 20 files changed, 4646 insertions(+), 175 deletions(-) create mode 100644 apis/kafka/v1alpha1/schemaregistry_helpers.go create mode 100644 apis/kafka/v1alpha1/schemaregistry_types.go create mode 100644 apis/kafka/v1alpha1/schemaregistry_webhook.go create mode 100644 client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_schemaregistry.go create mode 100644 client/clientset/versioned/typed/kafka/v1alpha1/schemaregistry.go create mode 100644 client/informers/externalversions/kafka/v1alpha1/schemaregistry.go create mode 100644 client/listers/kafka/v1alpha1/schemaregistry.go create mode 100644 crds/kafka.kubedb.com_schemaregistries.yaml delete mode 100644 vendor/k8s.io/client-go/discovery/fake/discovery.go diff --git a/apis/kafka/v1alpha1/constants.go b/apis/kafka/v1alpha1/constants.go index 12e647223f..65156190c2 100644 --- a/apis/kafka/v1alpha1/constants.go +++ b/apis/kafka/v1alpha1/constants.go @@ -94,3 +94,9 @@ const ( KafkaClientKeystoreLocation = "/var/private/kafka-client-ssl/client.keystore.jks" KafkaClientTruststoreLocation = "/var/private/kafka-client-ssl/client.truststore.jks" ) + +// SchemaRegistry constants + +const ( + SchemaRegistryContainerName = "schema-registry" +) diff --git a/apis/kafka/v1alpha1/openapi_generated.go b/apis/kafka/v1alpha1/openapi_generated.go index 3e40695659..9d24d47446 100644 --- a/apis/kafka/v1alpha1/openapi_generated.go +++ b/apis/kafka/v1alpha1/openapi_generated.go @@ -465,6 +465,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kafka/v1alpha1.ConnectorList": schema_apimachinery_apis_kafka_v1alpha1_ConnectorList(ref), "kubedb.dev/apimachinery/apis/kafka/v1alpha1.ConnectorSpec": schema_apimachinery_apis_kafka_v1alpha1_ConnectorSpec(ref), "kubedb.dev/apimachinery/apis/kafka/v1alpha1.ConnectorStatus": schema_apimachinery_apis_kafka_v1alpha1_ConnectorStatus(ref), + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistry": schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistry(ref), + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistryApp": schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryApp(ref), + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistryList": schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryList(ref), + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistrySpec": schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistrySpec(ref), + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistryStatus": schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryStatus(ref), "kubedb.dev/apimachinery/apis/kafka/v1alpha1.connectClusterStatsService": schema_apimachinery_apis_kafka_v1alpha1_connectClusterStatsService(ref), } } @@ -23146,6 +23151,236 @@ func schema_apimachinery_apis_kafka_v1alpha1_ConnectorStatus(ref common.Referenc } } +func schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistry(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/kafka/v1alpha1.SchemaRegistrySpec"), + }, + }, + "status": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistryStatus"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistrySpec", "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistryStatus"}, + } +} + +func schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryApp(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "SchemaRegistry": { + SchemaProps: spec.SchemaProps{ + Ref: ref("kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistry"), + }, + }, + }, + Required: []string{"SchemaRegistry"}, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistry"}, + } +} + +func schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SchemaRegistryList contains a list of SchemaRegistry", + 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{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistry"), + }, + }, + }, + }, + }, + }, + Required: []string{"items"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "kubedb.dev/apimachinery/apis/kafka/v1alpha1.SchemaRegistry"}, + } +} + +func schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistrySpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SchemaRegistrySpec defines the desired state of SchemaRegistry", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "version": { + SchemaProps: spec.SchemaProps{ + Description: "Version of SchemaRegistry to be deployed.", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "replicas": { + SchemaProps: spec.SchemaProps{ + Description: "Number of instances to deploy for a schema registry.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "kafkaRef": { + SchemaProps: spec.SchemaProps{ + Description: "Kafka app-binding reference KafkaRef is an optional field, where SchemaRegistry will store its schema", + Ref: ref("kmodules.xyz/client-go/api/v1.ObjectReference"), + }, + }, + "podTemplate": { + SchemaProps: spec.SchemaProps{ + Description: "PodTemplate is an optional configuration for pods used to expose database", + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec"), + }, + }, + "serviceTemplates": { + SchemaProps: spec.SchemaProps{ + Description: "ServiceTemplates is an optional configuration for services used to expose database", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec"), + }, + }, + }, + }, + }, + "terminationPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "TerminationPolicy controls the delete operation for schema-registry cr", + Type: []string{"string"}, + Format: "", + }, + }, + "healthChecker": { + SchemaProps: spec.SchemaProps{ + Description: "HealthChecker defines attributes of the health checker", + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/client-go/api/v1.HealthCheckSpec"), + }, + }, + }, + Required: []string{"version"}, + }, + }, + Dependencies: []string{ + "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/client-go/api/v1.ObjectReference", "kmodules.xyz/offshoot-api/api/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec"}, + } +} + +func schema_apimachinery_apis_kafka_v1alpha1_SchemaRegistryStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SchemaRegistryStatus defines the observed state of SchemaRegistry", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "phase": { + SchemaProps: spec.SchemaProps{ + Description: "Specifies the current phase of the database", + Type: []string{"string"}, + Format: "", + }, + }, + "observedGeneration": { + SchemaProps: spec.SchemaProps{ + Description: "observedGeneration is the most recent generation observed for this resource. It corresponds to the resource's generation, which is updated on mutation by the API Server.", + Type: []string{"integer"}, + Format: "int64", + }, + }, + "conditions": { + SchemaProps: spec.SchemaProps{ + Description: "Conditions applied to the database, such as approval or denial.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kmodules.xyz/client-go/api/v1.Condition"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "kmodules.xyz/client-go/api/v1.Condition"}, + } +} + func schema_apimachinery_apis_kafka_v1alpha1_connectClusterStatsService(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/kafka/v1alpha1/register.go b/apis/kafka/v1alpha1/register.go index 59af5a13fd..ab368fa105 100644 --- a/apis/kafka/v1alpha1/register.go +++ b/apis/kafka/v1alpha1/register.go @@ -58,6 +58,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ConnectClusterList{}, &Connector{}, &ConnectorList{}, + &SchemaRegistry{}, + &SchemaRegistryList{}, ) scheme.AddKnownTypes(SchemeGroupVersion, diff --git a/apis/kafka/v1alpha1/schemaregistry_helpers.go b/apis/kafka/v1alpha1/schemaregistry_helpers.go new file mode 100644 index 0000000000..a6bbba86d4 --- /dev/null +++ b/apis/kafka/v1alpha1/schemaregistry_helpers.go @@ -0,0 +1,295 @@ +/* +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 ( + "context" + "fmt" + + "kubedb.dev/apimachinery/apis" + catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" + "kubedb.dev/apimachinery/apis/kafka" + api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + "kubedb.dev/apimachinery/crds" + + "gomodules.xyz/pointer" + core "k8s.io/api/core/v1" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/klog/v2" + "kmodules.xyz/client-go/apiextensions" + coreutil "kmodules.xyz/client-go/core/v1" + meta_util "kmodules.xyz/client-go/meta" + "kmodules.xyz/client-go/policy/secomp" + appcat "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1" + ofst "kmodules.xyz/offshoot-api/api/v1" + ofstv2 "kmodules.xyz/offshoot-api/api/v2" +) + +func (k *SchemaRegistry) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { + return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralSchemaRegistry)) +} + +func (k *SchemaRegistry) AsOwner() *meta.OwnerReference { + return meta.NewControllerRef(k, SchemeGroupVersion.WithKind(ResourceKindSchemaRegistry)) +} + +func (k *SchemaRegistry) ResourceShortCode() string { + return ResourceCodeSchemaRegistry +} + +func (k *SchemaRegistry) ResourceKind() string { + return ResourceKindSchemaRegistry +} + +func (k *SchemaRegistry) ResourceSingular() string { + return ResourceSingularSchemaRegistry +} + +func (k *SchemaRegistry) ResourcePlural() string { + return ResourcePluralSchemaRegistry +} + +func (k *SchemaRegistry) ResourceFQN() string { + return fmt.Sprintf("%s.%s", k.ResourcePlural(), kafka.GroupName) +} + +// Owner returns owner reference to resources +func (k *SchemaRegistry) Owner() *meta.OwnerReference { + return meta.NewControllerRef(k, SchemeGroupVersion.WithKind(k.ResourceKind())) +} + +func (k *SchemaRegistry) OffshootName() string { + return k.Name +} + +func (k *SchemaRegistry) ServiceName() string { + return k.OffshootName() +} + +func (k *SchemaRegistry) offshootLabels(selector, override map[string]string) map[string]string { + selector[meta_util.ComponentLabelKey] = ComponentKafka + return meta_util.FilterKeys(kafka.GroupName, selector, meta_util.OverwriteKeys(nil, k.Labels, override)) +} + +func (k *SchemaRegistry) OffshootSelectors(extraSelectors ...map[string]string) map[string]string { + selector := map[string]string{ + meta_util.NameLabelKey: k.ResourceFQN(), + meta_util.InstanceLabelKey: k.Name, + meta_util.ManagedByLabelKey: kafka.GroupName, + } + return meta_util.OverwriteKeys(selector, extraSelectors...) +} + +func (k *SchemaRegistry) OffshootLabels() map[string]string { + return k.offshootLabels(k.OffshootSelectors(), nil) +} + +// GetServiceTemplate returns a pointer to the desired serviceTemplate referred by "aliaS". Otherwise, it returns nil. +func (k *SchemaRegistry) GetServiceTemplate(templates []api.NamedServiceTemplateSpec, alias api.ServiceAlias) ofst.ServiceTemplateSpec { + for i := range templates { + c := templates[i] + if c.Alias == alias { + return c.ServiceTemplateSpec + } + } + return ofst.ServiceTemplateSpec{} +} + +func (k *SchemaRegistry) ServiceLabels(alias api.ServiceAlias, extraLabels ...map[string]string) map[string]string { + svcTemplate := k.GetServiceTemplate(k.Spec.ServiceTemplates, alias) + return k.offshootLabels(meta_util.OverwriteKeys(k.OffshootSelectors(), extraLabels...), svcTemplate.Labels) +} + +func (k *SchemaRegistry) PodControllerLabels(extraLabels ...map[string]string) map[string]string { + return k.offshootLabels(meta_util.OverwriteKeys(k.OffshootSelectors(), extraLabels...), k.Spec.PodTemplate.Controller.Labels) +} + +//type schemaRegistryStatsService struct { +// *SchemaRegistry +//} +// +//func (ks schemaRegistryStatsService) TLSConfig() *promapi.TLSConfig { +// return nil +//} +// +//func (ks schemaRegistryStatsService) GetNamespace() string { +// return ks.SchemaRegistry.GetNamespace() +//} +// +//func (ks schemaRegistryStatsService) ServiceName() string { +// return ks.OffshootName() + "-stats" +//} +// +//func (ks schemaRegistryStatsService) ServiceMonitorName() string { +// return ks.ServiceName() +//} +// +//func (ks schemaRegistryStatsService) ServiceMonitorAdditionalLabels() map[string]string { +// return ks.OffshootLabels() +//} +// +//func (ks schemaRegistryStatsService) Path() string { +// return DefaultStatsPath +//} +// +//func (ks schemaRegistryStatsService) Scheme() string { +// return "" +//} +// +//func (k *SchemaRegistry) StatsService() mona.StatsAccessor { +// return &schemaRegistryStatsService{k} +//} +// +//func (k *SchemaRegistry) StatsServiceLabels() map[string]string { +// return k.ServiceLabels(api.StatsServiceAlias, map[string]string{LabelRole: RoleStats}) +//} + +func (k *SchemaRegistry) PodLabels(extraLabels ...map[string]string) map[string]string { + return k.offshootLabels(meta_util.OverwriteKeys(k.OffshootSelectors(), extraLabels...), k.Spec.PodTemplate.Labels) +} + +func (k *SchemaRegistry) DeploymentName() string { + return k.OffshootName() +} + +func (k *SchemaRegistry) ConfigSecretName() string { + return meta_util.NameWithSuffix(k.OffshootName(), "config") +} + +func (k *SchemaRegistry) GetPersistentSecrets() []string { + var secrets []string + return secrets +} + +func (k *SchemaRegistry) KafkaClientCredentialsSecretName() string { + return meta_util.NameWithSuffix(k.Name, "kafka-client-cred") +} + +func (k *SchemaRegistry) SetHealthCheckerDefaults() { + if k.Spec.HealthChecker.PeriodSeconds == nil { + k.Spec.HealthChecker.PeriodSeconds = pointer.Int32P(10) + } + if k.Spec.HealthChecker.TimeoutSeconds == nil { + k.Spec.HealthChecker.TimeoutSeconds = pointer.Int32P(10) + } + if k.Spec.HealthChecker.FailureThreshold == nil { + k.Spec.HealthChecker.FailureThreshold = pointer.Int32P(3) + } +} + +func (k *SchemaRegistry) SetDefaults() { + if k.Spec.TerminationPolicy == "" { + k.Spec.TerminationPolicy = api.TerminationPolicyDelete + } + + if k.Spec.Replicas == nil { + k.Spec.Replicas = pointer.Int32P(1) + } + + var kfVersion catalog.KafkaVersion + err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: k.Spec.Version}, &kfVersion) + if err != nil { + klog.Errorf("can't get the kafka version object %s for %s \n", err.Error(), k.Spec.Version) + return + } + + k.setDefaultContainerSecurityContext(&kfVersion, &k.Spec.PodTemplate) + + dbContainer := coreutil.GetContainerByName(k.Spec.PodTemplate.Spec.Containers, SchemaRegistryContainerName) + if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { + apis.SetDefaultResourceLimits(&dbContainer.Resources, api.DefaultResources) + } + + k.SetHealthCheckerDefaults() + + k.SetDefaultEnvs() +} + +func (k *SchemaRegistry) SetDefaultEnvs() { + container := coreutil.GetContainerByName(k.Spec.PodTemplate.Spec.Containers, SchemaRegistryContainerName) + if container != nil { + } +} + +func (k *SchemaRegistry) setDefaultContainerSecurityContext(kfVersion *catalog.KafkaVersion, podTemplate *ofstv2.PodTemplateSpec) { + if podTemplate == nil { + return + } + if podTemplate.Spec.SecurityContext == nil { + podTemplate.Spec.SecurityContext = &core.PodSecurityContext{} + } + if podTemplate.Spec.SecurityContext.FSGroup == nil { + podTemplate.Spec.SecurityContext.FSGroup = kfVersion.Spec.SecurityContext.RunAsUser + } + + container := coreutil.GetContainerByName(podTemplate.Spec.Containers, SchemaRegistryContainerName) + if container == nil { + container = &core.Container{ + Name: SchemaRegistryContainerName, + } + } + if container.SecurityContext == nil { + container.SecurityContext = &core.SecurityContext{} + } + k.assignDefaultContainerSecurityContext(kfVersion, container.SecurityContext) + podTemplate.Spec.Containers = coreutil.UpsertContainer(podTemplate.Spec.Containers, *container) +} + +func (k *SchemaRegistry) assignDefaultContainerSecurityContext(kfVersion *catalog.KafkaVersion, sc *core.SecurityContext) { + if sc.AllowPrivilegeEscalation == nil { + sc.AllowPrivilegeEscalation = pointer.BoolP(false) + } + if sc.Capabilities == nil { + sc.Capabilities = &core.Capabilities{ + Drop: []core.Capability{"ALL"}, + } + } + if sc.RunAsNonRoot == nil { + sc.RunAsNonRoot = pointer.BoolP(true) + } + if sc.RunAsUser == nil { + sc.RunAsUser = kfVersion.Spec.SecurityContext.RunAsUser + } + if sc.RunAsGroup == nil { + sc.RunAsGroup = kfVersion.Spec.SecurityContext.RunAsUser + } + if sc.SeccompProfile == nil { + sc.SeccompProfile = secomp.DefaultSeccompProfile() + } +} + +type SchemaRegistryApp struct { + *SchemaRegistry +} + +func (r SchemaRegistryApp) Name() string { + return r.SchemaRegistry.Name +} + +func (r SchemaRegistryApp) Type() appcat.AppType { + return appcat.AppType(fmt.Sprintf("%s/%s", kafka.GroupName, ResourceSingularSchemaRegistry)) +} + +func (k *SchemaRegistry) AppBindingMeta() appcat.AppBindingMeta { + return &SchemaRegistryApp{k} +} + +func (k *SchemaRegistry) GetConnectionScheme() string { + scheme := "http" + return scheme +} diff --git a/apis/kafka/v1alpha1/schemaregistry_types.go b/apis/kafka/v1alpha1/schemaregistry_types.go new file mode 100644 index 0000000000..fe78c35bda --- /dev/null +++ b/apis/kafka/v1alpha1/schemaregistry_types.go @@ -0,0 +1,118 @@ +/* +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 ( + api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kmapi "kmodules.xyz/client-go/api/v1" + ofst "kmodules.xyz/offshoot-api/api/v2" +) + +const ( + ResourceCodeSchemaRegistry = "ksr" + ResourceKindSchemaRegistry = "SchemaRegistry" + ResourceSingularSchemaRegistry = "schemaregistry" + ResourcePluralSchemaRegistry = "schemaregistrys" +) + +// SchemaRegistry defines a runtime server system that stores a specific set of artifacts as files. + +// +genclient +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:shortName=kcc,scope=Namespaced +// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".apiVersion" +// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version" +// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +type SchemaRegistry struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SchemaRegistrySpec `json:"spec,omitempty"` + Status SchemaRegistryStatus `json:"status,omitempty"` +} + +// SchemaRegistrySpec defines the desired state of SchemaRegistry +type SchemaRegistrySpec struct { + // Version of SchemaRegistry to be deployed. + Version string `json:"version"` + + // Number of instances to deploy for a schema registry. + // +optional + Replicas *int32 `json:"replicas,omitempty"` + + // Kafka app-binding reference + // KafkaRef is an optional field, where SchemaRegistry will store its schema + KafkaRef *kmapi.ObjectReference `json:"kafkaRef,omitempty"` + + // PodTemplate is an optional configuration for pods used to expose database + // +optional + PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"` + + // ServiceTemplates is an optional configuration for services used to expose database + // +optional + ServiceTemplates []api.NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"` + + // TerminationPolicy controls the delete operation for schema-registry cr + // +optional + TerminationPolicy api.TerminationPolicy `json:"terminationPolicy,omitempty"` + + // HealthChecker defines attributes of the health checker + // +optional + // +kubebuilder:default={periodSeconds: 20, timeoutSeconds: 10, failureThreshold: 3} + HealthChecker kmapi.HealthCheckSpec `json:"healthChecker"` +} + +// SchemaRegistryStatus defines the observed state of SchemaRegistry +type SchemaRegistryStatus struct { + // Specifies the current phase of the database + // +optional + Phase SchemaRegistryPhase `json:"phase,omitempty"` + // observedGeneration is the most recent generation observed for this resource. It corresponds to the + // resource's generation, which is updated on mutation by the API Server. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // Conditions applied to the database, such as approval or denial. + // +optional + Conditions []kmapi.Condition `json:"conditions,omitempty"` +} + +// +kubebuilder:validation:Enum=Provisioning;Ready;NotReady;Critical;Unknown +type SchemaRegistryPhase string + +const ( + SchemaRegistryPhaseProvisioning SchemaRegistryPhase = "Provisioning" + SchemaRegistryPhaseReady SchemaRegistryPhase = "Ready" + SchemaRegistryPhaseNotReady SchemaRegistryPhase = "NotReady" + SchemaRegistryPhaseCritical SchemaRegistryPhase = "Critical" + SchemaRegistryPhaseUnknown SchemaRegistryPhase = "Unknown" +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SchemaRegistryList contains a list of SchemaRegistry +type SchemaRegistryList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SchemaRegistry `json:"items"` +} diff --git a/apis/kafka/v1alpha1/schemaregistry_webhook.go b/apis/kafka/v1alpha1/schemaregistry_webhook.go new file mode 100644 index 0000000000..aa3bf638a2 --- /dev/null +++ b/apis/kafka/v1alpha1/schemaregistry_webhook.go @@ -0,0 +1,199 @@ +/* +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 ( + "context" + + catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" + api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + + "github.com/pkg/errors" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/validation/field" + coreutil "kmodules.xyz/client-go/core/v1" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +// log is for logging in this package. +var schemaregistrylog = logf.Log.WithName("schemaregistry-resource") + +var _ webhook.Defaulter = &SchemaRegistry{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (k *SchemaRegistry) Default() { + if k == nil { + return + } + schemaregistrylog.Info("default", "name", k.Name) + k.SetDefaults() +} + +var _ webhook.Validator = &SchemaRegistry{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (k *SchemaRegistry) ValidateCreate() (admission.Warnings, error) { + schemaregistrylog.Info("validate create", "name", k.Name) + allErr := k.ValidateCreateOrUpdate() + if len(allErr) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "SchemaRegistry"}, k.Name, allErr) +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (k *SchemaRegistry) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { + schemaregistrylog.Info("validate update", "name", k.Name) + + oldRegistry := old.(*SchemaRegistry) + allErr := k.ValidateCreateOrUpdate() + + if *oldRegistry.Spec.Replicas == 1 && *k.Spec.Replicas > 1 { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"), + k.Name, + "Cannot scale up from 1 to more than 1 in standalone mode")) + } + + if len(allErr) == 0 { + return nil, nil + } + return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "SchemaRegistry"}, k.Name, allErr) +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (k *SchemaRegistry) ValidateDelete() (admission.Warnings, error) { + schemaregistrylog.Info("validate delete", "name", k.Name) + + var allErr field.ErrorList + if k.Spec.TerminationPolicy == api.TerminationPolicyDoNotTerminate { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), + k.Name, + "Can not delete as terminationPolicy is set to \"DoNotTerminate\"")) + return nil, apierrors.NewInvalid(schema.GroupKind{Group: "kafka.kubedb.com", Kind: "SchemaRegistry"}, k.Name, allErr) + } + return nil, nil +} + +func (k *SchemaRegistry) ValidateCreateOrUpdate() field.ErrorList { + var allErr field.ErrorList + + if k.Spec.TerminationPolicy == api.TerminationPolicyHalt { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("terminationPolicy"), + k.Name, + "TerminationPolicyHalt is not supported for SchemaRegistry")) + } + + // number of replicas can not be 0 or less + if k.Spec.Replicas != nil && *k.Spec.Replicas <= 0 { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"), + k.Name, + "number of replicas can not be 0 or less")) + } + + err := k.validateVersion() + if err != nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("version"), + k.Name, + err.Error())) + } + + err = k.validateVolumes() + if err != nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("volumes"), + k.Name, + err.Error())) + } + + err = k.validateContainerVolumeMountPaths() + if err != nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("containers").Child("volumeMounts"), + k.Name, + err.Error())) + } + + err = k.validateEnvVars() + if err != nil { + allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("containers").Child("envs"), + k.Name, + err.Error())) + } + + if len(allErr) == 0 { + return nil + } + return allErr +} + +func (k *SchemaRegistry) validateEnvVars() error { + return nil +} + +func (k *SchemaRegistry) validateVersion() error { + ksrVersion := &catalog.KafkaVersion{} + err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: k.Spec.Version}, ksrVersion) + if err != nil { + return errors.New("version not supported") + } + return nil +} + +var schemaRegistryReservedVolumes = []string{ + KafkaClientCertVolumeName, +} + +func (k *SchemaRegistry) validateVolumes() error { + if k.Spec.PodTemplate.Spec.Volumes == nil { + return nil + } + rsv := make([]string, len(schemaRegistryReservedVolumes)) + copy(rsv, schemaRegistryReservedVolumes) + volumes := k.Spec.PodTemplate.Spec.Volumes + for _, rv := range rsv { + for _, ugv := range volumes { + if ugv.Name == rv { + return errors.New("Cannot use a reserve volume name: " + rv) + } + } + } + return nil +} + +var schemaRegistryReservedVolumeMountPaths = []string{ + KafkaClientCertDir, +} + +func (k *SchemaRegistry) validateContainerVolumeMountPaths() error { + container := coreutil.GetContainerByName(k.Spec.PodTemplate.Spec.Containers, SchemaRegistryContainerName) + if container == nil { + return errors.New("container not found") + } + rPaths := schemaRegistryReservedVolumeMountPaths + volumeMountPaths := container.VolumeMounts + for _, rvm := range rPaths { + for _, ugv := range volumeMountPaths { + if ugv.MountPath == rvm { + return errors.New("Cannot use a reserve volume mount path: " + rvm) + } + } + } + return nil +} diff --git a/apis/kafka/v1alpha1/zz_generated.deepcopy.go b/apis/kafka/v1alpha1/zz_generated.deepcopy.go index 6cd5d7cc1c..a1f79fdbca 100644 --- a/apis/kafka/v1alpha1/zz_generated.deepcopy.go +++ b/apis/kafka/v1alpha1/zz_generated.deepcopy.go @@ -309,3 +309,143 @@ func (in *ConnectorStatus) DeepCopy() *ConnectorStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SchemaRegistry) DeepCopyInto(out *SchemaRegistry) { + *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 SchemaRegistry. +func (in *SchemaRegistry) DeepCopy() *SchemaRegistry { + if in == nil { + return nil + } + out := new(SchemaRegistry) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SchemaRegistry) 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 *SchemaRegistryApp) DeepCopyInto(out *SchemaRegistryApp) { + *out = *in + if in.SchemaRegistry != nil { + in, out := &in.SchemaRegistry, &out.SchemaRegistry + *out = new(SchemaRegistry) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryApp. +func (in *SchemaRegistryApp) DeepCopy() *SchemaRegistryApp { + if in == nil { + return nil + } + out := new(SchemaRegistryApp) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SchemaRegistryList) DeepCopyInto(out *SchemaRegistryList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SchemaRegistry, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryList. +func (in *SchemaRegistryList) DeepCopy() *SchemaRegistryList { + if in == nil { + return nil + } + out := new(SchemaRegistryList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SchemaRegistryList) 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 *SchemaRegistrySpec) DeepCopyInto(out *SchemaRegistrySpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + if in.KafkaRef != nil { + in, out := &in.KafkaRef, &out.KafkaRef + *out = new(v1.ObjectReference) + **out = **in + } + in.PodTemplate.DeepCopyInto(&out.PodTemplate) + if in.ServiceTemplates != nil { + in, out := &in.ServiceTemplates, &out.ServiceTemplates + *out = make([]v1alpha2.NamedServiceTemplateSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.HealthChecker.DeepCopyInto(&out.HealthChecker) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistrySpec. +func (in *SchemaRegistrySpec) DeepCopy() *SchemaRegistrySpec { + if in == nil { + return nil + } + out := new(SchemaRegistrySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SchemaRegistryStatus) DeepCopyInto(out *SchemaRegistryStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryStatus. +func (in *SchemaRegistryStatus) DeepCopy() *SchemaRegistryStatus { + if in == nil { + return nil + } + out := new(SchemaRegistryStatus) + in.DeepCopyInto(out) + return out +} diff --git a/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_kafka_client.go b/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_kafka_client.go index 6a0ae93010..5edb45a233 100644 --- a/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_kafka_client.go +++ b/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_kafka_client.go @@ -37,6 +37,10 @@ func (c *FakeKafkaV1alpha1) Connectors(namespace string) v1alpha1.ConnectorInter return &FakeConnectors{c, namespace} } +func (c *FakeKafkaV1alpha1) SchemaRegistries(namespace string) v1alpha1.SchemaRegistryInterface { + return &FakeSchemaRegistries{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeKafkaV1alpha1) RESTClient() rest.Interface { diff --git a/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_schemaregistry.go b/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_schemaregistry.go new file mode 100644 index 0000000000..7641089f19 --- /dev/null +++ b/client/clientset/versioned/typed/kafka/v1alpha1/fake/fake_schemaregistry.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/kafka/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" +) + +// FakeSchemaRegistries implements SchemaRegistryInterface +type FakeSchemaRegistries struct { + Fake *FakeKafkaV1alpha1 + ns string +} + +var schemaregistriesResource = v1alpha1.SchemeGroupVersion.WithResource("schemaregistries") + +var schemaregistriesKind = v1alpha1.SchemeGroupVersion.WithKind("SchemaRegistry") + +// Get takes name of the schemaRegistry, and returns the corresponding schemaRegistry object, and an error if there is any. +func (c *FakeSchemaRegistries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SchemaRegistry, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(schemaregistriesResource, c.ns, name), &v1alpha1.SchemaRegistry{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistry), err +} + +// List takes label and field selectors, and returns the list of SchemaRegistries that match those selectors. +func (c *FakeSchemaRegistries) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SchemaRegistryList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(schemaregistriesResource, schemaregistriesKind, c.ns, opts), &v1alpha1.SchemaRegistryList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SchemaRegistryList{ListMeta: obj.(*v1alpha1.SchemaRegistryList).ListMeta} + for _, item := range obj.(*v1alpha1.SchemaRegistryList).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 schemaRegistries. +func (c *FakeSchemaRegistries) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(schemaregistriesResource, c.ns, opts)) + +} + +// Create takes the representation of a schemaRegistry and creates it. Returns the server's representation of the schemaRegistry, and an error, if there is any. +func (c *FakeSchemaRegistries) Create(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.CreateOptions) (result *v1alpha1.SchemaRegistry, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(schemaregistriesResource, c.ns, schemaRegistry), &v1alpha1.SchemaRegistry{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistry), err +} + +// Update takes the representation of a schemaRegistry and updates it. Returns the server's representation of the schemaRegistry, and an error, if there is any. +func (c *FakeSchemaRegistries) Update(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (result *v1alpha1.SchemaRegistry, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(schemaregistriesResource, c.ns, schemaRegistry), &v1alpha1.SchemaRegistry{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistry), 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 *FakeSchemaRegistries) UpdateStatus(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (*v1alpha1.SchemaRegistry, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(schemaregistriesResource, "status", c.ns, schemaRegistry), &v1alpha1.SchemaRegistry{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistry), err +} + +// Delete takes name of the schemaRegistry and deletes it. Returns an error if one occurs. +func (c *FakeSchemaRegistries) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(schemaregistriesResource, c.ns, name, opts), &v1alpha1.SchemaRegistry{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSchemaRegistries) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(schemaregistriesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SchemaRegistryList{}) + return err +} + +// Patch applies the patch and returns the patched schemaRegistry. +func (c *FakeSchemaRegistries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SchemaRegistry, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(schemaregistriesResource, c.ns, name, pt, data, subresources...), &v1alpha1.SchemaRegistry{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistry), err +} diff --git a/client/clientset/versioned/typed/kafka/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/kafka/v1alpha1/generated_expansion.go index 4868973549..b8df56845c 100644 --- a/client/clientset/versioned/typed/kafka/v1alpha1/generated_expansion.go +++ b/client/clientset/versioned/typed/kafka/v1alpha1/generated_expansion.go @@ -21,3 +21,5 @@ package v1alpha1 type ConnectClusterExpansion interface{} type ConnectorExpansion interface{} + +type SchemaRegistryExpansion interface{} diff --git a/client/clientset/versioned/typed/kafka/v1alpha1/kafka_client.go b/client/clientset/versioned/typed/kafka/v1alpha1/kafka_client.go index e57b0527b8..d547431fa5 100644 --- a/client/clientset/versioned/typed/kafka/v1alpha1/kafka_client.go +++ b/client/clientset/versioned/typed/kafka/v1alpha1/kafka_client.go @@ -31,6 +31,7 @@ type KafkaV1alpha1Interface interface { RESTClient() rest.Interface ConnectClustersGetter ConnectorsGetter + SchemaRegistriesGetter } // KafkaV1alpha1Client is used to interact with features provided by the kafka.kubedb.com group. @@ -46,6 +47,10 @@ func (c *KafkaV1alpha1Client) Connectors(namespace string) ConnectorInterface { return newConnectors(c, namespace) } +func (c *KafkaV1alpha1Client) SchemaRegistries(namespace string) SchemaRegistryInterface { + return newSchemaRegistries(c, namespace) +} + // NewForConfig creates a new KafkaV1alpha1Client for the given config. // NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). diff --git a/client/clientset/versioned/typed/kafka/v1alpha1/schemaregistry.go b/client/clientset/versioned/typed/kafka/v1alpha1/schemaregistry.go new file mode 100644 index 0000000000..8840e40074 --- /dev/null +++ b/client/clientset/versioned/typed/kafka/v1alpha1/schemaregistry.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/kafka/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" +) + +// SchemaRegistriesGetter has a method to return a SchemaRegistryInterface. +// A group's client should implement this interface. +type SchemaRegistriesGetter interface { + SchemaRegistries(namespace string) SchemaRegistryInterface +} + +// SchemaRegistryInterface has methods to work with SchemaRegistry resources. +type SchemaRegistryInterface interface { + Create(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.CreateOptions) (*v1alpha1.SchemaRegistry, error) + Update(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (*v1alpha1.SchemaRegistry, error) + UpdateStatus(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (*v1alpha1.SchemaRegistry, 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.SchemaRegistry, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SchemaRegistryList, 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.SchemaRegistry, err error) + SchemaRegistryExpansion +} + +// schemaRegistries implements SchemaRegistryInterface +type schemaRegistries struct { + client rest.Interface + ns string +} + +// newSchemaRegistries returns a SchemaRegistries +func newSchemaRegistries(c *KafkaV1alpha1Client, namespace string) *schemaRegistries { + return &schemaRegistries{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the schemaRegistry, and returns the corresponding schemaRegistry object, and an error if there is any. +func (c *schemaRegistries) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SchemaRegistry, err error) { + result = &v1alpha1.SchemaRegistry{} + err = c.client.Get(). + Namespace(c.ns). + Resource("schemaregistries"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SchemaRegistries that match those selectors. +func (c *schemaRegistries) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SchemaRegistryList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SchemaRegistryList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("schemaregistries"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested schemaRegistries. +func (c *schemaRegistries) 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("schemaregistries"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a schemaRegistry and creates it. Returns the server's representation of the schemaRegistry, and an error, if there is any. +func (c *schemaRegistries) Create(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.CreateOptions) (result *v1alpha1.SchemaRegistry, err error) { + result = &v1alpha1.SchemaRegistry{} + err = c.client.Post(). + Namespace(c.ns). + Resource("schemaregistries"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(schemaRegistry). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a schemaRegistry and updates it. Returns the server's representation of the schemaRegistry, and an error, if there is any. +func (c *schemaRegistries) Update(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (result *v1alpha1.SchemaRegistry, err error) { + result = &v1alpha1.SchemaRegistry{} + err = c.client.Put(). + Namespace(c.ns). + Resource("schemaregistries"). + Name(schemaRegistry.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(schemaRegistry). + 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 *schemaRegistries) UpdateStatus(ctx context.Context, schemaRegistry *v1alpha1.SchemaRegistry, opts v1.UpdateOptions) (result *v1alpha1.SchemaRegistry, err error) { + result = &v1alpha1.SchemaRegistry{} + err = c.client.Put(). + Namespace(c.ns). + Resource("schemaregistries"). + Name(schemaRegistry.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(schemaRegistry). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the schemaRegistry and deletes it. Returns an error if one occurs. +func (c *schemaRegistries) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("schemaregistries"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *schemaRegistries) 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("schemaregistries"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched schemaRegistry. +func (c *schemaRegistries) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SchemaRegistry, err error) { + result = &v1alpha1.SchemaRegistry{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("schemaregistries"). + 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 43e99c8be7..035de59d2c 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -154,6 +154,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Kafka().V1alpha1().ConnectClusters().Informer()}, nil case kafkav1alpha1.SchemeGroupVersion.WithResource("connectors"): return &genericInformer{resource: resource.GroupResource(), informer: f.Kafka().V1alpha1().Connectors().Informer()}, nil + case kafkav1alpha1.SchemeGroupVersion.WithResource("schemaregistries"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Kafka().V1alpha1().SchemaRegistries().Informer()}, nil // Group=kubedb.com, Version=v1alpha2 case v1alpha2.SchemeGroupVersion.WithResource("druids"): diff --git a/client/informers/externalversions/kafka/v1alpha1/interface.go b/client/informers/externalversions/kafka/v1alpha1/interface.go index ee6e167581..41dfff85b2 100644 --- a/client/informers/externalversions/kafka/v1alpha1/interface.go +++ b/client/informers/externalversions/kafka/v1alpha1/interface.go @@ -28,6 +28,8 @@ type Interface interface { ConnectClusters() ConnectClusterInformer // Connectors returns a ConnectorInformer. Connectors() ConnectorInformer + // SchemaRegistries returns a SchemaRegistryInformer. + SchemaRegistries() SchemaRegistryInformer } type version struct { @@ -50,3 +52,8 @@ func (v *version) ConnectClusters() ConnectClusterInformer { func (v *version) Connectors() ConnectorInformer { return &connectorInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } + +// SchemaRegistries returns a SchemaRegistryInformer. +func (v *version) SchemaRegistries() SchemaRegistryInformer { + return &schemaRegistryInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/client/informers/externalversions/kafka/v1alpha1/schemaregistry.go b/client/informers/externalversions/kafka/v1alpha1/schemaregistry.go new file mode 100644 index 0000000000..304e882c26 --- /dev/null +++ b/client/informers/externalversions/kafka/v1alpha1/schemaregistry.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" + + kafkav1alpha1 "kubedb.dev/apimachinery/apis/kafka/v1alpha1" + versioned "kubedb.dev/apimachinery/client/clientset/versioned" + internalinterfaces "kubedb.dev/apimachinery/client/informers/externalversions/internalinterfaces" + v1alpha1 "kubedb.dev/apimachinery/client/listers/kafka/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" +) + +// SchemaRegistryInformer provides access to a shared informer and lister for +// SchemaRegistries. +type SchemaRegistryInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.SchemaRegistryLister +} + +type schemaRegistryInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSchemaRegistryInformer constructs a new informer for SchemaRegistry 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 NewSchemaRegistryInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSchemaRegistryInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSchemaRegistryInformer constructs a new informer for SchemaRegistry 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 NewFilteredSchemaRegistryInformer(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.KafkaV1alpha1().SchemaRegistries(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KafkaV1alpha1().SchemaRegistries(namespace).Watch(context.TODO(), options) + }, + }, + &kafkav1alpha1.SchemaRegistry{}, + resyncPeriod, + indexers, + ) +} + +func (f *schemaRegistryInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSchemaRegistryInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *schemaRegistryInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&kafkav1alpha1.SchemaRegistry{}, f.defaultInformer) +} + +func (f *schemaRegistryInformer) Lister() v1alpha1.SchemaRegistryLister { + return v1alpha1.NewSchemaRegistryLister(f.Informer().GetIndexer()) +} diff --git a/client/listers/kafka/v1alpha1/expansion_generated.go b/client/listers/kafka/v1alpha1/expansion_generated.go index e5654ca6ea..85c4ca58a4 100644 --- a/client/listers/kafka/v1alpha1/expansion_generated.go +++ b/client/listers/kafka/v1alpha1/expansion_generated.go @@ -33,3 +33,11 @@ type ConnectorListerExpansion interface{} // ConnectorNamespaceListerExpansion allows custom methods to be added to // ConnectorNamespaceLister. type ConnectorNamespaceListerExpansion interface{} + +// SchemaRegistryListerExpansion allows custom methods to be added to +// SchemaRegistryLister. +type SchemaRegistryListerExpansion interface{} + +// SchemaRegistryNamespaceListerExpansion allows custom methods to be added to +// SchemaRegistryNamespaceLister. +type SchemaRegistryNamespaceListerExpansion interface{} diff --git a/client/listers/kafka/v1alpha1/schemaregistry.go b/client/listers/kafka/v1alpha1/schemaregistry.go new file mode 100644 index 0000000000..68b9232fe6 --- /dev/null +++ b/client/listers/kafka/v1alpha1/schemaregistry.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/kafka/v1alpha1" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SchemaRegistryLister helps list SchemaRegistries. +// All objects returned here must be treated as read-only. +type SchemaRegistryLister interface { + // List lists all SchemaRegistries in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistry, err error) + // SchemaRegistries returns an object that can list and get SchemaRegistries. + SchemaRegistries(namespace string) SchemaRegistryNamespaceLister + SchemaRegistryListerExpansion +} + +// schemaRegistryLister implements the SchemaRegistryLister interface. +type schemaRegistryLister struct { + indexer cache.Indexer +} + +// NewSchemaRegistryLister returns a new SchemaRegistryLister. +func NewSchemaRegistryLister(indexer cache.Indexer) SchemaRegistryLister { + return &schemaRegistryLister{indexer: indexer} +} + +// List lists all SchemaRegistries in the indexer. +func (s *schemaRegistryLister) List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistry, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SchemaRegistry)) + }) + return ret, err +} + +// SchemaRegistries returns an object that can list and get SchemaRegistries. +func (s *schemaRegistryLister) SchemaRegistries(namespace string) SchemaRegistryNamespaceLister { + return schemaRegistryNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SchemaRegistryNamespaceLister helps list and get SchemaRegistries. +// All objects returned here must be treated as read-only. +type SchemaRegistryNamespaceLister interface { + // List lists all SchemaRegistries in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistry, err error) + // Get retrieves the SchemaRegistry from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.SchemaRegistry, error) + SchemaRegistryNamespaceListerExpansion +} + +// schemaRegistryNamespaceLister implements the SchemaRegistryNamespaceLister +// interface. +type schemaRegistryNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all SchemaRegistries in the indexer for a given namespace. +func (s schemaRegistryNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistry, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SchemaRegistry)) + }) + return ret, err +} + +// Get retrieves the SchemaRegistry from the indexer for a given namespace and name. +func (s schemaRegistryNamespaceLister) Get(name string) (*v1alpha1.SchemaRegistry, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("schemaregistry"), name) + } + return obj.(*v1alpha1.SchemaRegistry), nil +} diff --git a/crds/kafka.kubedb.com_schemaregistries.yaml b/crds/kafka.kubedb.com_schemaregistries.yaml new file mode 100644 index 0000000000..2b2e1fe6c6 --- /dev/null +++ b/crds/kafka.kubedb.com_schemaregistries.yaml @@ -0,0 +1,3094 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: kubedb + name: schemaregistries.kafka.kubedb.com +spec: + group: kafka.kubedb.com + names: + kind: SchemaRegistry + listKind: SchemaRegistryList + plural: schemaregistries + shortNames: + - kcc + singular: schemaregistry + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .apiVersion + name: Type + type: string + - jsonPath: .spec.version + name: Version + 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: + healthChecker: + default: + failureThreshold: 3 + periodSeconds: 20 + timeoutSeconds: 10 + properties: + disableWriteCheck: + type: boolean + failureThreshold: + default: 1 + format: int32 + type: integer + periodSeconds: + default: 10 + format: int32 + type: integer + timeoutSeconds: + default: 10 + format: int32 + type: integer + type: object + kafkaRef: + properties: + name: + type: string + namespace: + type: string + required: + - name + type: object + podTemplate: + properties: + controller: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + activeDeadlineSeconds: + format: int64 + type: integer + automountServiceAccountToken: + type: boolean + containers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic + 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 + restartPolicy: + type: string + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + dnsConfig: + properties: + nameservers: + items: + type: string + type: array + options: + items: + properties: + name: + type: string + value: + type: string + type: object + type: array + searches: + items: + type: string + type: array + type: object + dnsPolicy: + type: string + enableServiceLinks: + type: boolean + ephemeralContainers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic + 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 + restartPolicy: + type: string + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + targetContainerName: + type: string + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + hostAliases: + items: + properties: + hostnames: + items: + type: string + type: array + ip: + type: string + type: object + type: array + hostIPC: + type: boolean + hostNetwork: + type: boolean + hostPID: + type: boolean + hostUsers: + type: boolean + imagePullSecrets: + items: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + type: array + initContainers: + items: + properties: + args: + items: + type: string + type: array + command: + items: + type: string + type: array + env: + items: + properties: + name: + type: string + value: + type: string + valueFrom: + properties: + configMapKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + resourceFieldRef: + properties: + containerName: + type: string + divisor: + 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + secretKeyRef: + properties: + key: + type: string + name: + type: string + optional: + type: boolean + required: + - key + type: object + x-kubernetes-map-type: atomic + type: object + required: + - name + type: object + type: array + envFrom: + items: + properties: + configMapRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + prefix: + type: string + secretRef: + properties: + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + type: object + type: array + image: + type: string + imagePullPolicy: + type: string + lifecycle: + properties: + postStart: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + preStop: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + sleep: + properties: + seconds: + format: int64 + type: integer + required: + - seconds + type: object + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + type: object + type: object + livenessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + name: + type: string + ports: + items: + properties: + containerPort: + format: int32 + type: integer + hostIP: + type: string + hostPort: + format: int32 + type: integer + name: + type: string + protocol: + default: TCP + type: string + required: + - containerPort + type: object + type: array + x-kubernetes-list-map-keys: + - containerPort + - protocol + x-kubernetes-list-type: map + readinessProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + resizePolicy: + items: + properties: + resourceName: + type: string + restartPolicy: + type: string + required: + - resourceName + - restartPolicy + type: object + type: array + x-kubernetes-list-type: atomic + 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 + restartPolicy: + type: string + securityContext: + properties: + allowPrivilegeEscalation: + type: boolean + capabilities: + properties: + add: + items: + type: string + type: array + drop: + items: + type: string + type: array + type: object + privileged: + type: boolean + procMount: + type: string + readOnlyRootFilesystem: + type: boolean + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + startupProbe: + properties: + exec: + properties: + command: + items: + type: string + type: array + type: object + failureThreshold: + format: int32 + type: integer + grpc: + properties: + port: + format: int32 + type: integer + service: + type: string + required: + - port + type: object + httpGet: + properties: + host: + type: string + httpHeaders: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + path: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + scheme: + type: string + required: + - port + type: object + initialDelaySeconds: + format: int32 + type: integer + periodSeconds: + format: int32 + type: integer + successThreshold: + format: int32 + type: integer + tcpSocket: + properties: + host: + type: string + port: + anyOf: + - type: integer + - type: string + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + format: int64 + type: integer + timeoutSeconds: + format: int32 + type: integer + type: object + stdin: + type: boolean + stdinOnce: + type: boolean + terminationMessagePath: + type: string + terminationMessagePolicy: + type: string + tty: + type: boolean + volumeDevices: + items: + properties: + devicePath: + type: string + name: + type: string + required: + - devicePath + - name + type: object + type: array + volumeMounts: + items: + properties: + mountPath: + type: string + mountPropagation: + type: string + name: + type: string + readOnly: + type: boolean + subPath: + type: string + subPathExpr: + type: string + required: + - mountPath + - name + type: object + type: array + workingDir: + type: string + required: + - name + type: object + type: array + nodeName: + type: string + nodeSelector: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: atomic + os: + properties: + name: + type: string + required: + - name + type: object + overhead: + 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 + preemptionPolicy: + type: string + priority: + format: int32 + type: integer + priorityClassName: + type: string + readinessGates: + items: + properties: + conditionType: + type: string + required: + - conditionType + type: object + type: array + restartPolicy: + type: string + runtimeClassName: + type: string + schedulerName: + type: string + securityContext: + properties: + fsGroup: + format: int64 + type: integer + fsGroupChangePolicy: + type: string + runAsGroup: + format: int64 + type: integer + runAsNonRoot: + type: boolean + runAsUser: + format: int64 + type: integer + seLinuxOptions: + properties: + level: + type: string + role: + type: string + type: + type: string + user: + type: string + type: object + seccompProfile: + properties: + localhostProfile: + type: string + type: + type: string + required: + - type + type: object + supplementalGroups: + items: + format: int64 + type: integer + type: array + sysctls: + items: + properties: + name: + type: string + value: + type: string + required: + - name + - value + type: object + type: array + windowsOptions: + properties: + gmsaCredentialSpec: + type: string + gmsaCredentialSpecName: + type: string + hostProcess: + type: boolean + runAsUserName: + type: string + type: object + type: object + serviceAccountName: + type: string + setHostnameAsFQDN: + type: boolean + shareProcessNamespace: + type: boolean + terminationGracePeriodSeconds: + format: int64 + type: integer + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + volumes: + items: + properties: + awsElasticBlockStore: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + azureDisk: + properties: + cachingMode: + type: string + diskName: + type: string + diskURI: + type: string + fsType: + type: string + kind: + type: string + readOnly: + type: boolean + required: + - diskName + - diskURI + type: object + azureFile: + properties: + readOnly: + type: boolean + secretName: + type: string + shareName: + type: string + required: + - secretName + - shareName + type: object + cephfs: + properties: + monitors: + items: + type: string + type: array + path: + type: string + readOnly: + type: boolean + secretFile: + type: string + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - monitors + type: object + cinder: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeID: + type: string + required: + - volumeID + type: object + configMap: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + csi: + properties: + driver: + type: string + fsType: + type: string + nodePublishSecretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + readOnly: + type: boolean + volumeAttributes: + additionalProperties: + type: string + type: object + required: + - driver + type: object + downwardAPI: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + emptyDir: + properties: + medium: + type: string + sizeLimit: + 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 + ephemeral: + properties: + volumeClaimTemplate: + properties: + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + generateName: + type: string + labels: + additionalProperties: + type: string + type: object + name: + type: string + namespace: + type: string + ownerReferences: + items: + properties: + apiVersion: + type: string + blockOwnerDeletion: + type: boolean + controller: + type: boolean + kind: + type: string + name: + type: string + uid: + type: string + required: + - apiVersion + - kind + - name + - uid + type: object + x-kubernetes-map-type: atomic + type: array + type: object + spec: + properties: + accessModes: + items: + type: string + type: array + dataSource: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + resources: + properties: + 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 + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + type: string + volumeAttributesClassName: + type: string + volumeMode: + type: string + volumeName: + type: string + type: object + required: + - spec + type: object + type: object + fc: + properties: + fsType: + type: string + lun: + format: int32 + type: integer + readOnly: + type: boolean + targetWWNs: + items: + type: string + type: array + wwids: + items: + type: string + type: array + type: object + flexVolume: + properties: + driver: + type: string + fsType: + type: string + options: + additionalProperties: + type: string + type: object + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + required: + - driver + type: object + flocker: + properties: + datasetName: + type: string + datasetUUID: + type: string + type: object + gcePersistentDisk: + properties: + fsType: + type: string + partition: + format: int32 + type: integer + pdName: + type: string + readOnly: + type: boolean + required: + - pdName + type: object + glusterfs: + properties: + endpoints: + type: string + path: + type: string + readOnly: + type: boolean + required: + - endpoints + - path + type: object + hostPath: + properties: + path: + type: string + type: + type: string + required: + - path + type: object + iscsi: + properties: + chapAuthDiscovery: + type: boolean + chapAuthSession: + type: boolean + fsType: + type: string + initiatorName: + type: string + iqn: + type: string + iscsiInterface: + type: string + lun: + format: int32 + type: integer + portals: + items: + type: string + type: array + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + targetPortal: + type: string + required: + - iqn + - lun + - targetPortal + type: object + name: + type: string + nfs: + properties: + path: + type: string + readOnly: + type: boolean + server: + type: string + required: + - path + - server + type: object + persistentVolumeClaim: + properties: + claimName: + type: string + readOnly: + type: boolean + required: + - claimName + type: object + photonPersistentDisk: + properties: + fsType: + type: string + pdID: + type: string + required: + - pdID + type: object + portworxVolume: + properties: + fsType: + type: string + readOnly: + type: boolean + volumeID: + type: string + required: + - volumeID + type: object + projected: + properties: + defaultMode: + format: int32 + type: integer + sources: + items: + properties: + clusterTrustBundle: + properties: + labelSelector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + name: + type: string + optional: + type: boolean + path: + type: string + signerName: + type: string + required: + - path + type: object + configMap: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + downwardAPI: + properties: + items: + items: + properties: + fieldRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + required: + - fieldPath + type: object + x-kubernetes-map-type: atomic + mode: + format: int32 + type: integer + path: + type: string + resourceFieldRef: + properties: + containerName: + type: string + divisor: + 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 + resource: + type: string + required: + - resource + type: object + x-kubernetes-map-type: atomic + required: + - path + type: object + type: array + type: object + secret: + properties: + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + name: + type: string + optional: + type: boolean + type: object + x-kubernetes-map-type: atomic + serviceAccountToken: + properties: + audience: + type: string + expirationSeconds: + format: int64 + type: integer + path: + type: string + required: + - path + type: object + type: object + type: array + type: object + quobyte: + properties: + group: + type: string + readOnly: + type: boolean + registry: + type: string + tenant: + type: string + user: + type: string + volume: + type: string + required: + - registry + - volume + type: object + rbd: + properties: + fsType: + type: string + image: + type: string + keyring: + type: string + monitors: + items: + type: string + type: array + pool: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + user: + type: string + required: + - image + - monitors + type: object + scaleIO: + properties: + fsType: + type: string + gateway: + type: string + protectionDomain: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + sslEnabled: + type: boolean + storageMode: + type: string + storagePool: + type: string + system: + type: string + volumeName: + type: string + required: + - gateway + - secretRef + - system + type: object + secret: + properties: + defaultMode: + format: int32 + type: integer + items: + items: + properties: + key: + type: string + mode: + format: int32 + type: integer + path: + type: string + required: + - key + - path + type: object + type: array + optional: + type: boolean + secretName: + type: string + type: object + storageos: + properties: + fsType: + type: string + readOnly: + type: boolean + secretRef: + properties: + name: + type: string + type: object + x-kubernetes-map-type: atomic + volumeName: + type: string + volumeNamespace: + type: string + type: object + vsphereVolume: + properties: + fsType: + type: string + storagePolicyID: + type: string + storagePolicyName: + type: string + volumePath: + type: string + required: + - volumePath + type: object + required: + - name + type: object + type: array + type: object + type: object + replicas: + format: int32 + type: integer + serviceTemplates: + items: + properties: + alias: + enum: + - primary + - standby + - stats + type: string + metadata: + properties: + annotations: + additionalProperties: + type: string + type: object + labels: + additionalProperties: + type: string + type: object + type: object + spec: + properties: + clusterIP: + type: string + externalIPs: + items: + type: string + type: array + externalTrafficPolicy: + type: string + healthCheckNodePort: + format: int32 + type: integer + loadBalancerIP: + type: string + loadBalancerSourceRanges: + items: + type: string + type: array + ports: + items: + properties: + name: + type: string + nodePort: + format: int32 + type: integer + port: + format: int32 + type: integer + required: + - port + type: object + type: array + sessionAffinityConfig: + properties: + clientIP: + properties: + timeoutSeconds: + format: int32 + type: integer + type: object + type: object + type: + type: string + type: object + required: + - alias + type: object + type: array + terminationPolicy: + enum: + - Halt + - Delete + - WipeOut + - DoNotTerminate + type: string + version: + type: string + required: + - version + 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 + phase: + enum: + - Provisioning + - Ready + - NotReady + - Critical + - Unknown + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/vendor/k8s.io/client-go/discovery/fake/discovery.go b/vendor/k8s.io/client-go/discovery/fake/discovery.go deleted file mode 100644 index f8a78e1ef4..0000000000 --- a/vendor/k8s.io/client-go/discovery/fake/discovery.go +++ /dev/null @@ -1,174 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -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 fake - -import ( - "fmt" - "net/http" - - openapi_v2 "github.com/google/gnostic-models/openapiv2" - - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/version" - "k8s.io/client-go/discovery" - "k8s.io/client-go/openapi" - kubeversion "k8s.io/client-go/pkg/version" - restclient "k8s.io/client-go/rest" - "k8s.io/client-go/testing" -) - -// FakeDiscovery implements discovery.DiscoveryInterface and sometimes calls testing.Fake.Invoke with an action, -// but doesn't respect the return value if any. There is a way to fake static values like ServerVersion by using the Faked... fields on the struct. -type FakeDiscovery struct { - *testing.Fake - FakedServerVersion *version.Info -} - -// ServerResourcesForGroupVersion returns the supported resources for a group -// and version. -func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - c.Invokes(action, nil) - for _, resourceList := range c.Resources { - if resourceList.GroupVersion == groupVersion { - return resourceList, nil - } - } - return nil, &errors.StatusError{ - ErrStatus: metav1.Status{ - Status: metav1.StatusFailure, - Code: http.StatusNotFound, - Reason: metav1.StatusReasonNotFound, - Message: fmt.Sprintf("the server could not find the requested resource, GroupVersion %q not found", groupVersion), - }} -} - -// ServerGroupsAndResources returns the supported groups and resources for all groups and versions. -func (c *FakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { - sgs, err := c.ServerGroups() - if err != nil { - return nil, nil, err - } - resultGroups := []*metav1.APIGroup{} - for i := range sgs.Groups { - resultGroups = append(resultGroups, &sgs.Groups[i]) - } - - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - c.Invokes(action, nil) - return resultGroups, c.Resources, nil -} - -// ServerPreferredResources returns the supported resources with the version -// preferred by the server. -func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerPreferredNamespacedResources returns the supported namespaced resources -// with the version preferred by the server. -func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerGroups returns the supported groups, with information like supported -// versions and the preferred version. -func (c *FakeDiscovery) ServerGroups() (*metav1.APIGroupList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "group"}, - } - c.Invokes(action, nil) - - groups := map[string]*metav1.APIGroup{} - - for _, res := range c.Resources { - gv, err := schema.ParseGroupVersion(res.GroupVersion) - if err != nil { - return nil, err - } - group := groups[gv.Group] - if group == nil { - group = &metav1.APIGroup{ - Name: gv.Group, - PreferredVersion: metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }, - } - groups[gv.Group] = group - } - - group.Versions = append(group.Versions, metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }) - } - - list := &metav1.APIGroupList{} - for _, apiGroup := range groups { - list.Groups = append(list.Groups, *apiGroup) - } - - return list, nil - -} - -// ServerVersion retrieves and parses the server's version. -func (c *FakeDiscovery) ServerVersion() (*version.Info, error) { - action := testing.ActionImpl{} - action.Verb = "get" - action.Resource = schema.GroupVersionResource{Resource: "version"} - _, err := c.Invokes(action, nil) - if err != nil { - return nil, err - } - - if c.FakedServerVersion != nil { - return c.FakedServerVersion, nil - } - - versionInfo := kubeversion.Get() - return &versionInfo, nil -} - -// OpenAPISchema retrieves and parses the swagger API schema the server supports. -func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) { - return &openapi_v2.Document{}, nil -} - -func (c *FakeDiscovery) OpenAPIV3() openapi.Client { - panic("unimplemented") -} - -// RESTClient returns a RESTClient that is used to communicate with API server -// by this client implementation. -func (c *FakeDiscovery) RESTClient() restclient.Interface { - return nil -} - -func (c *FakeDiscovery) WithLegacy() discovery.DiscoveryInterface { - panic("unimplemented") -} diff --git a/vendor/modules.txt b/vendor/modules.txt index a0746a88a9..f92637533c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1283,7 +1283,6 @@ k8s.io/client-go/applyconfigurations/storage/v1alpha1 k8s.io/client-go/applyconfigurations/storage/v1beta1 k8s.io/client-go/discovery k8s.io/client-go/discovery/cached/memory -k8s.io/client-go/discovery/fake k8s.io/client-go/dynamic k8s.io/client-go/dynamic/dynamicinformer k8s.io/client-go/dynamic/dynamiclister From 1a80cbff3227869e7d45d7599bb6260e56471bf4 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Fri, 17 May 2024 19:05:44 +0600 Subject: [PATCH 2/7] Add some constants Signed-off-by: obaydullahmhs --- apis/kafka/v1alpha1/constants.go | 13 ++++++++++++- apis/kafka/v1alpha1/schemaregistry_helpers.go | 6 +++++- apis/kafka/v1alpha1/schemaregistry_types.go | 4 ++-- apis/kubedb/v1alpha2/constants.go | 3 +++ crds/kafka.kubedb.com_schemaregistries.yaml | 2 +- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/apis/kafka/v1alpha1/constants.go b/apis/kafka/v1alpha1/constants.go index 65156190c2..24b212763f 100644 --- a/apis/kafka/v1alpha1/constants.go +++ b/apis/kafka/v1alpha1/constants.go @@ -98,5 +98,16 @@ const ( // SchemaRegistry constants const ( - SchemaRegistryContainerName = "schema-registry" + SchemaRegistryPrimaryPortName = "primary" + SchemaRegistryPortName = "registry" + ApicurioRegistryRESTPort = 8080 + SchemaRegistryContainerName = "schema-registry" + SchemaRegistryConfigFileName = "application.properties" + + SchemaRegistryStorageBackendTypeMemory = "mem" + SchemaRegistryStorageBackendTypeKafka = "kafkasql" + SchemaRegistryStorageBackendTypeSQL = "sql" + + SchemaRegistryOperatorVolumeConfig = "registry-operator-config" + SchemaRegistryOperatorConfigPath = "/deployments/config" ) diff --git a/apis/kafka/v1alpha1/schemaregistry_helpers.go b/apis/kafka/v1alpha1/schemaregistry_helpers.go index a6bbba86d4..55f0a695f5 100644 --- a/apis/kafka/v1alpha1/schemaregistry_helpers.go +++ b/apis/kafka/v1alpha1/schemaregistry_helpers.go @@ -77,6 +77,10 @@ func (k *SchemaRegistry) OffshootName() string { return k.Name } +func (k *SchemaRegistry) GoverningServiceName() string { + return meta_util.NameWithSuffix(k.ServiceName(), "pods") +} + func (k *SchemaRegistry) ServiceName() string { return k.OffshootName() } @@ -163,7 +167,7 @@ func (k *SchemaRegistry) PodLabels(extraLabels ...map[string]string) map[string] return k.offshootLabels(meta_util.OverwriteKeys(k.OffshootSelectors(), extraLabels...), k.Spec.PodTemplate.Labels) } -func (k *SchemaRegistry) DeploymentName() string { +func (k *SchemaRegistry) StatefulSetName() string { return k.OffshootName() } diff --git a/apis/kafka/v1alpha1/schemaregistry_types.go b/apis/kafka/v1alpha1/schemaregistry_types.go index fe78c35bda..fc7a582caa 100644 --- a/apis/kafka/v1alpha1/schemaregistry_types.go +++ b/apis/kafka/v1alpha1/schemaregistry_types.go @@ -28,7 +28,7 @@ const ( ResourceCodeSchemaRegistry = "ksr" ResourceKindSchemaRegistry = "SchemaRegistry" ResourceSingularSchemaRegistry = "schemaregistry" - ResourcePluralSchemaRegistry = "schemaregistrys" + ResourcePluralSchemaRegistry = "schemaregistries" ) // SchemaRegistry defines a runtime server system that stores a specific set of artifacts as files. @@ -39,7 +39,7 @@ const ( // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=kcc,scope=Namespaced +// +kubebuilder:resource:shortName=ksr,scope=Namespaced // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".apiVersion" // +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version" // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase" diff --git a/apis/kubedb/v1alpha2/constants.go b/apis/kubedb/v1alpha2/constants.go index defcd5071b..7cc0ad03ec 100644 --- a/apis/kubedb/v1alpha2/constants.go +++ b/apis/kubedb/v1alpha2/constants.go @@ -774,6 +774,9 @@ const ( KafkaKeystorePassword = "ssl.keystore.password" KafkaTruststorePassword = "ssl.truststore.password" KafkaKeyPassword = "ssl.key.password" + KafkaTruststoreType = "ssl.truststore.type" + KafkaKeystoreType = "ssl.keystore.type" + KafkaTruststoreTypeJKS = "JKS" KafkaKeystoreDefaultPass = "changeit" KafkaMetricReporters = "metric.reporters" diff --git a/crds/kafka.kubedb.com_schemaregistries.yaml b/crds/kafka.kubedb.com_schemaregistries.yaml index 2b2e1fe6c6..ba51257fbd 100644 --- a/crds/kafka.kubedb.com_schemaregistries.yaml +++ b/crds/kafka.kubedb.com_schemaregistries.yaml @@ -12,7 +12,7 @@ spec: listKind: SchemaRegistryList plural: schemaregistries shortNames: - - kcc + - ksr singular: schemaregistry scope: Namespaced versions: From 880c3f11b7ce4cfed44c30bced5ad6c2e9b3520c Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Tue, 21 May 2024 15:49:57 +0600 Subject: [PATCH 3/7] Add schema registry version Signed-off-by: obaydullahmhs --- apis/catalog/v1alpha1/openapi_generated.go | 231 ++++++++++++++++++ .../schemaregistry_version_helpers.go | 64 +++++ .../v1alpha1/schemaregistry_version_types.go | 103 ++++++++ .../catalog/v1alpha1/zz_generated.deepcopy.go | 129 ++++++++++ .../typed/catalog/v1alpha1/catalog_client.go | 5 + .../v1alpha1/fake/fake_catalog_client.go | 4 + .../fake/fake_schemaregistryversion.go | 122 +++++++++ .../catalog/v1alpha1/generated_expansion.go | 2 + .../catalog/v1alpha1/schemaregistryversion.go | 169 +++++++++++++ .../catalog/v1alpha1/interface.go | 7 + .../catalog/v1alpha1/schemaregistryversion.go | 90 +++++++ client/informers/externalversions/generic.go | 2 + .../catalog/v1alpha1/expansion_generated.go | 4 + .../catalog/v1alpha1/schemaregistryversion.go | 69 ++++++ ...log.kubedb.com_schemaregistryversions.yaml | 106 ++++++++ pkg/openapi/lib.go | 2 + 16 files changed, 1109 insertions(+) create mode 100644 apis/catalog/v1alpha1/schemaregistry_version_helpers.go create mode 100644 apis/catalog/v1alpha1/schemaregistry_version_types.go create mode 100644 client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_schemaregistryversion.go create mode 100644 client/clientset/versioned/typed/catalog/v1alpha1/schemaregistryversion.go create mode 100644 client/informers/externalversions/catalog/v1alpha1/schemaregistryversion.go create mode 100644 client/listers/catalog/v1alpha1/schemaregistryversion.go create mode 100644 crds/catalog.kubedb.com_schemaregistryversions.yaml diff --git a/apis/catalog/v1alpha1/openapi_generated.go b/apis/catalog/v1alpha1/openapi_generated.go index 6c1ff4ba23..08f25bbce2 100644 --- a/apis/catalog/v1alpha1/openapi_generated.go +++ b/apis/catalog/v1alpha1/openapi_generated.go @@ -458,6 +458,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kmodules.xyz/offshoot-api/api/v1.VolumeSource": schema_kmodulesxyz_offshoot_api_api_v1_VolumeSource(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.AddonSpec": schema_apimachinery_apis_catalog_v1alpha1_AddonSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.AddonTasks": schema_apimachinery_apis_catalog_v1alpha1_AddonTasks(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory": schema_apimachinery_apis_catalog_v1alpha1_ApicurioInMemory(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL": schema_apimachinery_apis_catalog_v1alpha1_ApicurioSQL(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ArchiverSpec": schema_apimachinery_apis_catalog_v1alpha1_ArchiverSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ConnectClusterVersion": schema_apimachinery_apis_catalog_v1alpha1_ConnectClusterVersion(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ConnectorPlugin": schema_apimachinery_apis_catalog_v1alpha1_ConnectorPlugin(ref), @@ -588,7 +590,11 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RedisVersionList": schema_apimachinery_apis_catalog_v1alpha1_RedisVersionList(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RedisVersionPodSecurityPolicy": schema_apimachinery_apis_catalog_v1alpha1_RedisVersionPodSecurityPolicy(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RedisVersionSpec": schema_apimachinery_apis_catalog_v1alpha1_RedisVersionSpec(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RegistryImage": schema_apimachinery_apis_catalog_v1alpha1_RegistryImage(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ReplicationModeDetector": schema_apimachinery_apis_catalog_v1alpha1_ReplicationModeDetector(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersion": schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersion(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersionList": schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionList(ref), + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersionSpec": schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext": schema_apimachinery_apis_catalog_v1alpha1_SecurityContext(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SinglestoreCoordinator": schema_apimachinery_apis_catalog_v1alpha1_SinglestoreCoordinator(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SinglestoreInitContainer": schema_apimachinery_apis_catalog_v1alpha1_SinglestoreInitContainer(ref), @@ -22890,6 +22896,48 @@ func schema_apimachinery_apis_catalog_v1alpha1_AddonTasks(ref common.ReferenceCa } } +func schema_apimachinery_apis_catalog_v1alpha1_ApicurioInMemory(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ApicurioInMemory is the Apicurio Registry In-Memory image", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "image": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"image"}, + }, + }, + } +} + +func schema_apimachinery_apis_catalog_v1alpha1_ApicurioSQL(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "ApicurioSQL is the Apicurio Registry sql image", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "image": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"image"}, + }, + }, + } +} + func schema_apimachinery_apis_catalog_v1alpha1_ArchiverSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -27584,6 +27632,27 @@ func schema_apimachinery_apis_catalog_v1alpha1_RedisVersionSpec(ref common.Refer } } +func schema_apimachinery_apis_catalog_v1alpha1_RegistryImage(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "RegistryImage is the SchemaRegistry image", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "image": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"image"}, + }, + }, + } +} + func schema_apimachinery_apis_catalog_v1alpha1_ReplicationModeDetector(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -27605,6 +27674,168 @@ func schema_apimachinery_apis_catalog_v1alpha1_ReplicationModeDetector(ref commo } } +func schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersion(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/catalog/v1alpha1.SchemaRegistryVersionSpec"), + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersionSpec"}, + } +} + +func schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionList(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SchemaRegistryVersionList is a list of SchemaRegistryVersion", + 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 SchemaRegistryVersion CRD objects", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersion"), + }, + }, + }, + }, + }, + }, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SchemaRegistryVersion"}, + } +} + +func schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Description: "SchemaRegistryVersionSpec is the spec for SchemaRegistry version", + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "distribution": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "version": { + SchemaProps: spec.SchemaProps{ + Description: "Version", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "registry": { + SchemaProps: spec.SchemaProps{ + Description: "Registry Image", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.RegistryImage"), + }, + }, + "inMemory": { + SchemaProps: spec.SchemaProps{ + Description: "Schema Registry In Memory Image", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory"), + }, + }, + "sql": { + SchemaProps: spec.SchemaProps{ + Description: "Schema Registry SQL Image", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL"), + }, + }, + "deprecated": { + SchemaProps: spec.SchemaProps{ + Description: "Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded.", + Type: []string{"boolean"}, + Format: "", + }, + }, + "updateConstraints": { + SchemaProps: spec.SchemaProps{ + Description: "update constraints", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"), + }, + }, + "securityContext": { + SchemaProps: spec.SchemaProps{ + Description: "SecurityContext is for the additional config for the DB container", + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext"), + }, + }, + }, + Required: []string{"distribution", "version", "registry"}, + }, + }, + Dependencies: []string{ + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RegistryImage", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"}, + } +} + func schema_apimachinery_apis_catalog_v1alpha1_SecurityContext(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/catalog/v1alpha1/schemaregistry_version_helpers.go b/apis/catalog/v1alpha1/schemaregistry_version_helpers.go new file mode 100644 index 0000000000..ef129a107d --- /dev/null +++ b/apis/catalog/v1alpha1/schemaregistry_version_helpers.go @@ -0,0 +1,64 @@ +/* +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/catalog" + "kubedb.dev/apimachinery/crds" + + "kmodules.xyz/client-go/apiextensions" +) + +func (_ *SchemaRegistryVersion) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { + return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralSchemaRegistryVersion)) +} + +var _ apis.ResourceInfo = &SchemaRegistryVersion{} + +func (r *SchemaRegistryVersion) ResourceFQN() string { + return fmt.Sprintf("%s.%s", ResourcePluralSchemaRegistryVersion, catalog.GroupName) +} + +func (r *SchemaRegistryVersion) ResourceShortCode() string { + return ResourceCodeSchemaRegistryVersion +} + +func (r *SchemaRegistryVersion) ResourceKind() string { + return ResourceKindSchemaRegistryVersion +} + +func (r *SchemaRegistryVersion) ResourceSingular() string { + return ResourceSingularSchemaRegistryVersion +} + +func (r *SchemaRegistryVersion) ResourcePlural() string { + return ResourcePluralSchemaRegistryVersion +} + +func (r *SchemaRegistryVersion) ValidateSpecs() error { + if r.Spec.Version == "" || + r.Spec.Registry.Image == "" || + r.Spec.InMemory.Image == "" || r.Spec.SQL.Image == "" { + return fmt.Errorf(`atleast one of the following specs is not set for schemaRegistryVersion "%v": + spec.version, + spec.registry.image, r.inMemory.image, r.sql.image`, r.Name) + } + return nil +} diff --git a/apis/catalog/v1alpha1/schemaregistry_version_types.go b/apis/catalog/v1alpha1/schemaregistry_version_types.go new file mode 100644 index 0000000000..0d50f3f566 --- /dev/null +++ b/apis/catalog/v1alpha1/schemaregistry_version_types.go @@ -0,0 +1,103 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ResourceCodeSchemaRegistryVersion = "ksrversion" + ResourceKindSchemaRegistryVersion = "SchemaRegistryVersion" + ResourceSingularSchemaRegistryVersion = "schemaregistryversion" + ResourcePluralSchemaRegistryVersion = "schemaregistryversions" +) + +// SchemaRegistryVersion defines a SchemaRegistry 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=schemaregistryversions,singular=schemaregistryversion,scope=Cluster,shortName=ksrversion,categories={datastore,kubedb,appscode} +// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version" +// +kubebuilder:printcolumn:name="Distribution",type="string",JSONPath=".spec.distribution" +// +kubebuilder:printcolumn:name="REGISTRY_IMAGE",type="string",JSONPath=".spec.registry.image" +// +kubebuilder:printcolumn:name="Deprecated",type="boolean",JSONPath=".spec.deprecated" +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +type SchemaRegistryVersion struct { + metav1.TypeMeta `json:",inline,omitempty"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec SchemaRegistryVersionSpec `json:"spec,omitempty"` +} + +// SchemaRegistryVersionSpec is the spec for SchemaRegistry version +type SchemaRegistryVersionSpec struct { + Distribution SchemaRegistryDistro `json:"distribution"` + // Version + Version string `json:"version"` + // Registry Image + Registry RegistryImage `json:"registry"` + // Schema Registry In Memory Image + InMemory ApicurioInMemory `json:"inMemory,omitempty"` + // Schema Registry SQL Image + SQL ApicurioSQL `json:"sql,omitempty"` + // Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded. + // +optional + Deprecated bool `json:"deprecated,omitempty"` + // update constraints + UpdateConstraints UpdateConstraints `json:"updateConstraints,omitempty"` + // SecurityContext is for the additional config for the DB container + // +optional + SecurityContext SecurityContext `json:"securityContext"` +} + +// RegistryImage is the SchemaRegistry image +type RegistryImage struct { + Image string `json:"image"` +} + +// ApicurioInMemory is the Apicurio Registry In-Memory image +type ApicurioInMemory struct { + Image string `json:"image"` +} + +// ApicurioSQL is the Apicurio Registry sql image +type ApicurioSQL struct { + Image string `json:"image"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SchemaRegistryVersionList is a list of SchemaRegistryVersion +type SchemaRegistryVersionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + // Items is a list of SchemaRegistryVersion CRD objects + Items []SchemaRegistryVersion `json:"items,omitempty"` +} + +// +kubebuilder:validation:Enum=Apicurio;Aiven +type SchemaRegistryDistro string + +const ( + SchemaRegistryDistroApicurio SchemaRegistryDistro = "Apicurio" + SchemaRegistryDistroAiven SchemaRegistryDistro = "Aiven" +) diff --git a/apis/catalog/v1alpha1/zz_generated.deepcopy.go b/apis/catalog/v1alpha1/zz_generated.deepcopy.go index a88f52960d..082e9a90ee 100644 --- a/apis/catalog/v1alpha1/zz_generated.deepcopy.go +++ b/apis/catalog/v1alpha1/zz_generated.deepcopy.go @@ -61,6 +61,38 @@ func (in *AddonTasks) DeepCopy() *AddonTasks { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApicurioInMemory) DeepCopyInto(out *ApicurioInMemory) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApicurioInMemory. +func (in *ApicurioInMemory) DeepCopy() *ApicurioInMemory { + if in == nil { + return nil + } + out := new(ApicurioInMemory) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ApicurioSQL) DeepCopyInto(out *ApicurioSQL) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApicurioSQL. +func (in *ApicurioSQL) DeepCopy() *ApicurioSQL { + if in == nil { + return nil + } + out := new(ApicurioSQL) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArchiverSpec) DeepCopyInto(out *ArchiverSpec) { *out = *in @@ -2819,6 +2851,22 @@ func (in *RedisVersionSpec) DeepCopy() *RedisVersionSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryImage) DeepCopyInto(out *RegistryImage) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryImage. +func (in *RegistryImage) DeepCopy() *RegistryImage { + if in == nil { + return nil + } + out := new(RegistryImage) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReplicationModeDetector) DeepCopyInto(out *ReplicationModeDetector) { *out = *in @@ -2835,6 +2883,87 @@ func (in *ReplicationModeDetector) DeepCopy() *ReplicationModeDetector { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SchemaRegistryVersion) DeepCopyInto(out *SchemaRegistryVersion) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryVersion. +func (in *SchemaRegistryVersion) DeepCopy() *SchemaRegistryVersion { + if in == nil { + return nil + } + out := new(SchemaRegistryVersion) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SchemaRegistryVersion) 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 *SchemaRegistryVersionList) DeepCopyInto(out *SchemaRegistryVersionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SchemaRegistryVersion, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryVersionList. +func (in *SchemaRegistryVersionList) DeepCopy() *SchemaRegistryVersionList { + if in == nil { + return nil + } + out := new(SchemaRegistryVersionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SchemaRegistryVersionList) 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 *SchemaRegistryVersionSpec) DeepCopyInto(out *SchemaRegistryVersionSpec) { + *out = *in + out.Registry = in.Registry + out.InMemory = in.InMemory + out.SQL = in.SQL + in.UpdateConstraints.DeepCopyInto(&out.UpdateConstraints) + in.SecurityContext.DeepCopyInto(&out.SecurityContext) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SchemaRegistryVersionSpec. +func (in *SchemaRegistryVersionSpec) DeepCopy() *SchemaRegistryVersionSpec { + if in == nil { + return nil + } + out := new(SchemaRegistryVersionSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SecurityContext) DeepCopyInto(out *SecurityContext) { *out = *in diff --git a/client/clientset/versioned/typed/catalog/v1alpha1/catalog_client.go b/client/clientset/versioned/typed/catalog/v1alpha1/catalog_client.go index d97048c58f..a1840a3d7c 100644 --- a/client/clientset/versioned/typed/catalog/v1alpha1/catalog_client.go +++ b/client/clientset/versioned/typed/catalog/v1alpha1/catalog_client.go @@ -47,6 +47,7 @@ type CatalogV1alpha1Interface interface { ProxySQLVersionsGetter RabbitMQVersionsGetter RedisVersionsGetter + SchemaRegistryVersionsGetter SinglestoreVersionsGetter SolrVersionsGetter ZooKeeperVersionsGetter @@ -129,6 +130,10 @@ func (c *CatalogV1alpha1Client) RedisVersions() RedisVersionInterface { return newRedisVersions(c) } +func (c *CatalogV1alpha1Client) SchemaRegistryVersions() SchemaRegistryVersionInterface { + return newSchemaRegistryVersions(c) +} + func (c *CatalogV1alpha1Client) SinglestoreVersions() SinglestoreVersionInterface { return newSinglestoreVersions(c) } diff --git a/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_catalog_client.go b/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_catalog_client.go index 194ab84935..3e563b9d93 100644 --- a/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_catalog_client.go +++ b/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_catalog_client.go @@ -101,6 +101,10 @@ func (c *FakeCatalogV1alpha1) RedisVersions() v1alpha1.RedisVersionInterface { return &FakeRedisVersions{c} } +func (c *FakeCatalogV1alpha1) SchemaRegistryVersions() v1alpha1.SchemaRegistryVersionInterface { + return &FakeSchemaRegistryVersions{c} +} + func (c *FakeCatalogV1alpha1) SinglestoreVersions() v1alpha1.SinglestoreVersionInterface { return &FakeSinglestoreVersions{c} } diff --git a/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_schemaregistryversion.go b/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_schemaregistryversion.go new file mode 100644 index 0000000000..6807bae991 --- /dev/null +++ b/client/clientset/versioned/typed/catalog/v1alpha1/fake/fake_schemaregistryversion.go @@ -0,0 +1,122 @@ +/* +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/catalog/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" +) + +// FakeSchemaRegistryVersions implements SchemaRegistryVersionInterface +type FakeSchemaRegistryVersions struct { + Fake *FakeCatalogV1alpha1 +} + +var schemaregistryversionsResource = v1alpha1.SchemeGroupVersion.WithResource("schemaregistryversions") + +var schemaregistryversionsKind = v1alpha1.SchemeGroupVersion.WithKind("SchemaRegistryVersion") + +// Get takes name of the schemaRegistryVersion, and returns the corresponding schemaRegistryVersion object, and an error if there is any. +func (c *FakeSchemaRegistryVersions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(schemaregistryversionsResource, name), &v1alpha1.SchemaRegistryVersion{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistryVersion), err +} + +// List takes label and field selectors, and returns the list of SchemaRegistryVersions that match those selectors. +func (c *FakeSchemaRegistryVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SchemaRegistryVersionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(schemaregistryversionsResource, schemaregistryversionsKind, opts), &v1alpha1.SchemaRegistryVersionList{}) + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SchemaRegistryVersionList{ListMeta: obj.(*v1alpha1.SchemaRegistryVersionList).ListMeta} + for _, item := range obj.(*v1alpha1.SchemaRegistryVersionList).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 schemaRegistryVersions. +func (c *FakeSchemaRegistryVersions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(schemaregistryversionsResource, opts)) +} + +// Create takes the representation of a schemaRegistryVersion and creates it. Returns the server's representation of the schemaRegistryVersion, and an error, if there is any. +func (c *FakeSchemaRegistryVersions) Create(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.CreateOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(schemaregistryversionsResource, schemaRegistryVersion), &v1alpha1.SchemaRegistryVersion{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistryVersion), err +} + +// Update takes the representation of a schemaRegistryVersion and updates it. Returns the server's representation of the schemaRegistryVersion, and an error, if there is any. +func (c *FakeSchemaRegistryVersions) Update(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.UpdateOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(schemaregistryversionsResource, schemaRegistryVersion), &v1alpha1.SchemaRegistryVersion{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistryVersion), err +} + +// Delete takes name of the schemaRegistryVersion and deletes it. Returns an error if one occurs. +func (c *FakeSchemaRegistryVersions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteActionWithOptions(schemaregistryversionsResource, name, opts), &v1alpha1.SchemaRegistryVersion{}) + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSchemaRegistryVersions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(schemaregistryversionsResource, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.SchemaRegistryVersionList{}) + return err +} + +// Patch applies the patch and returns the patched schemaRegistryVersion. +func (c *FakeSchemaRegistryVersions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SchemaRegistryVersion, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(schemaregistryversionsResource, name, pt, data, subresources...), &v1alpha1.SchemaRegistryVersion{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SchemaRegistryVersion), err +} diff --git a/client/clientset/versioned/typed/catalog/v1alpha1/generated_expansion.go b/client/clientset/versioned/typed/catalog/v1alpha1/generated_expansion.go index f9e9be0992..0545c9fec5 100644 --- a/client/clientset/versioned/typed/catalog/v1alpha1/generated_expansion.go +++ b/client/clientset/versioned/typed/catalog/v1alpha1/generated_expansion.go @@ -54,6 +54,8 @@ type RabbitMQVersionExpansion interface{} type RedisVersionExpansion interface{} +type SchemaRegistryVersionExpansion interface{} + type SinglestoreVersionExpansion interface{} type SolrVersionExpansion interface{} diff --git a/client/clientset/versioned/typed/catalog/v1alpha1/schemaregistryversion.go b/client/clientset/versioned/typed/catalog/v1alpha1/schemaregistryversion.go new file mode 100644 index 0000000000..849089c865 --- /dev/null +++ b/client/clientset/versioned/typed/catalog/v1alpha1/schemaregistryversion.go @@ -0,0 +1,169 @@ +/* +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/catalog/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" +) + +// SchemaRegistryVersionsGetter has a method to return a SchemaRegistryVersionInterface. +// A group's client should implement this interface. +type SchemaRegistryVersionsGetter interface { + SchemaRegistryVersions() SchemaRegistryVersionInterface +} + +// SchemaRegistryVersionInterface has methods to work with SchemaRegistryVersion resources. +type SchemaRegistryVersionInterface interface { + Create(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.CreateOptions) (*v1alpha1.SchemaRegistryVersion, error) + Update(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.UpdateOptions) (*v1alpha1.SchemaRegistryVersion, 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.SchemaRegistryVersion, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SchemaRegistryVersionList, 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.SchemaRegistryVersion, err error) + SchemaRegistryVersionExpansion +} + +// schemaRegistryVersions implements SchemaRegistryVersionInterface +type schemaRegistryVersions struct { + client rest.Interface +} + +// newSchemaRegistryVersions returns a SchemaRegistryVersions +func newSchemaRegistryVersions(c *CatalogV1alpha1Client) *schemaRegistryVersions { + return &schemaRegistryVersions{ + client: c.RESTClient(), + } +} + +// Get takes name of the schemaRegistryVersion, and returns the corresponding schemaRegistryVersion object, and an error if there is any. +func (c *schemaRegistryVersions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + result = &v1alpha1.SchemaRegistryVersion{} + err = c.client.Get(). + Resource("schemaregistryversions"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SchemaRegistryVersions that match those selectors. +func (c *schemaRegistryVersions) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SchemaRegistryVersionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SchemaRegistryVersionList{} + err = c.client.Get(). + Resource("schemaregistryversions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested schemaRegistryVersions. +func (c *schemaRegistryVersions) 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(). + Resource("schemaregistryversions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a schemaRegistryVersion and creates it. Returns the server's representation of the schemaRegistryVersion, and an error, if there is any. +func (c *schemaRegistryVersions) Create(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.CreateOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + result = &v1alpha1.SchemaRegistryVersion{} + err = c.client.Post(). + Resource("schemaregistryversions"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(schemaRegistryVersion). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a schemaRegistryVersion and updates it. Returns the server's representation of the schemaRegistryVersion, and an error, if there is any. +func (c *schemaRegistryVersions) Update(ctx context.Context, schemaRegistryVersion *v1alpha1.SchemaRegistryVersion, opts v1.UpdateOptions) (result *v1alpha1.SchemaRegistryVersion, err error) { + result = &v1alpha1.SchemaRegistryVersion{} + err = c.client.Put(). + Resource("schemaregistryversions"). + Name(schemaRegistryVersion.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(schemaRegistryVersion). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the schemaRegistryVersion and deletes it. Returns an error if one occurs. +func (c *schemaRegistryVersions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Resource("schemaregistryversions"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *schemaRegistryVersions) 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(). + Resource("schemaregistryversions"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched schemaRegistryVersion. +func (c *schemaRegistryVersions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SchemaRegistryVersion, err error) { + result = &v1alpha1.SchemaRegistryVersion{} + err = c.client.Patch(pt). + Resource("schemaregistryversions"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/client/informers/externalversions/catalog/v1alpha1/interface.go b/client/informers/externalversions/catalog/v1alpha1/interface.go index 3e9e3f509a..ba442c5f80 100644 --- a/client/informers/externalversions/catalog/v1alpha1/interface.go +++ b/client/informers/externalversions/catalog/v1alpha1/interface.go @@ -60,6 +60,8 @@ type Interface interface { RabbitMQVersions() RabbitMQVersionInformer // RedisVersions returns a RedisVersionInformer. RedisVersions() RedisVersionInformer + // SchemaRegistryVersions returns a SchemaRegistryVersionInformer. + SchemaRegistryVersions() SchemaRegistryVersionInformer // SinglestoreVersions returns a SinglestoreVersionInformer. SinglestoreVersions() SinglestoreVersionInformer // SolrVersions returns a SolrVersionInformer. @@ -169,6 +171,11 @@ func (v *version) RedisVersions() RedisVersionInformer { return &redisVersionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} } +// SchemaRegistryVersions returns a SchemaRegistryVersionInformer. +func (v *version) SchemaRegistryVersions() SchemaRegistryVersionInformer { + return &schemaRegistryVersionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} +} + // SinglestoreVersions returns a SinglestoreVersionInformer. func (v *version) SinglestoreVersions() SinglestoreVersionInformer { return &singlestoreVersionInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} diff --git a/client/informers/externalversions/catalog/v1alpha1/schemaregistryversion.go b/client/informers/externalversions/catalog/v1alpha1/schemaregistryversion.go new file mode 100644 index 0000000000..ddc8201da4 --- /dev/null +++ b/client/informers/externalversions/catalog/v1alpha1/schemaregistryversion.go @@ -0,0 +1,90 @@ +/* +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" + + catalogv1alpha1 "kubedb.dev/apimachinery/apis/catalog/v1alpha1" + versioned "kubedb.dev/apimachinery/client/clientset/versioned" + internalinterfaces "kubedb.dev/apimachinery/client/informers/externalversions/internalinterfaces" + v1alpha1 "kubedb.dev/apimachinery/client/listers/catalog/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" +) + +// SchemaRegistryVersionInformer provides access to a shared informer and lister for +// SchemaRegistryVersions. +type SchemaRegistryVersionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.SchemaRegistryVersionLister +} + +type schemaRegistryVersionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// NewSchemaRegistryVersionInformer constructs a new informer for SchemaRegistryVersion 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 NewSchemaRegistryVersionInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSchemaRegistryVersionInformer(client, resyncPeriod, indexers, nil) +} + +// NewFilteredSchemaRegistryVersionInformer constructs a new informer for SchemaRegistryVersion 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 NewFilteredSchemaRegistryVersionInformer(client versioned.Interface, 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.CatalogV1alpha1().SchemaRegistryVersions().List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.CatalogV1alpha1().SchemaRegistryVersions().Watch(context.TODO(), options) + }, + }, + &catalogv1alpha1.SchemaRegistryVersion{}, + resyncPeriod, + indexers, + ) +} + +func (f *schemaRegistryVersionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSchemaRegistryVersionInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *schemaRegistryVersionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&catalogv1alpha1.SchemaRegistryVersion{}, f.defaultInformer) +} + +func (f *schemaRegistryVersionInformer) Lister() v1alpha1.SchemaRegistryVersionLister { + return v1alpha1.NewSchemaRegistryVersionLister(f.Informer().GetIndexer()) +} diff --git a/client/informers/externalversions/generic.go b/client/informers/externalversions/generic.go index 035de59d2c..5a1b0c465e 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -138,6 +138,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Catalog().V1alpha1().RabbitMQVersions().Informer()}, nil case catalogv1alpha1.SchemeGroupVersion.WithResource("redisversions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Catalog().V1alpha1().RedisVersions().Informer()}, nil + case catalogv1alpha1.SchemeGroupVersion.WithResource("schemaregistryversions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Catalog().V1alpha1().SchemaRegistryVersions().Informer()}, nil case catalogv1alpha1.SchemeGroupVersion.WithResource("singlestoreversions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Catalog().V1alpha1().SinglestoreVersions().Informer()}, nil case catalogv1alpha1.SchemeGroupVersion.WithResource("solrversions"): diff --git a/client/listers/catalog/v1alpha1/expansion_generated.go b/client/listers/catalog/v1alpha1/expansion_generated.go index 22b64f489a..dcab9bcb7c 100644 --- a/client/listers/catalog/v1alpha1/expansion_generated.go +++ b/client/listers/catalog/v1alpha1/expansion_generated.go @@ -90,6 +90,10 @@ type RabbitMQVersionListerExpansion interface{} // RedisVersionLister. type RedisVersionListerExpansion interface{} +// SchemaRegistryVersionListerExpansion allows custom methods to be added to +// SchemaRegistryVersionLister. +type SchemaRegistryVersionListerExpansion interface{} + // SinglestoreVersionListerExpansion allows custom methods to be added to // SinglestoreVersionLister. type SinglestoreVersionListerExpansion interface{} diff --git a/client/listers/catalog/v1alpha1/schemaregistryversion.go b/client/listers/catalog/v1alpha1/schemaregistryversion.go new file mode 100644 index 0000000000..da768ad43f --- /dev/null +++ b/client/listers/catalog/v1alpha1/schemaregistryversion.go @@ -0,0 +1,69 @@ +/* +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/catalog/v1alpha1" + + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// SchemaRegistryVersionLister helps list SchemaRegistryVersions. +// All objects returned here must be treated as read-only. +type SchemaRegistryVersionLister interface { + // List lists all SchemaRegistryVersions in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistryVersion, err error) + // Get retrieves the SchemaRegistryVersion from the index for a given name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.SchemaRegistryVersion, error) + SchemaRegistryVersionListerExpansion +} + +// schemaRegistryVersionLister implements the SchemaRegistryVersionLister interface. +type schemaRegistryVersionLister struct { + indexer cache.Indexer +} + +// NewSchemaRegistryVersionLister returns a new SchemaRegistryVersionLister. +func NewSchemaRegistryVersionLister(indexer cache.Indexer) SchemaRegistryVersionLister { + return &schemaRegistryVersionLister{indexer: indexer} +} + +// List lists all SchemaRegistryVersions in the indexer. +func (s *schemaRegistryVersionLister) List(selector labels.Selector) (ret []*v1alpha1.SchemaRegistryVersion, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.SchemaRegistryVersion)) + }) + return ret, err +} + +// Get retrieves the SchemaRegistryVersion from the index for a given name. +func (s *schemaRegistryVersionLister) Get(name string) (*v1alpha1.SchemaRegistryVersion, error) { + obj, exists, err := s.indexer.GetByKey(name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("schemaregistryversion"), name) + } + return obj.(*v1alpha1.SchemaRegistryVersion), nil +} diff --git a/crds/catalog.kubedb.com_schemaregistryversions.yaml b/crds/catalog.kubedb.com_schemaregistryversions.yaml new file mode 100644 index 0000000000..2ae6eff166 --- /dev/null +++ b/crds/catalog.kubedb.com_schemaregistryversions.yaml @@ -0,0 +1,106 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + labels: + app.kubernetes.io/name: kubedb + name: schemaregistryversions.catalog.kubedb.com +spec: + group: catalog.kubedb.com + names: + categories: + - datastore + - kubedb + - appscode + kind: SchemaRegistryVersion + listKind: SchemaRegistryVersionList + plural: schemaregistryversions + shortNames: + - ksrversion + singular: schemaregistryversion + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.version + name: Version + type: string + - jsonPath: .spec.distribution + name: Distribution + type: string + - jsonPath: .spec.registry.image + name: REGISTRY_IMAGE + type: string + - jsonPath: .spec.deprecated + name: Deprecated + type: boolean + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + deprecated: + type: boolean + distribution: + enum: + - Apicurio + - Aiven + type: string + inMemory: + properties: + image: + type: string + required: + - image + type: object + registry: + properties: + image: + type: string + required: + - image + type: object + securityContext: + properties: + runAsUser: + format: int64 + type: integer + type: object + sql: + properties: + image: + type: string + required: + - image + type: object + updateConstraints: + properties: + allowlist: + items: + type: string + type: array + denylist: + items: + type: string + type: array + type: object + version: + type: string + required: + - distribution + - registry + - version + type: object + type: object + served: true + storage: true + subresources: {} diff --git a/pkg/openapi/lib.go b/pkg/openapi/lib.go index de70672752..d69eee1f2e 100644 --- a/pkg/openapi/lib.go +++ b/pkg/openapi/lib.go @@ -74,6 +74,7 @@ func ConfigureOpenAPI(scheme *runtime.Scheme, serverConfig *genericapiserver.Rec "/apis/mutators.kafka.kubedb.com/v1alpha1", "/apis/mutators.kafka.kubedb.com/v1alpha1/connectclusterwebhooks", "/apis/mutators.kafka.kubedb.com/v1alpha1/connectorwebhooks", + "/apis/mutators.kafka.kubedb.com/v1alpha1/schemaregistrywebhooks", "/apis/mutators.schema.kubedb.com/v1alpha1", "/apis/mutators.schema.kubedb.com/v1alpha1/mariadbdatabasewebhooks", @@ -135,6 +136,7 @@ func ConfigureOpenAPI(scheme *runtime.Scheme, serverConfig *genericapiserver.Rec "/apis/validators.kafka.kubedb.com/v1alpha1", "/apis/validators.kafka.kubedb.com/v1alpha1/connectclusterwebhooks", "/apis/validators.kafka.kubedb.com/v1alpha1/connectorwebhooks", + "/apis/validators.kafka.kubedb.com/v1alpha1/schemaregistrywebhooks", "/apis/validators.schema.kubedb.com/v1alpha1", "/apis/validators.schema.kubedb.com/v1alpha1/mariadbdatabasewebhooks", From 939348755ad6a4a4e60cf4aed71e948e8a4e0163 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Tue, 21 May 2024 15:59:57 +0600 Subject: [PATCH 4/7] Update schema registry webhook with new schemaregistry version Signed-off-by: obaydullahmhs --- apis/kafka/v1alpha1/schemaregistry_helpers.go | 28 +-- apis/kafka/v1alpha1/schemaregistry_webhook.go | 2 +- .../client-go/discovery/fake/discovery.go | 174 ++++++++++++++++++ vendor/modules.txt | 1 + 4 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 vendor/k8s.io/client-go/discovery/fake/discovery.go diff --git a/apis/kafka/v1alpha1/schemaregistry_helpers.go b/apis/kafka/v1alpha1/schemaregistry_helpers.go index 55f0a695f5..31e3cd3d45 100644 --- a/apis/kafka/v1alpha1/schemaregistry_helpers.go +++ b/apis/kafka/v1alpha1/schemaregistry_helpers.go @@ -205,14 +205,14 @@ func (k *SchemaRegistry) SetDefaults() { k.Spec.Replicas = pointer.Int32P(1) } - var kfVersion catalog.KafkaVersion - err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: k.Spec.Version}, &kfVersion) + var ksrVersion catalog.SchemaRegistryVersion + err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: k.Spec.Version}, &ksrVersion) if err != nil { - klog.Errorf("can't get the kafka version object %s for %s \n", err.Error(), k.Spec.Version) + klog.Errorf("can't get the schema-registry version object %s for %s \n", err.Error(), k.Spec.Version) return } - k.setDefaultContainerSecurityContext(&kfVersion, &k.Spec.PodTemplate) + k.setDefaultContainerSecurityContext(&ksrVersion, &k.Spec.PodTemplate) dbContainer := coreutil.GetContainerByName(k.Spec.PodTemplate.Spec.Containers, SchemaRegistryContainerName) if dbContainer != nil && (dbContainer.Resources.Requests == nil && dbContainer.Resources.Limits == nil) { @@ -220,17 +220,9 @@ func (k *SchemaRegistry) SetDefaults() { } k.SetHealthCheckerDefaults() - - k.SetDefaultEnvs() -} - -func (k *SchemaRegistry) SetDefaultEnvs() { - container := coreutil.GetContainerByName(k.Spec.PodTemplate.Spec.Containers, SchemaRegistryContainerName) - if container != nil { - } } -func (k *SchemaRegistry) setDefaultContainerSecurityContext(kfVersion *catalog.KafkaVersion, podTemplate *ofstv2.PodTemplateSpec) { +func (k *SchemaRegistry) setDefaultContainerSecurityContext(ksrVersion *catalog.SchemaRegistryVersion, podTemplate *ofstv2.PodTemplateSpec) { if podTemplate == nil { return } @@ -238,7 +230,7 @@ func (k *SchemaRegistry) setDefaultContainerSecurityContext(kfVersion *catalog.K podTemplate.Spec.SecurityContext = &core.PodSecurityContext{} } if podTemplate.Spec.SecurityContext.FSGroup == nil { - podTemplate.Spec.SecurityContext.FSGroup = kfVersion.Spec.SecurityContext.RunAsUser + podTemplate.Spec.SecurityContext.FSGroup = ksrVersion.Spec.SecurityContext.RunAsUser } container := coreutil.GetContainerByName(podTemplate.Spec.Containers, SchemaRegistryContainerName) @@ -250,11 +242,11 @@ func (k *SchemaRegistry) setDefaultContainerSecurityContext(kfVersion *catalog.K if container.SecurityContext == nil { container.SecurityContext = &core.SecurityContext{} } - k.assignDefaultContainerSecurityContext(kfVersion, container.SecurityContext) + k.assignDefaultContainerSecurityContext(ksrVersion, container.SecurityContext) podTemplate.Spec.Containers = coreutil.UpsertContainer(podTemplate.Spec.Containers, *container) } -func (k *SchemaRegistry) assignDefaultContainerSecurityContext(kfVersion *catalog.KafkaVersion, sc *core.SecurityContext) { +func (k *SchemaRegistry) assignDefaultContainerSecurityContext(ksrVersion *catalog.SchemaRegistryVersion, sc *core.SecurityContext) { if sc.AllowPrivilegeEscalation == nil { sc.AllowPrivilegeEscalation = pointer.BoolP(false) } @@ -267,10 +259,10 @@ func (k *SchemaRegistry) assignDefaultContainerSecurityContext(kfVersion *catalo sc.RunAsNonRoot = pointer.BoolP(true) } if sc.RunAsUser == nil { - sc.RunAsUser = kfVersion.Spec.SecurityContext.RunAsUser + sc.RunAsUser = ksrVersion.Spec.SecurityContext.RunAsUser } if sc.RunAsGroup == nil { - sc.RunAsGroup = kfVersion.Spec.SecurityContext.RunAsUser + sc.RunAsGroup = ksrVersion.Spec.SecurityContext.RunAsUser } if sc.SeccompProfile == nil { sc.SeccompProfile = secomp.DefaultSeccompProfile() diff --git a/apis/kafka/v1alpha1/schemaregistry_webhook.go b/apis/kafka/v1alpha1/schemaregistry_webhook.go index aa3bf638a2..ab8c08b4c0 100644 --- a/apis/kafka/v1alpha1/schemaregistry_webhook.go +++ b/apis/kafka/v1alpha1/schemaregistry_webhook.go @@ -148,7 +148,7 @@ func (k *SchemaRegistry) validateEnvVars() error { } func (k *SchemaRegistry) validateVersion() error { - ksrVersion := &catalog.KafkaVersion{} + ksrVersion := &catalog.SchemaRegistryVersion{} err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: k.Spec.Version}, ksrVersion) if err != nil { return errors.New("version not supported") diff --git a/vendor/k8s.io/client-go/discovery/fake/discovery.go b/vendor/k8s.io/client-go/discovery/fake/discovery.go new file mode 100644 index 0000000000..f8a78e1ef4 --- /dev/null +++ b/vendor/k8s.io/client-go/discovery/fake/discovery.go @@ -0,0 +1,174 @@ +/* +Copyright 2016 The Kubernetes Authors. + +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 fake + +import ( + "fmt" + "net/http" + + openapi_v2 "github.com/google/gnostic-models/openapiv2" + + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/version" + "k8s.io/client-go/discovery" + "k8s.io/client-go/openapi" + kubeversion "k8s.io/client-go/pkg/version" + restclient "k8s.io/client-go/rest" + "k8s.io/client-go/testing" +) + +// FakeDiscovery implements discovery.DiscoveryInterface and sometimes calls testing.Fake.Invoke with an action, +// but doesn't respect the return value if any. There is a way to fake static values like ServerVersion by using the Faked... fields on the struct. +type FakeDiscovery struct { + *testing.Fake + FakedServerVersion *version.Info +} + +// ServerResourcesForGroupVersion returns the supported resources for a group +// and version. +func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { + action := testing.ActionImpl{ + Verb: "get", + Resource: schema.GroupVersionResource{Resource: "resource"}, + } + c.Invokes(action, nil) + for _, resourceList := range c.Resources { + if resourceList.GroupVersion == groupVersion { + return resourceList, nil + } + } + return nil, &errors.StatusError{ + ErrStatus: metav1.Status{ + Status: metav1.StatusFailure, + Code: http.StatusNotFound, + Reason: metav1.StatusReasonNotFound, + Message: fmt.Sprintf("the server could not find the requested resource, GroupVersion %q not found", groupVersion), + }} +} + +// ServerGroupsAndResources returns the supported groups and resources for all groups and versions. +func (c *FakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { + sgs, err := c.ServerGroups() + if err != nil { + return nil, nil, err + } + resultGroups := []*metav1.APIGroup{} + for i := range sgs.Groups { + resultGroups = append(resultGroups, &sgs.Groups[i]) + } + + action := testing.ActionImpl{ + Verb: "get", + Resource: schema.GroupVersionResource{Resource: "resource"}, + } + c.Invokes(action, nil) + return resultGroups, c.Resources, nil +} + +// ServerPreferredResources returns the supported resources with the version +// preferred by the server. +func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) { + return nil, nil +} + +// ServerPreferredNamespacedResources returns the supported namespaced resources +// with the version preferred by the server. +func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { + return nil, nil +} + +// ServerGroups returns the supported groups, with information like supported +// versions and the preferred version. +func (c *FakeDiscovery) ServerGroups() (*metav1.APIGroupList, error) { + action := testing.ActionImpl{ + Verb: "get", + Resource: schema.GroupVersionResource{Resource: "group"}, + } + c.Invokes(action, nil) + + groups := map[string]*metav1.APIGroup{} + + for _, res := range c.Resources { + gv, err := schema.ParseGroupVersion(res.GroupVersion) + if err != nil { + return nil, err + } + group := groups[gv.Group] + if group == nil { + group = &metav1.APIGroup{ + Name: gv.Group, + PreferredVersion: metav1.GroupVersionForDiscovery{ + GroupVersion: res.GroupVersion, + Version: gv.Version, + }, + } + groups[gv.Group] = group + } + + group.Versions = append(group.Versions, metav1.GroupVersionForDiscovery{ + GroupVersion: res.GroupVersion, + Version: gv.Version, + }) + } + + list := &metav1.APIGroupList{} + for _, apiGroup := range groups { + list.Groups = append(list.Groups, *apiGroup) + } + + return list, nil + +} + +// ServerVersion retrieves and parses the server's version. +func (c *FakeDiscovery) ServerVersion() (*version.Info, error) { + action := testing.ActionImpl{} + action.Verb = "get" + action.Resource = schema.GroupVersionResource{Resource: "version"} + _, err := c.Invokes(action, nil) + if err != nil { + return nil, err + } + + if c.FakedServerVersion != nil { + return c.FakedServerVersion, nil + } + + versionInfo := kubeversion.Get() + return &versionInfo, nil +} + +// OpenAPISchema retrieves and parses the swagger API schema the server supports. +func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) { + return &openapi_v2.Document{}, nil +} + +func (c *FakeDiscovery) OpenAPIV3() openapi.Client { + panic("unimplemented") +} + +// RESTClient returns a RESTClient that is used to communicate with API server +// by this client implementation. +func (c *FakeDiscovery) RESTClient() restclient.Interface { + return nil +} + +func (c *FakeDiscovery) WithLegacy() discovery.DiscoveryInterface { + panic("unimplemented") +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f92637533c..a0746a88a9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1283,6 +1283,7 @@ k8s.io/client-go/applyconfigurations/storage/v1alpha1 k8s.io/client-go/applyconfigurations/storage/v1beta1 k8s.io/client-go/discovery k8s.io/client-go/discovery/cached/memory +k8s.io/client-go/discovery/fake k8s.io/client-go/dynamic k8s.io/client-go/dynamic/dynamicinformer k8s.io/client-go/dynamic/dynamiclister From 5a704ce49d8d1d14720a20b400d22cd309ed72c1 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Tue, 21 May 2024 17:18:35 +0600 Subject: [PATCH 5/7] Update schema version Signed-off-by: obaydullahmhs --- apis/catalog/v1alpha1/openapi_generated.go | 31 +------------------ .../schemaregistry_version_helpers.go | 4 +-- .../v1alpha1/schemaregistry_version_types.go | 7 ----- .../catalog/v1alpha1/zz_generated.deepcopy.go | 17 ---------- ...log.kubedb.com_schemaregistryversions.yaml | 7 ----- 5 files changed, 3 insertions(+), 63 deletions(-) diff --git a/apis/catalog/v1alpha1/openapi_generated.go b/apis/catalog/v1alpha1/openapi_generated.go index 08f25bbce2..932f43d11e 100644 --- a/apis/catalog/v1alpha1/openapi_generated.go +++ b/apis/catalog/v1alpha1/openapi_generated.go @@ -459,7 +459,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/catalog/v1alpha1.AddonSpec": schema_apimachinery_apis_catalog_v1alpha1_AddonSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.AddonTasks": schema_apimachinery_apis_catalog_v1alpha1_AddonTasks(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory": schema_apimachinery_apis_catalog_v1alpha1_ApicurioInMemory(ref), - "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL": schema_apimachinery_apis_catalog_v1alpha1_ApicurioSQL(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ArchiverSpec": schema_apimachinery_apis_catalog_v1alpha1_ArchiverSpec(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ConnectClusterVersion": schema_apimachinery_apis_catalog_v1alpha1_ConnectClusterVersion(ref), "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ConnectorPlugin": schema_apimachinery_apis_catalog_v1alpha1_ConnectorPlugin(ref), @@ -22917,27 +22916,6 @@ func schema_apimachinery_apis_catalog_v1alpha1_ApicurioInMemory(ref common.Refer } } -func schema_apimachinery_apis_catalog_v1alpha1_ApicurioSQL(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "ApicurioSQL is the Apicurio Registry sql image", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "image": { - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - Required: []string{"image"}, - }, - }, - } -} - func schema_apimachinery_apis_catalog_v1alpha1_ArchiverSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -27799,13 +27777,6 @@ func schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionSpec(ref com Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory"), }, }, - "sql": { - SchemaProps: spec.SchemaProps{ - Description: "Schema Registry SQL Image", - Default: map[string]interface{}{}, - Ref: ref("kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL"), - }, - }, "deprecated": { SchemaProps: spec.SchemaProps{ Description: "Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded.", @@ -27832,7 +27803,7 @@ func schema_apimachinery_apis_catalog_v1alpha1_SchemaRegistryVersionSpec(ref com }, }, Dependencies: []string{ - "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioSQL", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RegistryImage", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"}, + "kubedb.dev/apimachinery/apis/catalog/v1alpha1.ApicurioInMemory", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.RegistryImage", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.SecurityContext", "kubedb.dev/apimachinery/apis/catalog/v1alpha1.UpdateConstraints"}, } } diff --git a/apis/catalog/v1alpha1/schemaregistry_version_helpers.go b/apis/catalog/v1alpha1/schemaregistry_version_helpers.go index ef129a107d..ed04875b57 100644 --- a/apis/catalog/v1alpha1/schemaregistry_version_helpers.go +++ b/apis/catalog/v1alpha1/schemaregistry_version_helpers.go @@ -55,10 +55,10 @@ func (r *SchemaRegistryVersion) ResourcePlural() string { func (r *SchemaRegistryVersion) ValidateSpecs() error { if r.Spec.Version == "" || r.Spec.Registry.Image == "" || - r.Spec.InMemory.Image == "" || r.Spec.SQL.Image == "" { + r.Spec.InMemory.Image == "" { return fmt.Errorf(`atleast one of the following specs is not set for schemaRegistryVersion "%v": spec.version, - spec.registry.image, r.inMemory.image, r.sql.image`, r.Name) + spec.registry.image, r.inMemory.image`, r.Name) } return nil } diff --git a/apis/catalog/v1alpha1/schemaregistry_version_types.go b/apis/catalog/v1alpha1/schemaregistry_version_types.go index 0d50f3f566..cb873d7b85 100644 --- a/apis/catalog/v1alpha1/schemaregistry_version_types.go +++ b/apis/catalog/v1alpha1/schemaregistry_version_types.go @@ -57,8 +57,6 @@ type SchemaRegistryVersionSpec struct { Registry RegistryImage `json:"registry"` // Schema Registry In Memory Image InMemory ApicurioInMemory `json:"inMemory,omitempty"` - // Schema Registry SQL Image - SQL ApicurioSQL `json:"sql,omitempty"` // Deprecated versions usable but regarded as obsolete and best avoided, typically due to having been superseded. // +optional Deprecated bool `json:"deprecated,omitempty"` @@ -79,11 +77,6 @@ type ApicurioInMemory struct { Image string `json:"image"` } -// ApicurioSQL is the Apicurio Registry sql image -type ApicurioSQL struct { - Image string `json:"image"` -} - // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SchemaRegistryVersionList is a list of SchemaRegistryVersion diff --git a/apis/catalog/v1alpha1/zz_generated.deepcopy.go b/apis/catalog/v1alpha1/zz_generated.deepcopy.go index 082e9a90ee..f582c6771b 100644 --- a/apis/catalog/v1alpha1/zz_generated.deepcopy.go +++ b/apis/catalog/v1alpha1/zz_generated.deepcopy.go @@ -77,22 +77,6 @@ func (in *ApicurioInMemory) DeepCopy() *ApicurioInMemory { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApicurioSQL) DeepCopyInto(out *ApicurioSQL) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApicurioSQL. -func (in *ApicurioSQL) DeepCopy() *ApicurioSQL { - if in == nil { - return nil - } - out := new(ApicurioSQL) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ArchiverSpec) DeepCopyInto(out *ArchiverSpec) { *out = *in @@ -2948,7 +2932,6 @@ func (in *SchemaRegistryVersionSpec) DeepCopyInto(out *SchemaRegistryVersionSpec *out = *in out.Registry = in.Registry out.InMemory = in.InMemory - out.SQL = in.SQL in.UpdateConstraints.DeepCopyInto(&out.UpdateConstraints) in.SecurityContext.DeepCopyInto(&out.SecurityContext) return diff --git a/crds/catalog.kubedb.com_schemaregistryversions.yaml b/crds/catalog.kubedb.com_schemaregistryversions.yaml index 2ae6eff166..02ca97d01b 100644 --- a/crds/catalog.kubedb.com_schemaregistryversions.yaml +++ b/crds/catalog.kubedb.com_schemaregistryversions.yaml @@ -75,13 +75,6 @@ spec: format: int64 type: integer type: object - sql: - properties: - image: - type: string - required: - - image - type: object updateConstraints: properties: allowlist: From e355263d5a7fe9654295658220f37af9c181dbb8 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Wed, 22 May 2024 11:32:11 +0600 Subject: [PATCH 6/7] Add schema registry version to register.go Signed-off-by: obaydullahmhs --- apis/catalog/v1alpha1/register.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apis/catalog/v1alpha1/register.go b/apis/catalog/v1alpha1/register.go index 35f8bbc438..b150b141d3 100644 --- a/apis/catalog/v1alpha1/register.go +++ b/apis/catalog/v1alpha1/register.go @@ -94,6 +94,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ZooKeeperVersionList{}, &MSSQLServerVersion{}, &MSSQLServerVersionList{}, + &SchemaRegistryVersion{}, + &SchemaRegistryVersionList{}, ) scheme.AddKnownTypes(SchemeGroupVersion, From 1a55a55920f63eadebdeb8468592095f079505c0 Mon Sep 17 00:00:00 2001 From: obaydullahmhs Date: Thu, 30 May 2024 12:32:11 +0600 Subject: [PATCH 7/7] Remove runAsGroup Signed-off-by: obaydullahmhs --- apis/kafka/v1alpha1/schemaregistry_helpers.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/apis/kafka/v1alpha1/schemaregistry_helpers.go b/apis/kafka/v1alpha1/schemaregistry_helpers.go index 31e3cd3d45..7b5682d197 100644 --- a/apis/kafka/v1alpha1/schemaregistry_helpers.go +++ b/apis/kafka/v1alpha1/schemaregistry_helpers.go @@ -261,9 +261,6 @@ func (k *SchemaRegistry) assignDefaultContainerSecurityContext(ksrVersion *catal if sc.RunAsUser == nil { sc.RunAsUser = ksrVersion.Spec.SecurityContext.RunAsUser } - if sc.RunAsGroup == nil { - sc.RunAsGroup = ksrVersion.Spec.SecurityContext.RunAsUser - } if sc.SeccompProfile == nil { sc.SeccompProfile = secomp.DefaultSeccompProfile() }