use of io.strimzi.api.kafka.model.connect.ExternalConfigurationVolumeSource in project strimzi by strimzi.
the class KafkaMirrorMaker2ClusterTest method testExternalConfigurationConfigVolumes.
@ParallelTest
public void testExternalConfigurationConfigVolumes() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my-volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my-map").build()).build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), is(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selected.get(0).getConfigMap(), is(volume.getConfigMap()));
List<VolumeMount> volumeMounths = getContainer(dep).getVolumeMounts();
List<VolumeMount> selectedVolumeMounths = volumeMounths.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selectedVolumeMounths.get(0).getName(), is(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selectedVolumeMounths.get(0).getMountPath(), is(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_MOUNT_BASE_PATH + "my-volume"));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationVolumeSource in project strimzi by strimzi.
the class KafkaConnectClusterTest method testExternalConfigurationConfigVolumesWithDots.
@ParallelTest
public void testExternalConfigurationConfigVolumesWithDots() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my.volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my.map").build()).build();
KafkaConnect resource = new KafkaConnectBuilder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaConnectCluster kc = KafkaConnectCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kc.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selected.get(0).getName(), startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selected.get(0).getConfigMap(), is(volume.getConfigMap()));
List<VolumeMount> volumeMounts = dep.getSpec().getTemplate().getSpec().getContainers().get(0).getVolumeMounts();
List<VolumeMount> selectedVolumeMounts = volumeMounts.stream().filter(vol -> vol.getName().startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(1));
assertThat(selectedVolumeMounts.get(0).getName(), startsWith(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume"));
assertThat(selectedVolumeMounts.get(0).getMountPath(), is(KafkaConnectCluster.EXTERNAL_CONFIGURATION_VOLUME_MOUNT_BASE_PATH + "my.volume"));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationVolumeSource in project strimzi by strimzi.
the class KafkaMirrorMaker2ClusterTest method testNoExternalConfigurationVolumes.
@ParallelTest
public void testNoExternalConfigurationVolumes() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my-volume").build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
List<VolumeMount> volumeMounths = getContainer(dep).getVolumeMounts();
List<VolumeMount> selectedVolumeMounths = volumeMounths.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationVolumeSource in project strimzi by strimzi.
the class KafkaConnectCluster method getExternalConfigurationVolumes.
private List<Volume> getExternalConfigurationVolumes(boolean isOpenShift) {
int mode = 0444;
if (isOpenShift) {
mode = 0440;
}
List<Volume> volumeList = new ArrayList<>(0);
for (ExternalConfigurationVolumeSource volume : externalVolumes) {
String name = volume.getName();
if (name != null) {
if (volume.getConfigMap() != null && volume.getSecret() != null) {
LOGGER.warnCr(reconciliation, "Volume {} with external Kafka Connect configuration has to contain exactly one volume source reference to either ConfigMap or Secret", name);
} else {
if (volume.getConfigMap() != null) {
ConfigMapVolumeSource source = volume.getConfigMap();
source.setDefaultMode(mode);
Volume newVol = new VolumeBuilder().withName(VolumeUtils.getValidVolumeName(EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + name)).withConfigMap(source).build();
volumeList.add(newVol);
} else if (volume.getSecret() != null) {
SecretVolumeSource source = volume.getSecret();
source.setDefaultMode(mode);
Volume newVol = new VolumeBuilder().withName(VolumeUtils.getValidVolumeName(EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + name)).withSecret(source).build();
volumeList.add(newVol);
}
}
}
}
return volumeList;
}
use of io.strimzi.api.kafka.model.connect.ExternalConfigurationVolumeSource in project strimzi by strimzi.
the class KafkaMirrorMaker2ClusterTest method testExternalConfigurationInvalidVolumes.
@ParallelTest
public void testExternalConfigurationInvalidVolumes() {
ExternalConfigurationVolumeSource volume = new ExternalConfigurationVolumeSourceBuilder().withName("my-volume").withConfigMap(new ConfigMapVolumeSourceBuilder().withName("my-map").build()).withSecret(new SecretVolumeSourceBuilder().withSecretName("my-secret").build()).build();
KafkaMirrorMaker2 resource = new KafkaMirrorMaker2Builder(this.resource).editSpec().withNewExternalConfiguration().withVolumes(volume).endExternalConfiguration().endSpec().build();
KafkaMirrorMaker2Cluster kmm2 = KafkaMirrorMaker2Cluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
// Check Deployment
Deployment dep = kmm2.generateDeployment(emptyMap(), true, null, null);
List<Volume> volumes = dep.getSpec().getTemplate().getSpec().getVolumes();
List<Volume> selected = volumes.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
List<VolumeMount> volumeMounths = getContainer(dep).getVolumeMounts();
List<VolumeMount> selectedVolumeMounths = volumeMounths.stream().filter(vol -> vol.getName().equals(KafkaMirrorMaker2Cluster.EXTERNAL_CONFIGURATION_VOLUME_NAME_PREFIX + "my-volume")).collect(Collectors.toList());
assertThat(selected.size(), is(0));
}
Aggregations