From 065b54454d12fc65228e116fb0b7302a7cc02618 Mon Sep 17 00:00:00 2001 From: "mykyta.oleksiienko" Date: Thu, 7 Dec 2023 15:17:51 +0200 Subject: [PATCH] issue-613, default cluster name --- apis/clusters/v1beta1/cadence_webhook.go | 4 ++++ apis/clusters/v1beta1/cassandra_webhook.go | 4 ++++ apis/clusters/v1beta1/kafka_webhook.go | 4 ++++ apis/clusters/v1beta1/kafkaconnect_webhook.go | 4 ++++ apis/clusters/v1beta1/opensearch_webhook.go | 4 ++++ apis/clusters/v1beta1/postgresql_webhook.go | 4 ++++ apis/clusters/v1beta1/redis_webhook.go | 4 ++++ apis/clusters/v1beta1/zookeeper_webhook.go | 4 ++++ doc/clusters/cadence.md | 3 +++ doc/clusters/cassandra.md | 3 +++ doc/clusters/kafka-connect.md | 3 +++ doc/clusters/kafka.md | 3 +++ doc/clusters/opensearch.md | 4 ++++ doc/clusters/postgresql.md | 3 +++ doc/clusters/redis.md | 3 +++ doc/clusters/zookeeper.md | 3 +++ 16 files changed, 57 insertions(+) diff --git a/apis/clusters/v1beta1/cadence_webhook.go b/apis/clusters/v1beta1/cadence_webhook.go index f7fe05572..bae85db9f 100644 --- a/apis/clusters/v1beta1/cadence_webhook.go +++ b/apis/clusters/v1beta1/cadence_webhook.go @@ -51,6 +51,10 @@ var _ webhook.Defaulter = &Cadence{} func (c *Cadence) Default() { cadencelog.Info("default", "name", c.Name) + if c.Spec.Name == "" { + c.Spec.Name = c.Name + } + if c.GetAnnotations() == nil { c.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/cassandra_webhook.go b/apis/clusters/v1beta1/cassandra_webhook.go index 7869df417..18ae6393b 100644 --- a/apis/clusters/v1beta1/cassandra_webhook.go +++ b/apis/clusters/v1beta1/cassandra_webhook.go @@ -54,6 +54,10 @@ var _ webhook.Defaulter = &Cassandra{} func (c *Cassandra) Default() { cassandralog.Info("default", "name", c.Name) + if c.Spec.Name == "" { + c.Spec.Name = c.Name + } + if c.GetAnnotations() == nil { c.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/kafka_webhook.go b/apis/clusters/v1beta1/kafka_webhook.go index 47971e2ab..74fbd508e 100644 --- a/apis/clusters/v1beta1/kafka_webhook.go +++ b/apis/clusters/v1beta1/kafka_webhook.go @@ -51,6 +51,10 @@ var _ webhook.Defaulter = &Kafka{} func (k *Kafka) Default() { kafkalog.Info("default", "name", k.Name) + if k.Spec.Name == "" { + k.Spec.Name = k.Name + } + if k.GetAnnotations() == nil { k.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/kafkaconnect_webhook.go b/apis/clusters/v1beta1/kafkaconnect_webhook.go index c239c54e9..fd7f7180d 100644 --- a/apis/clusters/v1beta1/kafkaconnect_webhook.go +++ b/apis/clusters/v1beta1/kafkaconnect_webhook.go @@ -52,6 +52,10 @@ var _ webhook.Defaulter = &KafkaConnect{} func (r *KafkaConnect) Default() { kafkaconnectlog.Info("default", "name", r.Name) + if r.Spec.Name == "" { + r.Spec.Name = r.Name + } + if r.GetAnnotations() == nil { r.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/opensearch_webhook.go b/apis/clusters/v1beta1/opensearch_webhook.go index 41c52dab0..e6893511e 100644 --- a/apis/clusters/v1beta1/opensearch_webhook.go +++ b/apis/clusters/v1beta1/opensearch_webhook.go @@ -67,6 +67,10 @@ func (os *OpenSearch) Default() { } opensearchlog.Info("default values are set", "name", os.Name) + + if os.Spec.Name == "" { + os.Spec.Name = os.Name + } } func setDefaultValues(dc *OpenSearchDataCentre) { diff --git a/apis/clusters/v1beta1/postgresql_webhook.go b/apis/clusters/v1beta1/postgresql_webhook.go index 51f567063..733fe5866 100644 --- a/apis/clusters/v1beta1/postgresql_webhook.go +++ b/apis/clusters/v1beta1/postgresql_webhook.go @@ -58,6 +58,10 @@ var _ webhook.Defaulter = &PostgreSQL{} func (pg *PostgreSQL) Default() { postgresqllog.Info("default", "name", pg.Name) + if pg.Spec.Name == "" { + pg.Spec.Name = pg.Name + } + if pg.GetAnnotations() == nil { pg.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/redis_webhook.go b/apis/clusters/v1beta1/redis_webhook.go index 09c48b48e..e9e902376 100644 --- a/apis/clusters/v1beta1/redis_webhook.go +++ b/apis/clusters/v1beta1/redis_webhook.go @@ -51,6 +51,10 @@ var _ webhook.Defaulter = &Redis{} func (r *Redis) Default() { redislog.Info("default", "name", r.Name) + if r.Spec.Name == "" { + r.Spec.Name = r.Name + } + if r.GetAnnotations() == nil { r.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/apis/clusters/v1beta1/zookeeper_webhook.go b/apis/clusters/v1beta1/zookeeper_webhook.go index c7d9d097b..e4c104ec1 100644 --- a/apis/clusters/v1beta1/zookeeper_webhook.go +++ b/apis/clusters/v1beta1/zookeeper_webhook.go @@ -51,6 +51,10 @@ var _ webhook.Defaulter = &Zookeeper{} func (z *Zookeeper) Default() { redislog.Info("default", "name", z.Name) + if z.Spec.Name == "" { + z.Spec.Name = z.Name + } + if z.GetAnnotations() == nil { z.SetAnnotations(map[string]string{ models.ResourceStateAnnotation: "", diff --git a/doc/clusters/cadence.md b/doc/clusters/cadence.md index b0fb66f75..e4b35920e 100644 --- a/doc/clusters/cadence.md +++ b/doc/clusters/cadence.md @@ -148,6 +148,9 @@ ## Cluster create flow To create a Cadence cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # cadence.yaml apiVersion: clusters.instaclustr.com/v1beta1 diff --git a/doc/clusters/cassandra.md b/doc/clusters/cassandra.md index 39094bebc..83a269db5 100644 --- a/doc/clusters/cassandra.md +++ b/doc/clusters/cassandra.md @@ -94,6 +94,9 @@ ## Cluster create flow To create a Cassandra cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # cassandra.yaml apiVersion: clusters.instaclustr.com/v1beta1 diff --git a/doc/clusters/kafka-connect.md b/doc/clusters/kafka-connect.md index faf9d11c5..b06b58459 100644 --- a/doc/clusters/kafka-connect.md +++ b/doc/clusters/kafka-connect.md @@ -100,6 +100,9 @@ ## Cluster create flow To create a Kafka Connect cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # kafkaconnect.yaml diff --git a/doc/clusters/kafka.md b/doc/clusters/kafka.md index fbe25690f..836ac862a 100644 --- a/doc/clusters/kafka.md +++ b/doc/clusters/kafka.md @@ -102,6 +102,9 @@ ## Cluster create flow To create a Kafka cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml kafka.yaml apiVersion: clusters.instaclustr.com/v1beta1 diff --git a/doc/clusters/opensearch.md b/doc/clusters/opensearch.md index e5dfc1c20..fbccf4006 100644 --- a/doc/clusters/opensearch.md +++ b/doc/clusters/opensearch.md @@ -106,6 +106,10 @@ ## Cluster creation example To create a cluster you need to prepare a cluster manifest. Here is an example: + +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # opensearch.yaml file apiVersion: clusters.instaclustr.com/v1beta1 diff --git a/doc/clusters/postgresql.md b/doc/clusters/postgresql.md index 608a329d6..21ec533b2 100644 --- a/doc/clusters/postgresql.md +++ b/doc/clusters/postgresql.md @@ -94,6 +94,9 @@ ## Cluster creation example +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + To create a cluster you need to prepare a cluster manifest. Here is an example: ```yaml # postgresql.yaml file diff --git a/doc/clusters/redis.md b/doc/clusters/redis.md index ce9b23dea..66fa5c7f0 100644 --- a/doc/clusters/redis.md +++ b/doc/clusters/redis.md @@ -79,6 +79,9 @@ ## Cluster create flow To create a Redis cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # redis.yaml apiVersion: clusters.instaclustr.com/v1beta1 diff --git a/doc/clusters/zookeeper.md b/doc/clusters/zookeeper.md index 38e0e96c9..7f89d0e41 100644 --- a/doc/clusters/zookeeper.md +++ b/doc/clusters/zookeeper.md @@ -44,6 +44,9 @@ ## Cluster create flow To create a Zookeeper cluster instance you need to prepare the yaml manifest. Here is an example: +Notice: +- If you choose to omit the cluster name in the specification, the operator will use it from the metadata name instead. In this case make sure that metadata name matches the name pattern, you can check the pattern on instaclustr API specification + ```yaml # zookeeper.yaml apiVersion: clusters.instaclustr.com/v1beta1