Skip to content

Commit

Permalink
Add OneOf constraint to Connect external configuration (strimzi#10560)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj authored Sep 10, 2024
1 parent e5a7bc6 commit 8e30be3
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.strimzi.api.kafka.model.common.UnknownPropertyPreserving;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.strimzi.crdgenerator.annotations.OneOf;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -28,15 +29,14 @@
)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonPropertyOrder({"secretKeyRef", "configMapKeyRef"})
@OneOf({@OneOf.Alternative(@OneOf.Alternative.Property("secretKeyRef")), @OneOf.Alternative(@OneOf.Alternative.Property("configMapKeyRef"))})
@EqualsAndHashCode
@ToString
public class ExternalConfigurationEnvVarSource implements UnknownPropertyPreserving {
private SecretKeySelector secretKeyRef;
private ConfigMapKeySelector configMapKeyRef;
private Map<String, Object> additionalProperties;

// TODO: We should make it possible to generate a CRD configuring that exactly one of secretKeyRef and configMapKeyRef has to be defined.

@Description("Reference to a key in a Secret.")
@KubeLink(group = "core", version = "v1", kind = "secretkeyselector")
@JsonInclude(value = JsonInclude.Include.NON_NULL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.strimzi.api.kafka.model.common.UnknownPropertyPreserving;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.strimzi.crdgenerator.annotations.OneOf;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -29,6 +30,7 @@
)
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@JsonPropertyOrder({"name", "secret", "configMap"})
@OneOf({@OneOf.Alternative(@OneOf.Alternative.Property("secret")), @OneOf.Alternative(@OneOf.Alternative.Property("configMap"))})
@EqualsAndHashCode
@ToString
public class ExternalConfigurationVolumeSource implements UnknownPropertyPreserving {
Expand All @@ -47,8 +49,6 @@ public void setName(String name) {
this.name = name;
}

// TODO: We should make it possible to generate a CRD configuring that exactly one of secret and configMap has to be defined.

@Description("Reference to a key in a Secret. " +
"Exactly one Secret or ConfigMap has to be specified.")
@KubeLink(group = "core", version = "v1", kind = "secretvolumesource")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap.
oneOf:
- properties:
secretKeyRef: {}
required:
- secretKeyRef
- properties:
configMapKeyRef: {}
required:
- configMapKeyRef
description: Value of the environment variable which will be passed to the Kafka Connect pods. It can be passed either as a reference to Secret or ConfigMap field. The field has to specify exactly one Secret or ConfigMap.
required:
- name
Expand Down Expand Up @@ -2268,6 +2277,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap. Exactly one Secret or ConfigMap has to be specified.
oneOf:
- properties:
secret: {}
required:
- secret
- properties:
configMap: {}
required:
- configMap
required:
- name
description: Makes data from a Secret or ConfigMap available in the Kafka Connect pods as volumes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2358,6 +2358,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap.
oneOf:
- properties:
secretKeyRef: {}
required:
- secretKeyRef
- properties:
configMapKeyRef: {}
required:
- configMapKeyRef
description: Value of the environment variable which will be passed to the Kafka Connect pods. It can be passed either as a reference to Secret or ConfigMap field. The field has to specify exactly one Secret or ConfigMap.
required:
- name
Expand Down Expand Up @@ -2413,6 +2422,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap. Exactly one Secret or ConfigMap has to be specified.
oneOf:
- properties:
secret: {}
required:
- secret
- properties:
configMap: {}
required:
- configMap
required:
- name
description: Makes data from a Secret or ConfigMap available in the Kafka Connect pods as volumes.
Expand Down
18 changes: 18 additions & 0 deletions packaging/install/cluster-operator/041-Crd-kafkaconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap.
oneOf:
- properties:
secretKeyRef: {}
required:
- secretKeyRef
- properties:
configMapKeyRef: {}
required:
- configMapKeyRef
description: Value of the environment variable which will be passed to the Kafka Connect pods. It can be passed either as a reference to Secret or ConfigMap field. The field has to specify exactly one Secret or ConfigMap.
required:
- name
Expand Down Expand Up @@ -2267,6 +2276,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap. Exactly one Secret or ConfigMap has to be specified.
oneOf:
- properties:
secret: {}
required:
- secret
- properties:
configMap: {}
required:
- configMap
required:
- name
description: Makes data from a Secret or ConfigMap available in the Kafka Connect pods as volumes.
Expand Down
18 changes: 18 additions & 0 deletions packaging/install/cluster-operator/048-Crd-kafkamirrormaker2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap.
oneOf:
- properties:
secretKeyRef: {}
required:
- secretKeyRef
- properties:
configMapKeyRef: {}
required:
- configMapKeyRef
description: Value of the environment variable which will be passed to the Kafka Connect pods. It can be passed either as a reference to Secret or ConfigMap field. The field has to specify exactly one Secret or ConfigMap.
required:
- name
Expand Down Expand Up @@ -2412,6 +2421,15 @@ spec:
optional:
type: boolean
description: Reference to a key in a ConfigMap. Exactly one Secret or ConfigMap has to be specified.
oneOf:
- properties:
secret: {}
required:
- secret
- properties:
configMap: {}
required:
- configMap
required:
- name
description: Makes data from a Secret or ConfigMap available in the Kafka Connect pods as volumes.
Expand Down

0 comments on commit 8e30be3

Please sign in to comment.