exceptionfactory commented on code in PR #8240:
URL: https://github.com/apache/nifi/pull/8240#discussion_r1454177876
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-kubernetes-bundle/nifi-framework-kubernetes-state-provider/src/main/java/org/apache/nifi/kubernetes/state/provider/KubernetesConfigMapStateProvider.java:
##########
@@ -99,6 +118,12 @@ public void initialize(final
StateProviderInitializationContext context) {
this.logger = context.getLogger();
this.kubernetesClient = getKubernetesClient();
this.namespace = new ServiceAccountNamespaceProvider().getNamespace();
+
+ String configMapNamePrefix =
context.getProperty(CONFIG_MAP_NAME_PREFIX).isSet() ?
context.getProperty(CONFIG_MAP_NAME_PREFIX).getValue() : null;
+ CONFIG_MAP_NAME_FORMAT = configMapNamePrefix != null
+ ? String.format("%s-%s-%%s", configMapNamePrefix,
CONFIG_MAP_CORE_NAME) : String.format("%s-%%s", CONFIG_MAP_CORE_NAME);
+ CONFIG_MAP_NAME_PATTERN = Pattern.compile(configMapNamePrefix != null
+ ? String.format("^%s-%s-(.+)$", configMapNamePrefix,
CONFIG_MAP_CORE_NAME) : String.format("^%s-(.+)$", CONFIG_MAP_CORE_NAME));
Review Comment:
There is still a bit of repetition here that would be helpful to streamline,
given the importance of proper formatting. The ternary expression is also
difficult to read. I recommend the `PATTERN_FORMAT` as a static value with
`^%snifi-component-(.+)$` and then supplying either an empty string, or the
configured prefix to build the final Pattern. Declaring the intermediate values
could also make this more readable.
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml:
##########
@@ -269,6 +269,9 @@
<nifi.python.max.processes>100</nifi.python.max.processes>
<nifi.python.max.processes.per.extension.type>10</nifi.python.max.processes.per.extension.type>
<nifi.python.logs.dir>./logs</nifi.python.logs.dir>
+
+ <!-- nifi.properties: kubernetes properties -->
Review Comment:
The comment can be removed as it does not provide additional information.
```suggestion
```
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-kubernetes-bundle/nifi-framework-kubernetes-state-provider/src/main/java/org/apache/nifi/kubernetes/state/provider/KubernetesConfigMapStateProvider.java:
##########
@@ -70,6 +78,10 @@ public class KubernetesConfigMapStateProvider extends
AbstractConfigurableCompon
private final AtomicBoolean enabled = new AtomicBoolean();
+ private String CONFIG_MAP_NAME_FORMAT;
+
+ private Pattern CONFIG_MAP_NAME_PATTERN;
Review Comment:
These should be changed reflect that they are member variables.
```suggestion
private String configMapNameFormat;
private Pattern configMapNamePattern;
```
##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-kubernetes-bundle/nifi-framework-kubernetes-state-provider/pom.xml:
##########
@@ -48,5 +48,10 @@
<artifactId>kubernetes-server-mock</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-expression-language</artifactId>
Review Comment:
Is this dependency required?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]