Skip to content

Commit

Permalink
feat(kafkaschemaregistryacl): add new kind
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Mar 28, 2024
1 parent e272556 commit 49a9f90
Show file tree
Hide file tree
Showing 25 changed files with 1,140 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [MAJOR.MINOR.PATCH] - YYYY-MM-DD

- Add `KafkaSchemaRegistryACL` kind
- Add `ClickhouseDatabase` kind
- Fix secret creation for kinds with no secrets
- Replace `Database` kind validations and default values with CRD validation rules
Expand Down
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,12 @@ resources:
kind: ClickhouseDatabase
path: github.com/aiven/aiven-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: aiven.io
kind: KafkaSchemaRegistryACL
path: github.com/aiven/aiven-operator/api/v1alpha1
version: v1alpha1
version: "3"
86 changes: 86 additions & 0 deletions api/v1alpha1/kafkaschemaregistryacl_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright (c) 2024 Aiven, Helsinki, Finland. https://aiven.io/

package v1alpha1

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

// KafkaSchemaRegistryACLSpec defines the desired state of KafkaSchemaRegistryACL
type KafkaSchemaRegistryACLSpec struct {
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Format="^[a-zA-Z0-9_-]*$"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// Identifies the project this resource belongs to
Project string `json:"project"`

// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// Specifies the name of the service that this resource belongs to
ServiceName string `json:"serviceName"`

// Authentication reference to Aiven token in a secret
AuthSecretRef *AuthSecretReference `json:"authSecretRef,omitempty"`

// +kubebuilder:validation:Enum=schema_registry_read;schema_registry_write
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
Permission string `json:"permission"`

// +kubebuilder:validation:MaxLength=249
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// Resource name pattern for the Schema Registry ACL entry
Resource string `json:"resource"`

// +kubebuilder:validation:MaxLength=64
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// Username pattern for the ACL entry
Username string `json:"username"`
}

// KafkaSchemaRegistryACLStatus defines the observed state of KafkaSchemaRegistryACL
type KafkaSchemaRegistryACLStatus struct {
// Conditions represent the latest available observations of an KafkaSchemaRegistryACL state
Conditions []metav1.Condition `json:"conditions"`

// Kafka ACL ID
ACLId string `json:"acl_id"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// KafkaSchemaRegistryACL is the Schema for the kafkaschemaregistryacls API
type KafkaSchemaRegistryACL struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec KafkaSchemaRegistryACLSpec `json:"spec,omitempty"`
Status KafkaSchemaRegistryACLStatus `json:"status,omitempty"`
}

func (in *KafkaSchemaRegistryACL) AuthSecretRef() *AuthSecretReference {
return in.Spec.AuthSecretRef
}

func (in *KafkaSchemaRegistryACL) Conditions() *[]metav1.Condition {
return &in.Status.Conditions
}

func (in *KafkaSchemaRegistryACL) NoSecret() bool {
return true
}

var _ AivenManagedObject = &KafkaSchemaRegistryACL{}

//+kubebuilder:object:root=true

// KafkaSchemaRegistryACLList contains a list of KafkaSchemaRegistryACL
type KafkaSchemaRegistryACLList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KafkaSchemaRegistryACL `json:"items"`
}

func init() {
SchemeBuilder.Register(&KafkaSchemaRegistryACL{}, &KafkaSchemaRegistryACLList{})
}
101 changes: 101 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 49a9f90

Please sign in to comment.