Skip to content

Commit

Permalink
WIP: schema gen from controller-gen annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseto committed Apr 17, 2024
1 parent 4aa51d7 commit 98f4525
Show file tree
Hide file tree
Showing 8 changed files with 6,695 additions and 529 deletions.
10 changes: 7 additions & 3 deletions charts/redpanda/kafka_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ package redpanda
// Developer facing documentation
// Annotations +kubebuilder,+gotohelm,etc

// JSONScalar is any scalar JSON value marshalled to a string.
// +kubebuilder:validation:Pattern=^(\d+)|(true|false)|(".*")$
type JSONScalar string

type BrokerConfig struct {
// KafkaListeners is an amalgam of `kafka_api`, `kafka_api_tls`,
// `advertised_kafka_api`. That may be configured in a more ergonomic and
Expand All @@ -15,17 +19,17 @@ type BrokerConfig struct {
// KafkaAPI is a direct mapping to `kafka_api`. It takes precedence over
// everything else, if provided. It is recommend to instead use .KafkaListeners.
// +verbatim
KafkaAPI []map[string]any `json:"kafka_api,omitempty"`
KafkaAPI []map[string]JSONScalar `json:"kafka_api,omitempty"`
// AdvertisedKafkaAPI is a direct mapping to `advertised_kafka_api`. It
// takes precedence over everything else, if provided. It is recommend to
// instead use .KafkaListeners.
// +verbatim
AdvertisedKafkaAPI []map[string]any `json:"advertised_kafka_api,omitempty"`
AdvertisedKafkaAPI []map[string]JSONScalar `json:"advertised_kafka_api,omitempty"`
// KafkaAPITLS is a direct mapping to `kafka_api_tls`. It takes precedence
// over everything else, if provided. It is recommend to instead use
// .KafkaListeners.
// +verbatim
KafkaAPITLS []map[string]any `json:"kafka_api_tls,omitempty"`
KafkaAPITLS []map[string]JSONScalar `json:"kafka_api_tls,omitempty"`
}

// ---
Expand Down
23 changes: 15 additions & 8 deletions charts/redpanda/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Values struct {
// ---
// RedpandaYAML represents redpanda.yaml as is read by redpanda. Provide
// direct access to every field. Enhance when possible.
RedpandaYAML `json:",inline"`
// RedpandaYAML `json:",inline"`

NameOverride string `json:"nameOverride"`
FullnameOverride string `json:"fullnameOverride"`
Expand All @@ -32,8 +32,12 @@ type Values struct {
Image Image `json:"image" jsonschema:"required,description=Values used to define the container image to be used for Redpanda"`
Service *Service `json:"service"`
// ImagePullSecrets []string `json:"imagePullSecrets"`
LicenseKey string `json:"license_key" jsonschema:"deprecated,pattern=^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\\.(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$|^$"`
LicenseSecretRef LicenseSecretRef `json:"license_secret_ref" jsonschema:"deprecated"`

// +deprecated
// kubebuilder:validation:Pattern=^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\\.(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$|^$"
LicenseKey string `json:"license_key"`
// +deprecated
LicenseSecretRef LicenseSecretRef `json:"license_secret_ref"`
AuditLogging AuditLogging `json:"auditLogging"`
Enterprise Enterprise `json:"enterprise"`
RackAwareness RackAwareness `json:"rackAwareness"`
Expand Down Expand Up @@ -444,9 +448,10 @@ func (TLSCertMap) JSONSchemaExtend(schema *jsonschema.Schema) {
}

type SASLUser struct {
Name string `json:"name"`
Password string `json:"password"`
Mechanism string `json:"mechanism" jsonschema:"pattern=^(SCRAM-SHA-512|SCRAM-SHA-256)$"`
Name string `json:"name"`
Password string `json:"password"`
// +kubebuilder:validation:Pattern=^(SCRAM-SHA-512|SCRAM-SHA-256)$
Mechanism string `json:"mechanism"`
}

type SASLAuth struct {
Expand Down Expand Up @@ -615,8 +620,10 @@ type Tiered struct {
CredentialsSecretRef TieredStorageCredentials `json:"credentialsSecretRef"`
Config TieredStorageConfig `json:"config"`
HostPath string `json:"hostPath"`
MountType string `json:"mountType" jsonschema:"required,pattern=^(none|hostPath|emptyDir|persistentVolume)$"`
PersistentVolume struct {
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=^(none|hostPath|emptyDir|persistentVolume)$
MountType string `json:"mountType"`
PersistentVolume struct {
Annotations map[string]string `json:"annotations" jsonschema:"required"`
Enabled bool `json:"enabled"`
Labels map[string]string `json:"labels" jsonschema:"required"`
Expand Down
Loading

0 comments on commit 98f4525

Please sign in to comment.