Skip to content
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

[JENKINS-57828] Cleaning up the Snippet Generator output for PodTemplateStep #703

Merged
merged 30 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c4f1c5
[CPLT2-6206][JENKINS-57828] Cleaning up the Snippet Generator output …
kerogers-cloudbees Feb 6, 2020
79e7062
[CPLT2-6206][JENKINS-57828] Accidentally left commented out code in a…
kerogers-cloudbees Feb 7, 2020
62e6056
Missed a brace that was in the comment.
kerogers-cloudbees Feb 7, 2020
f83ee33
Update src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline…
kerogers-cloudbees Feb 7, 2020
13820a7
[CPLT2-6206][JENKINS-57828] Updates from code review
kerogers-cloudbees Feb 7, 2020
67884c3
Merge branch 'podTemplate-snippet-jenkins-57828-cplt2-6206' of github…
kerogers-cloudbees Feb 7, 2020
511a7c1
Fix unit test to use corrected defaults.
kerogers-cloudbees Feb 7, 2020
984d409
add dependency with classifier for tests.
kerogers-cloudbees Feb 7, 2020
4f57e22
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Feb 12, 2020
14886ef
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Feb 13, 2020
924d0a0
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Feb 13, 2020
0e8ea09
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Feb 17, 2020
934a27c
[CPLT2-6206] Changing PodTemplateStep to have a default value for ins…
kerogers-cloudbees Feb 17, 2020
a17439a
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Feb 18, 2020
4b01002
Fix merge
Vlatombe Feb 18, 2020
9082ddd
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
kerogers-cloudbees Feb 25, 2020
4504773
[CPLT2-6206] special case for inheritFrom to allow KubernetesPipeline…
kerogers-cloudbees Feb 28, 2020
1662c1e
[CPLT2-6206] Change the special string to ",default," as it doesn't r…
kerogers-cloudbees Mar 3, 2020
febb56f
[CPLT2-6206] Explain behavior of inheritFrom in the help text.
kerogers-cloudbees Mar 4, 2020
6d2fd30
[CPLT2-6206] Changed the string to <noInherit> to reduce the confusio…
kerogers-cloudbees Mar 6, 2020
7309343
[CPLT2-6206] restored empty string to be no inheritance and null to b…
kerogers-cloudbees Mar 9, 2020
b36413b
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
Vlatombe Mar 9, 2020
60442ae
Merge branch 'master' into podTemplate-snippet-jenkins-57828-cplt2-6206
kerogers-cloudbees Mar 11, 2020
cceb7ee
Merge branch 'podTemplate-snippet-jenkins-57828-cplt2-6206' of github…
kerogers-cloudbees Mar 11, 2020
4254f2c
Update src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline…
kerogers-cloudbees Mar 11, 2020
e346b9f
Update src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline…
kerogers-cloudbees Mar 11, 2020
4774681
Update src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline…
kerogers-cloudbees Mar 11, 2020
03debcc
Update src/main/webapp/help/inheritFrom.html
kerogers-cloudbees Mar 11, 2020
529e89b
[CPLT2-6206] Clean up imports, fix a missing dot.
kerogers-cloudbees Mar 12, 2020
877a145
[CPLT2-6206] Remove the checkbox that was hiding the WorkspaceVolume …
kerogers-cloudbees Mar 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<classifier>tests</classifier>
kerogers-cloudbees marked this conversation as resolved.
Show resolved Hide resolved
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import org.csanchez.jenkins.plugins.kubernetes.PodAnnotation;
import org.csanchez.jenkins.plugins.kubernetes.PodTemplate;
import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar;
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.Always;
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention;
import org.csanchez.jenkins.plugins.kubernetes.pod.yaml.YamlMergeStrategy;
import org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume;
import org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.DynamicPVCWorkspaceVolume;
import org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.WorkspaceVolume;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.steps.StepContext;
Expand All @@ -36,40 +38,77 @@ public class PodTemplateStep extends Step implements Serializable {

private static final String DEFAULT_CLOUD = "kubernetes";

@CheckForNull
private String cloud = DEFAULT_CLOUD;

@CheckForNull
private String inheritFrom;

@CheckForNull
private String label;

@CheckForNull
private String name;

@CheckForNull
private String namespace;

@CheckForNull
jglick marked this conversation as resolved.
Show resolved Hide resolved
private List<ContainerTemplate> containers = new ArrayList<>();

@CheckForNull
private List<TemplateEnvVar> envVars = new ArrayList<>();

@CheckForNull
jglick marked this conversation as resolved.
Show resolved Hide resolved
private List<PodVolume> volumes = new ArrayList<PodVolume>();

@CheckForNull
private WorkspaceVolume workspaceVolume;

@CheckForNull
private List<PodAnnotation> annotations = new ArrayList<>();

@CheckForNull
private List<String> imagePullSecrets = new ArrayList<>();

private int instanceCap = Integer.MAX_VALUE;
private int instanceCap;
jglick marked this conversation as resolved.
Show resolved Hide resolved
private int idleMinutes;
private int slaveConnectTimeout = PodTemplate.DEFAULT_SLAVE_JENKINS_CONNECTION_TIMEOUT;
private int activeDeadlineSeconds;

private Boolean hostNetwork;

@CheckForNull
private String serviceAccount;

@CheckForNull
private String nodeSelector;

@CheckForNull
private Node.Mode nodeUsageMode = Node.Mode.EXCLUSIVE;

@CheckForNull
private String workingDir = ContainerTemplate.DEFAULT_WORKING_DIR;

@CheckForNull
private String yaml;

@CheckForNull
private YamlMergeStrategy yamlMergeStrategy = YamlMergeStrategy.defaultStrategy();

@CheckForNull
private PodRetention podRetention;

private Boolean showRawYaml;


@CheckForNull
private String runAsUser;

@CheckForNull
private String runAsGroup;

@CheckForNull
private String supplementalGroups;

@DataBoundConstructor
Expand All @@ -80,96 +119,105 @@ public String getLabel() {
}

@DataBoundSetter
public void setLabel(String label) {
public void setLabel(@CheckForNull String label) {
this.label = Util.fixEmpty(label);
}

public @CheckForNull String getName() {
@CheckForNull
public String getName() {
return name;
}

@DataBoundSetter
public void setName(String name) {
public void setName(@CheckForNull String name) {
this.name = Util.fixEmpty(name);
}

@CheckForNull
public String getNamespace() {
return namespace;
}

@DataBoundSetter
public void setNamespace(String namespace) {
this.namespace = namespace;
public void setNamespace(@CheckForNull String namespace) {
this.namespace = Util.fixEmpty(namespace);
}

@CheckForNull
public String getCloud() {
return cloud;
}

@DataBoundSetter
public void setCloud(String cloud) {
this.cloud = cloud;
public void setCloud(@CheckForNull String cloud) {
this.cloud = Util.fixEmpty(cloud);
}

@CheckForNull
public String getInheritFrom() {
return inheritFrom;
}

@DataBoundSetter
public void setInheritFrom(String inheritFrom) {
this.inheritFrom = inheritFrom;
public void setInheritFrom(@CheckForNull String inheritFrom) {
this.inheritFrom = Util.fixEmpty(inheritFrom);
}

@CheckForNull
jglick marked this conversation as resolved.
Show resolved Hide resolved
public List<ContainerTemplate> getContainers() {
return containers;
}

@DataBoundSetter
public void setContainers(List<ContainerTemplate> containers) {
this.containers = containers;
public void setContainers(@CheckForNull List<ContainerTemplate> containers) {
jglick marked this conversation as resolved.
Show resolved Hide resolved
this.containers = Util.fixNull(containers);
jglick marked this conversation as resolved.
Show resolved Hide resolved
}

@CheckForNull
public List<TemplateEnvVar> getEnvVars() {
return envVars == null ? Collections.emptyList() : envVars;
}

@DataBoundSetter
public void setEnvVars(List<TemplateEnvVar> envVars) {
public void setEnvVars(@CheckForNull List<TemplateEnvVar> envVars) {
if (envVars != null) {
this.envVars.clear();
this.envVars.addAll(envVars);
}
}

@CheckForNull
public YamlMergeStrategy getYamlMergeStrategy() {
return yamlMergeStrategy;
}

@DataBoundSetter
public void setYamlMergeStrategy(YamlMergeStrategy yamlMergeStrategy) {
public void setYamlMergeStrategy(@CheckForNull YamlMergeStrategy yamlMergeStrategy) {
this.yamlMergeStrategy = yamlMergeStrategy;
}

@CheckForNull
jglick marked this conversation as resolved.
Show resolved Hide resolved
public List<PodVolume> getVolumes() {
return volumes;
}

@DataBoundSetter
public void setVolumes(List<PodVolume> volumes) {
this.volumes = volumes;
public void setVolumes(@CheckForNull List<PodVolume> volumes) {
this.volumes = Util.fixNull(volumes);
jglick marked this conversation as resolved.
Show resolved Hide resolved
}

@CheckForNull
public WorkspaceVolume getWorkspaceVolume() {
return workspaceVolume;
return workspaceVolume == null ? DescriptorImpl.defaultWorkspaceVolume : this.workspaceVolume;
}

@DataBoundSetter
public void setWorkspaceVolume(WorkspaceVolume workspaceVolume) {
this.workspaceVolume = workspaceVolume;
public void setWorkspaceVolume(@CheckForNull WorkspaceVolume workspaceVolume) {
this.workspaceVolume = (workspaceVolume == null || workspaceVolume.equals(DescriptorImpl.defaultWorkspaceVolume)) ? null : workspaceVolume;
}

public int getInstanceCap() {
return instanceCap;
return instanceCap;// == null ? DescriptorImpl.defaultInstanceCap : instanceCap;
jglick marked this conversation as resolved.
Show resolved Hide resolved
}

@DataBoundSetter
Expand All @@ -182,25 +230,27 @@ public int getIdleMinutes() {
}

@DataBoundSetter
public void setIdleMinutes(int idleMinutes) {
public void setIdleMinutes(@CheckForNull int idleMinutes) {
this.idleMinutes = idleMinutes;
}

@CheckForNull
public int getSlaveConnectTimeout() {
return slaveConnectTimeout;
}

@DataBoundSetter
public void setSlaveConnectTimeout(int slaveConnectTimeout) {
public void setSlaveConnectTimeout(@CheckForNull int slaveConnectTimeout) {
this.slaveConnectTimeout = slaveConnectTimeout;
}

@CheckForNull
public int getActiveDeadlineSeconds() {
return activeDeadlineSeconds;
}

@DataBoundSetter
public void setActiveDeadlineSeconds(int activeDeadlineSeconds) {
public void setActiveDeadlineSeconds(@CheckForNull int activeDeadlineSeconds) {
this.activeDeadlineSeconds = activeDeadlineSeconds;
}

Expand All @@ -213,20 +263,22 @@ public void setHostNetwork(boolean hostNetwork) {
this.hostNetwork = hostNetwork;
}

@CheckForNull
public String getServiceAccount() { return serviceAccount; }

@DataBoundSetter
public void setServiceAccount(String serviceAccount) {
this.serviceAccount = serviceAccount;
public void setServiceAccount(@CheckForNull String serviceAccount) {
this.serviceAccount = Util.fixEmpty(serviceAccount);
}

@CheckForNull
public String getNodeSelector() {
return nodeSelector;
}

@DataBoundSetter
public void setNodeSelector(String nodeSelector) {
this.nodeSelector = nodeSelector;
public void setNodeSelector(@CheckForNull String nodeSelector) {
this.nodeSelector = Util.fixEmpty(nodeSelector);
}

public Node.Mode getNodeUsageMode() {
Expand Down Expand Up @@ -277,23 +329,24 @@ public void setImagePullSecrets(List<String> imagePullSecrets) {
}
}


@CheckForNull
public String getYaml() {
return yaml;
}

@DataBoundSetter
public void setYaml(String yaml) {
this.yaml = yaml;
public void setYaml(@CheckForNull String yaml) {
this.yaml = Util.fixEmpty(yaml);
}

@CheckForNull
public PodRetention getPodRetention() {
return this.podRetention;
return this.podRetention == null ? DescriptorImpl.defaultPodRetention : this.podRetention;
}

@DataBoundSetter
public void setPodRetention(PodRetention podRetention) {
this.podRetention = podRetention;
public void setPodRetention(@CheckForNull PodRetention podRetention) {
this.podRetention = (podRetention == null || podRetention.equals(DescriptorImpl.defaultPodRetention)) ? null : podRetention;
}

boolean isShowRawYamlSet() {
Expand Down Expand Up @@ -327,13 +380,14 @@ public void setRunAsGroup(String runAsGroup) {
this.runAsGroup = runAsGroup;
}

@CheckForNull
public String getSupplementalGroups() {
return supplementalGroups;
}

@DataBoundSetter
public void setSupplementalGroups(String supplementalGroups) {
this.supplementalGroups = supplementalGroups;
public void setSupplementalGroups(@CheckForNull String supplementalGroups) {
this.supplementalGroups = Util.fixEmpty(supplementalGroups);
}

@Extension
Expand Down Expand Up @@ -363,5 +417,8 @@ public Set<? extends Class<?>> getRequiredContext() {
public String getWorkingDir() {
return ContainerTemplate.DEFAULT_WORKING_DIR;
}

public static final PodRetention defaultPodRetention = new Always();
public static final WorkspaceVolume defaultWorkspaceVolume = new DynamicPVCWorkspaceVolume(null, null, "ReadWriteOnce");
jglick marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading