-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Clean up the snippet generation for a container template. #917
base: master
Are you sure you want to change the base?
Changes from all commits
0bda546
1a77924
07cb7a8
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 |
---|---|---|
|
@@ -130,7 +130,7 @@ public String getImage() { | |
|
||
@DataBoundSetter | ||
public void setCommand(String command) { | ||
this.command = command; | ||
this.command = Util.fixEmpty(command); | ||
} | ||
|
||
public String getCommand() { | ||
|
@@ -139,7 +139,7 @@ public String getCommand() { | |
|
||
@DataBoundSetter | ||
public void setArgs(String args) { | ||
this.args = args; | ||
this.args = Util.fixEmpty(args); | ||
} | ||
|
||
public String getArgs() { | ||
|
@@ -222,7 +222,9 @@ public void setEnvVars(List<TemplateEnvVar> envVars) { | |
} | ||
|
||
|
||
public ContainerLivenessProbe getLivenessProbe() { return livenessProbe; } | ||
public ContainerLivenessProbe getLivenessProbe() { | ||
return livenessProbe; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setLivenessProbe(ContainerLivenessProbe livenessProbe) { | ||
|
@@ -244,7 +246,7 @@ public String getResourceRequestMemory() { | |
|
||
@DataBoundSetter | ||
public void setResourceRequestMemory(String resourceRequestMemory) { | ||
this.resourceRequestMemory = resourceRequestMemory; | ||
this.resourceRequestMemory = Util.fixEmpty(resourceRequestMemory); | ||
} | ||
|
||
public String getResourceLimitMemory() { | ||
|
@@ -253,16 +255,16 @@ public String getResourceLimitMemory() { | |
|
||
@DataBoundSetter | ||
public void setResourceLimitMemory(String resourceLimitMemory) { | ||
this.resourceLimitMemory = resourceLimitMemory; | ||
this.resourceLimitMemory = Util.fixEmpty(resourceLimitMemory); | ||
} | ||
|
||
public String getResourceRequestCpu() { | ||
return resourceRequestCpu; | ||
} | ||
|
||
@DataBoundSetter | ||
public void setResourceRequestCpu(String resourceRequestCpu) { | ||
this.resourceRequestCpu = resourceRequestCpu; | ||
public void setResourceRequestCpu(String resourceRequestCpu){ | ||
this.resourceRequestCpu = Util.fixEmpty(resourceRequestCpu); | ||
} | ||
|
||
public String getResourceLimitCpu() { | ||
|
@@ -271,7 +273,7 @@ public String getResourceLimitCpu() { | |
|
||
@DataBoundSetter | ||
public void setResourceLimitCpu(String resourceLimitCpu) { | ||
this.resourceLimitCpu = resourceLimitCpu; | ||
this.resourceLimitCpu = Util.fixEmpty(resourceLimitCpu); | ||
} | ||
|
||
public String getResourceRequestEphemeralStorage() { | ||
|
@@ -280,7 +282,7 @@ public String getResourceRequestEphemeralStorage() { | |
|
||
@DataBoundSetter | ||
public void setResourceRequestEphemeralStorage(String resourceRequestEphemeralStorage) { | ||
this.resourceRequestEphemeralStorage = resourceRequestEphemeralStorage; | ||
this.resourceRequestEphemeralStorage = Util.fixEmpty(resourceRequestEphemeralStorage); | ||
} | ||
|
||
public String getResourceLimitEphemeralStorage() { | ||
|
@@ -289,7 +291,7 @@ public String getResourceLimitEphemeralStorage() { | |
|
||
@DataBoundSetter | ||
public void setResourceLimitEphemeralStorage(String resourceLimitEphemeralStorage) { | ||
this.resourceLimitEphemeralStorage = resourceLimitEphemeralStorage; | ||
this.resourceLimitEphemeralStorage = Util.fixEmpty(resourceLimitEphemeralStorage); | ||
} | ||
|
||
|
||
|
@@ -299,7 +301,7 @@ public String getShell() { | |
|
||
@DataBoundSetter | ||
public void setShell(String shell) { | ||
this.shell = shell; | ||
this.shell = Util.fixEmpty(shell); | ||
} | ||
|
||
public Map<String,Object> getAsArgs() { | ||
|
@@ -330,6 +332,9 @@ public List<? extends Descriptor> getEnvVarsDescriptors() { | |
} | ||
|
||
public FormValidation doCheckName(@QueryParameter String value) { | ||
if (StringUtils.isEmpty(value)) { | ||
return FormValidation.warning("Container name is mandatory."); | ||
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 image check uses Also this warning appears as soon as you add a container template in the form, it doesn't wait for the text box to gain and lose focus. |
||
} | ||
if(!PodTemplateUtils.validateContainerName(value)) { | ||
return FormValidation.error(Messages.RFC1123_error(value)); | ||
} | ||
|
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.
interestingly, if you put a string that isn't a number into the field, the form validation doesn't happen.
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.
You can use
<f:number/>
instead of<f:textbox/>
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.
And use
FormValidation.validatePositiveInteger(value)
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.
interesting,
FormValidation.validatePositiveInteger()
takes a string as the argument. I'd really rather not rework this class to maintain strings and integers for these values.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.
Ah yes because it works from a textbox, so it expects a string as input.
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.
The validation method can use string but the rest can use int just fine
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.
@kerogers-cloudbees Could you rework the validation methods with
@QueryParameter int value
?