Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OneOf constraint to Connect external configuration #10560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading