-
Notifications
You must be signed in to change notification settings - Fork 3k
NIFI-16076: Context path support for NiFi Registry Flow Registry Clie… #11393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PNAC03
wants to merge
1
commit into
apache:main
Choose a base branch
from
PNAC03:context-path-2.10.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...vices/src/test/java/org/apache/nifi/registry/flow/TestNifiRegistryFlowRegistryClient.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.nifi.registry.flow; | ||
|
|
||
| import org.apache.nifi.components.PropertyValue; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.lang.reflect.Method; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| public class TestNifiRegistryFlowRegistryClient { | ||
|
|
||
| @Test | ||
| public void testGetProposedUri() throws Exception { | ||
| final NifiRegistryFlowRegistryClient client = new NifiRegistryFlowRegistryClient(); | ||
| final FlowRegistryClientConfigurationContext context = mock(FlowRegistryClientConfigurationContext.class); | ||
| final PropertyValue propertyValue = mock(PropertyValue.class); | ||
|
|
||
| // Test with root context | ||
| when(context.getProperty(NifiRegistryFlowRegistryClient.PROPERTY_URL)).thenReturn(propertyValue); | ||
| when(propertyValue.evaluateAttributeExpressions()).thenReturn(propertyValue); | ||
| when(propertyValue.getValue()).thenReturn("https://localhost:18443"); | ||
|
|
||
| // Access private method via reflection | ||
| Method getProposedUri = NifiRegistryFlowRegistryClient.class.getDeclaredMethod("getProposedUri", FlowRegistryClientConfigurationContext.class); | ||
| getProposedUri.setAccessible(true); | ||
| String uri = (String) getProposedUri.invoke(client, context); | ||
|
|
||
| assertEquals("https://localhost:18443", uri); | ||
|
|
||
| // Test with custom context path | ||
| when(propertyValue.getValue()).thenReturn("https://localhost:18443/my-registry"); | ||
| uri = (String) getProposedUri.invoke(client, context); | ||
|
|
||
| // Before fix, this returns "https://localhost:18443" (stripped path) | ||
| // We assert expected behavior (preserving path) to confirm failure | ||
| assertEquals("https://localhost:18443/my-registry", uri); | ||
|
|
||
| // Test with trailing slash | ||
| when(propertyValue.getValue()).thenReturn("https://localhost:18443/my-registry/"); | ||
| uri = (String) getProposedUri.invoke(client, context); | ||
| // URI.create(s).toString() normalizes? No, URI toString returns as is usually, | ||
| // but the method constructs a new URI. | ||
| // The current implementation reconstructs URI from scheme, host, port. | ||
| // My proposed fix will append path. | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ | |
| import io.fabric8.kubernetes.client.KubernetesClient; | ||
| import io.fabric8.kubernetes.client.KubernetesClientException; | ||
| import io.fabric8.kubernetes.client.dsl.Resource; | ||
| import org.apache.nifi.annotation.documentation.CapabilityDescription; | ||
| import org.apache.nifi.annotation.documentation.Tags; | ||
| import org.apache.nifi.components.AbstractConfigurableComponent; | ||
| import org.apache.nifi.components.PropertyDescriptor; | ||
| import org.apache.nifi.components.PropertyValue; | ||
|
|
@@ -54,6 +56,10 @@ | |
| /** | ||
| * State Provider implementation based on Kubernetes ConfigMaps with Base64 encoded keys to meet Kubernetes constraints | ||
| */ | ||
| @Tags({"kubernetes", "state", "provider", "configmap", "cluster"}) | ||
| @CapabilityDescription("Provides a State Provider that stores state in a Kubernetes ConfigMap. " | ||
| + "This allows state to be shared across a Kubernetes cluster. " | ||
| + "The State Provider uses the Kubernetes Client to read and write ConfigMaps.") | ||
|
Comment on lines
+59
to
+62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is unrelated and should be reverted |
||
| public class KubernetesConfigMapStateProvider extends AbstractConfigurableComponent implements StateProvider { | ||
| static final PropertyDescriptor CONFIG_MAP_NAME_PREFIX = new PropertyDescriptor.Builder() | ||
| .name("ConfigMap Name Prefix") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../test/java/org/apache/nifi/registry/properties/TestNiFiRegistryPropertiesContextPath.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.nifi.registry.properties; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
|
||
| public class TestNiFiRegistryPropertiesContextPath { | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathNotSet() { | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertNotNull(contextPath); | ||
| assertEquals("", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathWithLeadingSlash() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, "/integration-hub"); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("/integration-hub", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathWithoutLeadingSlash() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, "integration-hub"); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("/integration-hub", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathWithTrailingSlash() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, "/integration-hub/"); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("/integration-hub", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathWithBothSlashes() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, "integration-hub/"); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("/integration-hub", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathWithWhitespace() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, " /integration-hub "); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("/integration-hub", contextPath); | ||
| } | ||
|
|
||
| @Test | ||
| public void testGetWebContextPathEmptyString() { | ||
| final Map<String, String> props = new HashMap<>(); | ||
| props.put(NiFiRegistryProperties.WEB_CONTEXT_PATH, ""); | ||
| final NiFiRegistryProperties properties = new NiFiRegistryProperties(props); | ||
| final String contextPath = properties.getWebContextPath(); | ||
| assertEquals("", contextPath); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| Build the NiFi Source First, you need to compile the source code you just patched so that it generates those .zip files. From the root (C:\MyData\Test\nifi-2.4.0-source-release\original-repo\nifi), run: | ||
|
|
||
| Run - mvn clean install -DskipTests | ||
| (Note: This might take ~10-15 minutes since NiFi is huge. It will create nifi-assembly/target/nifi-2.4.0-bin.zip and nifi-toolkit/nifi-toolkit-assembly/target/nifi-toolkit-2.4.0-bin.zip) | ||
|
|
||
| Move the Zips to your Docker folder Copy those two generated .zip files into your nifi-docker/dockerhub/ folder so Docker can see them. | ||
|
|
||
| docker build -f Dockerfile-local -t nifi:2.4.0-custom . |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated and should be reverted.