use of io.strimzi.api.kafka.model.connect.ExternalConfigurationEnvBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2ClusterTest method testExternalConfigurationConfigEnvs.
@ParallelTest
public void testExternalConfigurationConfigEnvs() {
ExternalConfigurationEnv env = new ExternalConfigurationEnvBuilder().withName("MY_ENV_VAR").withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-map").withKey("my-key").withOptional(false).build()).endValueFrom().build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withEnv(env).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<EnvVar> envs = getContainer(dep).getEnv();
List<EnvVar> selected = envs.stream().filter(var -> var.getName().equals("MY_ENV_VAR")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), is("MY_ENV_VAR"));
assertThat(selected.get(0).getValueFrom().getConfigMapKeyRef(), is(env.getValueFrom().getConfigMapKeyRef()));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationEnvBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationSecretEnvs.
@ParallelTest
public void testExternalConfigurationSecretEnvs() {
ExternalConfigurationEnv env = new ExternalConfigurationEnvBuilder().withName("MY_ENV_VAR").withNewValueFrom().withSecretKeyRef(new SecretKeySelectorBuilder().withName("my-secret").withKey("my-key").withOptional(false).build()).endValueFrom().build();
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewExternalConfiguration().withEnv(env).endExternalConfiguration().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
List<EnvVar> envs = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
List<EnvVar> selected = envs.stream().filter(var -> var.getName().equals("MY_ENV_VAR")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), is("MY_ENV_VAR"));
assertThat(selected.get(0).getValueFrom().getSecretKeyRef(), is(env.getValueFrom().getSecretKeyRef()));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationEnvBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testNoExternalConfigurationEnvs.
@ParallelTest
public void testNoExternalConfigurationEnvs() {
ExternalConfigurationEnv env = new ExternalConfigurationEnvBuilder().withName("MY_ENV_VAR").withNewValueFrom().endValueFrom().build();
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewExternalConfiguration().withEnv(env).endExternalConfiguration().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
List<EnvVar> envs = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
List<EnvVar> selected = envs.stream().filter(var -> var.getName().equals("MY_ENV_VAR")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationEnvBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationConfigEnvs.
@ParallelTest
public void testExternalConfigurationConfigEnvs() {
ExternalConfigurationEnv env = new ExternalConfigurationEnvBuilder().withName("MY_ENV_VAR").withNewValueFrom().withConfigMapKeyRef(new ConfigMapKeySelectorBuilder().withName("my-map").withKey("my-key").withOptional(false).build()).endValueFrom().build();
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewExternalConfiguration().withEnv(env).endExternalConfiguration().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
List<EnvVar> envs = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
List<EnvVar> selected = envs.stream().filter(var -> var.getName().equals("MY_ENV_VAR")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), is("MY_ENV_VAR"));
assertThat(selected.get(0).getValueFrom().getConfigMapKeyRef(), is(env.getValueFrom().getConfigMapKeyRef()));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationEnvBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2ClusterTest method testNoExternalConfigurationEnvs.
@ParallelTest
public void testNoExternalConfigurationEnvs() {
ExternalConfigurationEnv env = new ExternalConfigurationEnvBuilder().withName("MY_ENV_VAR").withNewValueFrom().endValueFrom().build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withEnv(env).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<EnvVar> envs = getContainer(dep).getEnv();
List<EnvVar> selected = envs.stream().filter(var -> var.getName().equals("MY_ENV_VAR")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
}
Aggregations