KafkaExporter extends AbstractModel { public static KafkaExporter fromCrd(Kafka kafkaAssembly, KafkaVersion.Lookup versions) { KafkaExporter kafkaExporter = new KafkaExporter(kafkaAssembly); KafkaExporterSpec spec = kafkaAssembly.getSpec().getKafkaExporter(); if (spec != null) { kafkaExporter.isDeployed = true; kafkaExporter.setResources(spec.getResources()); if (spec.getReadinessProbe() != null) { kafkaExporter.setReadinessProbe(spec.getReadinessProbe()); } if (spec.getLivenessProbe() != null) { kafkaExporter.setLivenessProbe(spec.getLivenessProbe()); } kafkaExporter.setGroupRegex(spec.getGroupRegex()); kafkaExporter.setTopicRegex(spec.getTopicRegex()); String image = spec.getImage(); if (image == null) { KafkaClusterSpec kafkaClusterSpec = kafkaAssembly.getSpec().getKafka(); image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_KAFKA_EXPORTER_IMAGE, versions.kafkaImage(kafkaClusterSpec.getImage(), versions.defaultVersion().version())); } kafkaExporter.setImage(image); kafkaExporter.setLogging(spec.getLogging()); kafkaExporter.setSaramaLoggingEnabled(spec.getEnableSaramaLogging()); if (spec.getTemplate() != null) { KafkaExporterTemplate template = spec.getTemplate(); if (template.getDeployment() != null && template.getDeployment().getMetadata() != null) { kafkaExporter.templateDeploymentLabels = template.getDeployment().getMetadata().getLabels(); kafkaExporter.templateDeploymentAnnotations = template.getDeployment().getMetadata().getAnnotations(); } if (template.getService() != null && template.getService().getMetadata() != null) { kafkaExporter.templateServiceLabels = template.getService().getMetadata().getLabels(); kafkaExporter.templateServiceAnnotations = template.getService().getMetadata().getAnnotations(); } if (template.getContainer() != null && template.getContainer().getEnv() != null) { kafkaExporter.templateContainerEnvVars = template.getContainer().getEnv(); } if (template.getContainer() != null && template.getContainer().getSecurityContext() != null) { kafkaExporter.templateContainerSecurityContext = template.getContainer().getSecurityContext(); } ModelUtils.parsePodTemplate(kafkaExporter, template.getPod()); } kafkaExporter.setVersion(versions.version(kafkaAssembly.getSpec().getKafka().getVersion()).version()); kafkaExporter.setOwnerReference(kafkaAssembly); } else { kafkaExporter.isDeployed = false; } return kafkaExporter; } protected  KafkaExporter(HasMetadata resource); static KafkaExporter fromCrd(Kafka kafkaAssembly, KafkaVersion.Lookup versions); Deployment generateDeployment(boolean isOpenShift, ImagePullPolicy imagePullPolicy, List<LocalObjectReference> imagePullSecrets); static String kafkaExporterName(String kafkaCluster); static String secretName(String kafkaCluster); static String containerServiceAccountName(String kafkaCluster); Secret generateSecret(ClusterCa clusterCa, boolean isMaintenanceTimeWindowsSatisfied); static final Probe READINESS_PROBE_OPTIONS; }
@Test public void testFromConfigMapDefaultConfig() { Kafka resource = ResourceUtils.createKafka(namespace, cluster, replicas, null, healthDelay, healthTimeout, metricsCm, kafkaConfig, zooConfig, kafkaStorage, zkStorage, kafkaLogJson, zooLogJson, new KafkaExporterSpec(), null); KafkaExporter ke = KafkaExporter.fromCrd(resource, VERSIONS); assertThat(ke.getImage(), is(KafkaVersionTestUtils.DEFAULT_KAFKA_IMAGE)); assertThat(ke.logging, is("info")); assertThat(ke.groupRegex, is(".*")); assertThat(ke.topicRegex, is(".*")); assertThat(ke.saramaLoggingEnabled, is(false)); }