-
Notifications
You must be signed in to change notification settings - Fork 522
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
Fix #1053: Add ocHelm task to OpenShift Gradle Plugin #1072
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5541cc1
HelmMojo: Move manifest not found warning into a separate method
rohanKanojia 93d556d
Fix wrong property name in OpenShiftHelmMojo regarding openshift mani…
rohanKanojia e1030d3
Fix #1053: Add ocHelm task to OpenShift Gradle Plugin
rohanKanojia b693e5f
Remove usage of getOpenShiftManifestOrDefault from OpenShiftExtension
rohanKanojia 0fa094e
OpenShiftExtensionPropertyTest: Add test for getKubernetesTemplateOrD…
rohanKanojia 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 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 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 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 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 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
34 changes: 34 additions & 0 deletions
34
...lugin/openshift/src/main/java/org/eclipse/jkube/gradle/plugin/task/OpenShiftHelmTask.java
This file contains 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,34 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.gradle.plugin.task; | ||
|
||
import org.eclipse.jkube.gradle.plugin.OpenShiftExtension; | ||
|
||
import javax.inject.Inject; | ||
import java.io.File; | ||
|
||
public class OpenShiftHelmTask extends KubernetesHelmTask implements OpenShiftJKubeTask { | ||
|
||
@Inject | ||
public OpenShiftHelmTask(Class<? extends OpenShiftExtension> extensionClass) { | ||
super(extensionClass); | ||
setDescription( | ||
"Generates a Helm chart for the OpenShift resources."); | ||
} | ||
|
||
@Override | ||
protected void logManifestNotFoundWarning(File manifest) { | ||
kitLogger.warn("No OpenShift manifest file has been generated yet by the ocResource task at: " + manifest); | ||
} | ||
} |
This file contains 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 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 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 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
79 changes: 79 additions & 0 deletions
79
...n/openshift/src/test/java/org/eclipse/jkube/gradle/plugin/task/OpenShiftHelmTaskTest.java
This file contains 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,79 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.gradle.plugin.task; | ||
|
||
import org.eclipse.jkube.gradle.plugin.OpenShiftExtension; | ||
import org.eclipse.jkube.gradle.plugin.TestOpenShiftExtension; | ||
import org.eclipse.jkube.kit.resource.helm.HelmService; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.MockedConstruction; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.junit.Assert.assertThrows; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.mockConstruction; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class OpenShiftHelmTaskTest { | ||
@Rule | ||
public TaskEnvironment taskEnvironment = new TaskEnvironment(); | ||
|
||
private TestOpenShiftExtension extension; | ||
private MockedConstruction<HelmService> helmServiceMockedConstruction; | ||
|
||
@Before | ||
public void setUp() { | ||
extension = new TestOpenShiftExtension(); | ||
helmServiceMockedConstruction = mockConstruction(HelmService.class); | ||
when(taskEnvironment.project.getExtensions().getByType(OpenShiftExtension.class)).thenReturn(extension); | ||
} | ||
|
||
@Test | ||
public void runTask_withNoTemplateDir_shouldThrowException() { | ||
// Given | ||
OpenShiftHelmTask kubernetesHelmTask = new OpenShiftHelmTask(OpenShiftExtension.class); | ||
|
||
// When | ||
IllegalStateException illegalStateException = assertThrows(IllegalStateException.class, kubernetesHelmTask::runTask); | ||
|
||
// Then | ||
assertThat(illegalStateException) | ||
.hasMessageContaining("META-INF/jkube/openshift (No such file or directory)"); | ||
} | ||
|
||
@Test | ||
public void runTask_withTemplateDir_shouldCallHelmService() throws IOException { | ||
// Given | ||
taskEnvironment.withOpenShiftTemplate(); | ||
OpenShiftHelmTask kubernetesHelmTask = new OpenShiftHelmTask(OpenShiftExtension.class); | ||
|
||
// When | ||
kubernetesHelmTask.runTask(); | ||
|
||
// Then | ||
verify((helmServiceMockedConstruction.constructed().iterator().next()), times(1)).generateHelmCharts(any()); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
helmServiceMockedConstruction.close(); | ||
} | ||
} |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -41,3 +41,26 @@ kubernetes { | |
}] | ||
} | ||
} | ||
|
||
openshift { | ||
resources { | ||
labels { | ||
all { | ||
testProject = 'spring-boot-with-yaml-label-for-all' | ||
} | ||
} | ||
} | ||
generator { | ||
config { | ||
'spring-boot' { | ||
color = 'always' | ||
} | ||
} | ||
} | ||
helm { | ||
maintainers = [{ | ||
name = 'John' | ||
email = '[email protected]' | ||
}] | ||
} | ||
} |
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.
Add a test for this in KubernetesExtensionPropertyTest + OpenShiftExtensionPropertyTest
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.
There is a test already in KubernetesExtensionPropertyTest, I'll add the test in OpenShiftExtensionPropertyTest
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.
👍 I was checking on an outdated branch