001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2017 MicroBean.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
014 * implied.  See the License for the specific language governing
015 * permissions and limitations under the License.
016 */
017package org.microbean.helm.maven;
018
019import java.util.regex.Matcher;
020
021import org.apache.maven.plugins.annotations.Parameter;
022
023import org.microbean.helm.ReleaseManager;
024
025/**
026 * An {@link AbstractSingleReleaseMojo} whose implementations change
027 * the single <a href="https://docs.helm.sh/glossary/#release">Helm
028 * release</a> they are configured to work with (as opposed to just
029 * reading its information).
030 *
031 * @author <a href="https://about.me/lairdnelson"
032 * target="_parent">Laird Nelson</a>
033 */
034public abstract class AbstractMutatingReleaseMojo extends AbstractSingleReleaseMojo {
035
036
037  /*
038   * Instance fields.
039   */
040
041
042  /**
043   * Whether <a
044   * href="https://github.com/kubernetes/helm/blob/master/docs/charts_hooks.md#hooks">release
045   * hooks</a> should be disabled.
046   */
047  @Parameter(defaultValue = "false")
048  private boolean disableHooks;
049  
050  /**
051   * Whether the operation should be treated as a <em>dry
052   * run</em>&mdash;a simulation of a real operation.
053   */
054  @Parameter(defaultValue = "false", property = "helm.dryRun")
055  private boolean dryRun;
056
057  /**
058   * The timeout, in seconds, to use for Kubernetes operations; set to
059   * {@code 300} by default for parity with the {@code helm} command
060   * line program.
061   */
062  @Parameter(defaultValue = "300", property = "helm.timeout")
063  private long timeout; // in seconds
064
065  /**
066   * Whether to wait until any Pods in a release are ready.
067   */
068  @Parameter(defaultValue = "false")
069  private boolean wait;
070
071
072  /*
073   * Constructors.
074   */
075
076
077  /**
078   * Creates a new {@link AbstractMutatingReleaseMojo}.
079   */
080  protected AbstractMutatingReleaseMojo() {
081    super();
082  }
083
084
085  /*
086   * Instance methods.
087   */
088  
089
090  /**
091   * Returns {@code true} if <a
092   * href="https://github.com/kubernetes/helm/blob/master/docs/charts_hooks.md#hooks">chart
093   * hooks</a> are disabled.
094   *
095   * @return {@code true} if <a
096   * href="https://github.com/kubernetes/helm/blob/master/docs/charts_hooks.md#hooks">chart
097   * hooks</a> are disabled
098   *
099   * @see #setDisableHooks(boolean)
100   */
101  public boolean getDisableHooks() {
102    return this.disableHooks;
103  }
104
105  /**
106   * Sets whether <a
107   * href="https://github.com/kubernetes/helm/blob/master/docs/charts_hooks.md#hooks">chart
108   * hooks</a> are disabled.
109   *
110   * @param disableHooks if {@code true}, <a
111   * href="https://github.com/kubernetes/helm/blob/master/docs/charts_hooks.md#hooks">chart
112   * hooks</a> will be disabled
113   *
114   * @see #getDisableHooks()
115   */
116  public void setDisableHooks(final boolean disableHooks) {
117    this.disableHooks = disableHooks;
118  }
119
120  /**
121   * Returns whether this operation will be simulated.
122   *
123   * @return whether this operation will be simulated
124   *
125   * @see #setDryRun(boolean)
126   */
127  public boolean getDryRun() {
128    return this.dryRun;
129  }
130
131  /**
132   * Sets whether this operation will be simulated.
133   *
134   * @param dryRun if {@code true}, this operation will be simulated
135   *
136   * @see #getDryRun()
137   */
138  public void setDryRun(final boolean dryRun) {
139    this.dryRun = dryRun;
140  }
141
142  /**
143   * Returns the timeout value, in seconds, for Kubernetes operations.
144   *
145   * @return the timeout value, in seconds, for Kubernetes operations
146   *
147   * @see #setTimeout(long)
148   */
149  public long getTimeout() {
150    return this.timeout;
151  }
152
153  /**
154   * Sets the timeout value, in seconds, for Kubernetes operations.
155   *
156   * @param timeout the timeout value, in seconds, for Kubernetes
157   * operations
158   *
159   * @see #getTimeout()
160   */
161  public void setTimeout(final long timeout) {
162    this.timeout = timeout;
163  }
164
165  /**
166   * Returns {@code true} if this operation will wait for Pods to be
167   * ready before returning.
168   *
169   * @return {@code true} if this operation will wait for Pods to be
170   * ready before returning
171   *
172   * @see #setWait(boolean)
173   */
174  public boolean getWait() {
175    return this.wait;
176  }
177
178  /**
179   * Sets whether this operation will wait for Pods to be ready before
180   * returning.
181   *
182   * @param wait if {@code true}, this operation will wait for Pods to
183   * be ready before returning
184   *
185   * @see #getWait()
186   */
187  public void setWait(final boolean wait) {
188    this.wait = wait;
189  }
190  
191}