@Test public void testFromCrdNoTopicOperatorInEntityOperator() { EntityOperatorSpec entityOperatorSpec = new EntityOperatorSpecBuilder().build(); Kafka resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)) .editSpec() .withEntityOperator(entityOperatorSpec) .endSpec() .build(); EntityTopicOperator entityTopicOperator = EntityTopicOperator.fromCrd(resource); assertThat(entityTopicOperator, is(nullValue())); }
public static EntityTopicOperator fromCrd(Kafka kafkaAssembly) { EntityTopicOperator result = null; EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator(); if (entityOperatorSpec != null) { EntityTopicOperatorSpec topicOperatorSpec = entityOperatorSpec.getTopicOperator(); if (topicOperatorSpec != null) { String namespace = kafkaAssembly.getMetadata().getNamespace(); result = new EntityTopicOperator(kafkaAssembly); result.setOwnerReference(kafkaAssembly); String image = topicOperatorSpec.getImage(); if (image == null) { image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE, "strimzi/operator:latest"); } result.setImage(image); result.setWatchedNamespace(topicOperatorSpec.getWatchedNamespace() != null ? topicOperatorSpec.getWatchedNamespace() : namespace); result.setReconciliationIntervalMs(topicOperatorSpec.getReconciliationIntervalSeconds() * 1_000); result.setZookeeperSessionTimeoutMs(topicOperatorSpec.getZookeeperSessionTimeoutSeconds() * 1_000); result.setTopicMetadataMaxAttempts(topicOperatorSpec.getTopicMetadataMaxAttempts()); result.setLogging(topicOperatorSpec.getLogging()); result.setGcLoggingEnabled(topicOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : topicOperatorSpec.getJvmOptions().isGcLoggingEnabled()); if (topicOperatorSpec.getJvmOptions() != null) { result.setJavaSystemProperties(topicOperatorSpec.getJvmOptions().getJavaSystemProperties()); } result.setJvmOptions(topicOperatorSpec.getJvmOptions()); result.setResources(topicOperatorSpec.getResources()); if (topicOperatorSpec.getReadinessProbe() != null) { result.setReadinessProbe(topicOperatorSpec.getReadinessProbe()); } if (topicOperatorSpec.getLivenessProbe() != null) { result.setLivenessProbe(topicOperatorSpec.getLivenessProbe()); } } } return result; }
EntityTopicOperator extends AbstractModel { public static EntityTopicOperator fromCrd(Kafka kafkaAssembly) { EntityTopicOperator result = null; EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator(); if (entityOperatorSpec != null) { EntityTopicOperatorSpec topicOperatorSpec = entityOperatorSpec.getTopicOperator(); if (topicOperatorSpec != null) { String namespace = kafkaAssembly.getMetadata().getNamespace(); result = new EntityTopicOperator(kafkaAssembly); result.setOwnerReference(kafkaAssembly); String image = topicOperatorSpec.getImage(); if (image == null) { image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE, "strimzi/operator:latest"); } result.setImage(image); result.setWatchedNamespace(topicOperatorSpec.getWatchedNamespace() != null ? topicOperatorSpec.getWatchedNamespace() : namespace); result.setReconciliationIntervalMs(topicOperatorSpec.getReconciliationIntervalSeconds() * 1_000); result.setZookeeperSessionTimeoutMs(topicOperatorSpec.getZookeeperSessionTimeoutSeconds() * 1_000); result.setTopicMetadataMaxAttempts(topicOperatorSpec.getTopicMetadataMaxAttempts()); result.setLogging(topicOperatorSpec.getLogging()); result.setGcLoggingEnabled(topicOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : topicOperatorSpec.getJvmOptions().isGcLoggingEnabled()); if (topicOperatorSpec.getJvmOptions() != null) { result.setJavaSystemProperties(topicOperatorSpec.getJvmOptions().getJavaSystemProperties()); } result.setJvmOptions(topicOperatorSpec.getJvmOptions()); result.setResources(topicOperatorSpec.getResources()); if (topicOperatorSpec.getReadinessProbe() != null) { result.setReadinessProbe(topicOperatorSpec.getReadinessProbe()); } if (topicOperatorSpec.getLivenessProbe() != null) { result.setLivenessProbe(topicOperatorSpec.getLivenessProbe()); } } } return result; } }
EntityTopicOperator extends AbstractModel { public static EntityTopicOperator fromCrd(Kafka kafkaAssembly) { EntityTopicOperator result = null; EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator(); if (entityOperatorSpec != null) { EntityTopicOperatorSpec topicOperatorSpec = entityOperatorSpec.getTopicOperator(); if (topicOperatorSpec != null) { String namespace = kafkaAssembly.getMetadata().getNamespace(); result = new EntityTopicOperator(kafkaAssembly); result.setOwnerReference(kafkaAssembly); String image = topicOperatorSpec.getImage(); if (image == null) { image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE, "strimzi/operator:latest"); } result.setImage(image); result.setWatchedNamespace(topicOperatorSpec.getWatchedNamespace() != null ? topicOperatorSpec.getWatchedNamespace() : namespace); result.setReconciliationIntervalMs(topicOperatorSpec.getReconciliationIntervalSeconds() * 1_000); result.setZookeeperSessionTimeoutMs(topicOperatorSpec.getZookeeperSessionTimeoutSeconds() * 1_000); result.setTopicMetadataMaxAttempts(topicOperatorSpec.getTopicMetadataMaxAttempts()); result.setLogging(topicOperatorSpec.getLogging()); result.setGcLoggingEnabled(topicOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : topicOperatorSpec.getJvmOptions().isGcLoggingEnabled()); if (topicOperatorSpec.getJvmOptions() != null) { result.setJavaSystemProperties(topicOperatorSpec.getJvmOptions().getJavaSystemProperties()); } result.setJvmOptions(topicOperatorSpec.getJvmOptions()); result.setResources(topicOperatorSpec.getResources()); if (topicOperatorSpec.getReadinessProbe() != null) { result.setReadinessProbe(topicOperatorSpec.getReadinessProbe()); } if (topicOperatorSpec.getLivenessProbe() != null) { result.setLivenessProbe(topicOperatorSpec.getLivenessProbe()); } } } return result; } protected  EntityTopicOperator(HasMetadata resource); }
EntityTopicOperator extends AbstractModel { public static EntityTopicOperator fromCrd(Kafka kafkaAssembly) { EntityTopicOperator result = null; EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator(); if (entityOperatorSpec != null) { EntityTopicOperatorSpec topicOperatorSpec = entityOperatorSpec.getTopicOperator(); if (topicOperatorSpec != null) { String namespace = kafkaAssembly.getMetadata().getNamespace(); result = new EntityTopicOperator(kafkaAssembly); result.setOwnerReference(kafkaAssembly); String image = topicOperatorSpec.getImage(); if (image == null) { image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE, "strimzi/operator:latest"); } result.setImage(image); result.setWatchedNamespace(topicOperatorSpec.getWatchedNamespace() != null ? topicOperatorSpec.getWatchedNamespace() : namespace); result.setReconciliationIntervalMs(topicOperatorSpec.getReconciliationIntervalSeconds() * 1_000); result.setZookeeperSessionTimeoutMs(topicOperatorSpec.getZookeeperSessionTimeoutSeconds() * 1_000); result.setTopicMetadataMaxAttempts(topicOperatorSpec.getTopicMetadataMaxAttempts()); result.setLogging(topicOperatorSpec.getLogging()); result.setGcLoggingEnabled(topicOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : topicOperatorSpec.getJvmOptions().isGcLoggingEnabled()); if (topicOperatorSpec.getJvmOptions() != null) { result.setJavaSystemProperties(topicOperatorSpec.getJvmOptions().getJavaSystemProperties()); } result.setJvmOptions(topicOperatorSpec.getJvmOptions()); result.setResources(topicOperatorSpec.getResources()); if (topicOperatorSpec.getReadinessProbe() != null) { result.setReadinessProbe(topicOperatorSpec.getReadinessProbe()); } if (topicOperatorSpec.getLivenessProbe() != null) { result.setLivenessProbe(topicOperatorSpec.getLivenessProbe()); } } } return result; } protected  EntityTopicOperator(HasMetadata resource); void setWatchedNamespace(String watchedNamespace); String getWatchedNamespace(); void setResourceLabels(String resourceLabels); String getResourceLabels(); void setReconciliationIntervalMs(int reconciliationIntervalMs); int getReconciliationIntervalMs(); void setZookeeperSessionTimeoutMs(int zookeeperSessionTimeoutMs); int getZookeeperSessionTimeoutMs(); void setKafkaBootstrapServers(String kafkaBootstrapServers); String getKafkaBootstrapServers(); void setTopicMetadataMaxAttempts(int topicMetadataMaxAttempts); int getTopicMetadataMaxAttempts(); void setZookeeperConnect(String zookeeperConnect); String getZookeeperConnect(); static String topicOperatorName(String cluster); static String metricAndLogConfigsName(String cluster); static String roleBindingName(String cluster); @Override String getAncillaryConfigMapKeyLogConfig(); static EntityTopicOperator fromCrd(Kafka kafkaAssembly); List<Volume> getVolumes(); RoleBinding generateRoleBinding(String namespace, String watchedNamespace); void setContainerEnvVars(List<ContainerEnvVar> envVars); void setContainerSecurityContext(SecurityContext securityContext); @Override String createLog4jProperties(OrderedProperties properties); }
EntityTopicOperator extends AbstractModel { public static EntityTopicOperator fromCrd(Kafka kafkaAssembly) { EntityTopicOperator result = null; EntityOperatorSpec entityOperatorSpec = kafkaAssembly.getSpec().getEntityOperator(); if (entityOperatorSpec != null) { EntityTopicOperatorSpec topicOperatorSpec = entityOperatorSpec.getTopicOperator(); if (topicOperatorSpec != null) { String namespace = kafkaAssembly.getMetadata().getNamespace(); result = new EntityTopicOperator(kafkaAssembly); result.setOwnerReference(kafkaAssembly); String image = topicOperatorSpec.getImage(); if (image == null) { image = System.getenv().getOrDefault(ClusterOperatorConfig.STRIMZI_DEFAULT_TOPIC_OPERATOR_IMAGE, "strimzi/operator:latest"); } result.setImage(image); result.setWatchedNamespace(topicOperatorSpec.getWatchedNamespace() != null ? topicOperatorSpec.getWatchedNamespace() : namespace); result.setReconciliationIntervalMs(topicOperatorSpec.getReconciliationIntervalSeconds() * 1_000); result.setZookeeperSessionTimeoutMs(topicOperatorSpec.getZookeeperSessionTimeoutSeconds() * 1_000); result.setTopicMetadataMaxAttempts(topicOperatorSpec.getTopicMetadataMaxAttempts()); result.setLogging(topicOperatorSpec.getLogging()); result.setGcLoggingEnabled(topicOperatorSpec.getJvmOptions() == null ? DEFAULT_JVM_GC_LOGGING_ENABLED : topicOperatorSpec.getJvmOptions().isGcLoggingEnabled()); if (topicOperatorSpec.getJvmOptions() != null) { result.setJavaSystemProperties(topicOperatorSpec.getJvmOptions().getJavaSystemProperties()); } result.setJvmOptions(topicOperatorSpec.getJvmOptions()); result.setResources(topicOperatorSpec.getResources()); if (topicOperatorSpec.getReadinessProbe() != null) { result.setReadinessProbe(topicOperatorSpec.getReadinessProbe()); } if (topicOperatorSpec.getLivenessProbe() != null) { result.setLivenessProbe(topicOperatorSpec.getLivenessProbe()); } } } return result; } protected  EntityTopicOperator(HasMetadata resource); void setWatchedNamespace(String watchedNamespace); String getWatchedNamespace(); void setResourceLabels(String resourceLabels); String getResourceLabels(); void setReconciliationIntervalMs(int reconciliationIntervalMs); int getReconciliationIntervalMs(); void setZookeeperSessionTimeoutMs(int zookeeperSessionTimeoutMs); int getZookeeperSessionTimeoutMs(); void setKafkaBootstrapServers(String kafkaBootstrapServers); String getKafkaBootstrapServers(); void setTopicMetadataMaxAttempts(int topicMetadataMaxAttempts); int getTopicMetadataMaxAttempts(); void setZookeeperConnect(String zookeeperConnect); String getZookeeperConnect(); static String topicOperatorName(String cluster); static String metricAndLogConfigsName(String cluster); static String roleBindingName(String cluster); @Override String getAncillaryConfigMapKeyLogConfig(); static EntityTopicOperator fromCrd(Kafka kafkaAssembly); List<Volume> getVolumes(); RoleBinding generateRoleBinding(String namespace, String watchedNamespace); void setContainerEnvVars(List<ContainerEnvVar> envVars); void setContainerSecurityContext(SecurityContext securityContext); @Override String createLog4jProperties(OrderedProperties properties); static final String ENV_VAR_RESOURCE_LABELS; static final String ENV_VAR_KAFKA_BOOTSTRAP_SERVERS; static final String ENV_VAR_ZOOKEEPER_CONNECT; static final String ENV_VAR_WATCHED_NAMESPACE; static final String ENV_VAR_FULL_RECONCILIATION_INTERVAL_MS; static final String ENV_VAR_ZOOKEEPER_SESSION_TIMEOUT_MS; static final String ENV_VAR_TOPIC_METADATA_MAX_ATTEMPTS; static final String ENV_VAR_TLS_ENABLED; static final Probe DEFAULT_HEALTHCHECK_OPTIONS; }