-
Notifications
You must be signed in to change notification settings - Fork 550
Introduce AbstractHelmMojo class #2714
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * 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.maven.plugin.mojo.build; | ||
|
|
||
| import static org.eclipse.jkube.kit.resource.helm.HelmServiceUtil.initHelmConfig; | ||
|
|
||
| import java.io.File; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.maven.plugin.MojoFailureException; | ||
| import org.apache.maven.plugins.annotations.Parameter; | ||
| import org.eclipse.jkube.kit.resource.helm.HelmConfig; | ||
|
|
||
| public abstract class AbstractHelmMojo extends AbstractJKubeMojo { | ||
|
|
||
| /** | ||
| * One of: | ||
| * <ul> | ||
| * <li>A directory containing OpenShift Templates to use as Helm parameters.</li> | ||
| * <li>A file containing a Kubernetes List with OpenShift Template entries to be used as Helm parameters.</li> | ||
| * </ul> | ||
| */ | ||
| @Parameter(property = "jkube.kubernetesTemplate", defaultValue = "${basedir}/target/classes/META-INF/jkube/kubernetes") | ||
| File kubernetesTemplate; | ||
|
|
||
| @Parameter | ||
| HelmConfig helm; | ||
|
|
||
| @Override | ||
| public void init() throws MojoFailureException { | ||
| super.init(); | ||
|
|
||
| try { | ||
| helm = initHelmConfig(getDefaultHelmType(), javaProject, getKubernetesTemplate(), helm).build(); | ||
| } catch (IOException e) { | ||
| throw new MojoFailureException(e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
| protected File getKubernetesTemplate() { | ||
| return kubernetesTemplate; | ||
| } | ||
|
|
||
| protected HelmConfig.HelmType getDefaultHelmType() { | ||
| return HelmConfig.HelmType.KUBERNETES; | ||
| } | ||
|
|
||
| protected HelmConfig getHelm() { | ||
| return helm; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,29 +18,22 @@ | |
| import org.apache.maven.plugins.annotations.Parameter; | ||
| import org.apache.maven.plugins.annotations.ResolutionScope; | ||
| import org.eclipse.jkube.kit.resource.helm.HelmConfig; | ||
| import org.eclipse.jkube.maven.plugin.mojo.OpenShift; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| @Mojo(name = "helm-lint", defaultPhase = LifecyclePhase.INTEGRATION_TEST, requiresDependencyResolution = ResolutionScope.COMPILE) | ||
| public class OpenshiftHelmLintMojo extends HelmLintMojo { | ||
|
|
||
| /** | ||
| * The generated kubernetes YAML file | ||
| * One of: | ||
| * <ul> | ||
| * <li>A directory containing OpenShift Templates to use as Helm parameters.</li> | ||
| * <li>A file containing a Kubernetes List with OpenShift Template entries to be used as Helm parameters.</li> | ||
| * </ul> | ||
| */ | ||
| @Parameter(property = "jkube.kubernetesManifest", defaultValue = "${basedir}/target/classes/META-INF/jkube/openshift.yml") | ||
| private File openShiftManifest; | ||
|
|
||
| /** | ||
| * The generated kubernetes YAML file | ||
| */ | ||
| @Parameter(property = "jkube.kubernetesManifest", defaultValue = "${basedir}/target/classes/META-INF/jkube/openshift") | ||
Jurrie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Parameter(property = "jkube.openshiftTemplate", defaultValue = "${basedir}/target/classes/META-INF/jkube/openshift") | ||
| private File openShiftTemplate; | ||
|
|
||
| @Override | ||
| protected File getKubernetesManifest() { | ||
| return openShiftManifest; | ||
| } | ||
|
|
||
| @Override | ||
| protected File getKubernetesTemplate() { | ||
|
|
@@ -51,9 +44,4 @@ protected File getKubernetesTemplate() { | |
| protected HelmConfig.HelmType getDefaultHelmType() { | ||
| return HelmConfig.HelmType.OPENSHIFT; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getLogPrefix() { | ||
| return OpenShift.DEFAULT_LOG_PREFIX; | ||
| } | ||
|
Member
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. The OpenShift overrides are required to preserve the OpenShift-specific behavior (in this case the logged statements should be prefixed with
Contributor
Author
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. Ah, I missed that this reads
Contributor
Author
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. As for the other apparently redundant overrides: I feel that they are actually redundant. (#2714 (comment) for example.) But of course I might be wrong 😀
Member
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. Basically there are 4 things to override for the OpenShift Helm experience.
As for the last two, I assume they were introduced to be able to override the default value of the parameter. The only one redundant or unnecessary for the Helm Push mojo is the one for the kubernetesManifest, which is used for the warning log. (As a user, I want to get warned if I run the helm goal without having run the resource goal before, so that I'm aware of my misconfiguration). However, this warning should also apply for the Lint mojo. The new
Contributor
Author
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 holds for all OpenShift Helm classes that are changed, so for:
Let's be methodical and list per method-to-be-overridden here: getKubernetesManifest()
The The Kubernetes manifest property is only used in getKubernetesTemplate()
getDefaultHelmType()
getLogPrefix()
Member
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 sounds about right.
This is necessary for those goals that depend on the resources. So only for the initial HelmMojo. However, for the others, it'd be nice to have a similar warning reminding user to run the helm goal first (follow-up PR), the Gradle task behavior should be aligned too (follow-up PR 2). |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.