-
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
[JENKINS-72176] Split cloud management page into multiple pages #1443
Changes from 39 commits
f9571b2
be4fca7
2e89c57
b7bdefe
cee3420
b183580
558cb42
0661f6d
f1d29e6
5848de2
93b833d
227712c
aefb1d9
20c0acf
2dbd016
d921fc9
189c5ac
a011a9d
d31ac1f
30753a8
c86ad89
49c0ac3
75b7c78
c1342c6
bee1a7f
3c2a4a3
4442a4a
a6295db
7b875ed
af6373b
a5699ee
bcafb81
b1edb7f
3be2fde
31be218
0e3cbb0
0986f8e
dd65959
2a9048c
ea4047a
d03c902
c7180ab
758d8c8
2775886
08866ec
697f605
18c219c
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
import java.util.Set; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
import javax.servlet.ServletException; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckForNull; | ||
|
@@ -34,12 +33,17 @@ | |
import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuth; | ||
import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthException; | ||
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
import org.kohsuke.stapler.AncestorInPath; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
import org.kohsuke.stapler.DataBoundSetter; | ||
import org.kohsuke.stapler.HttpResponse; | ||
import org.kohsuke.stapler.QueryParameter; | ||
import org.kohsuke.stapler.StaplerRequest; | ||
import org.kohsuke.stapler.StaplerResponse; | ||
import org.kohsuke.stapler.interceptor.RequirePOST; | ||
|
||
import org.kohsuke.stapler.verb.POST; | ||
import com.cloudbees.plugins.credentials.CredentialsMatchers; | ||
import com.cloudbees.plugins.credentials.common.StandardCredentials; | ||
import com.cloudbees.plugins.credentials.common.StandardListBoxModel; | ||
|
@@ -58,7 +62,9 @@ | |
import hudson.security.ACL; | ||
import hudson.slaves.Cloud; | ||
import hudson.slaves.NodeProvisioner; | ||
import hudson.util.FormApply; | ||
import hudson.util.FormValidation; | ||
import hudson.util.HttpResponses; | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import hudson.util.ListBoxModel; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import io.fabric8.kubernetes.client.KubernetesClientException; | ||
|
@@ -100,6 +106,10 @@ public class KubernetesCloud extends Cloud { | |
|
||
@NonNull | ||
private List<PodTemplate> templates = new ArrayList<>(); | ||
|
||
public boolean hasTemplates() { | ||
return !templates.isEmpty(); | ||
} | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private String serverUrl; | ||
private boolean useJenkinsProxy; | ||
@CheckForNull | ||
|
@@ -600,6 +610,34 @@ public boolean canProvision(@NonNull Cloud.CloudState state) { | |
public PodTemplate getTemplate(@CheckForNull Label label) { | ||
return PodTemplateUtils.getTemplateByLabel(label, getAllTemplates()); | ||
} | ||
|
||
@CheckForNull | ||
public PodTemplate getTemplate(@NonNull String id) { | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return getTemplateById(id); | ||
} | ||
|
||
// TODO: Remove when JENKINS-71737 is fixed | ||
@POST | ||
public HttpResponse doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException { | ||
|
||
Jenkins j = Jenkins.get(); | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
j.checkPermission(Jenkins.ADMINISTER); | ||
Cloud cloud = j.getCloud(this.name); | ||
if (cloud == null) { | ||
return HttpResponses.notFound(); | ||
} | ||
KubernetesCloud result = (KubernetesCloud) cloud.reconfigure(req, req.getSubmittedForm()); | ||
String proposedName = result.name; | ||
if (!proposedName.equals(this.name) | ||
&& j.getCloud(proposedName) != null) { | ||
throw new Descriptor.FormException(Messages.cloudAlreadyExists(proposedName), "name"); | ||
} | ||
result.templates = this.templates; | ||
j.clouds.replace(this, result); | ||
j.save(); | ||
// take the user back to the cloud top page. | ||
return FormApply.success("../.."); | ||
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 should be followed up in Jenkins core, since in case you rename a cloud |
||
} | ||
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. Even if this starts from a good intention, I think it should be split to a separate PR as it is unrelated to the intent of this PR. |
||
|
||
@CheckForNull | ||
public PodTemplate getTemplateById(@NonNull String id) { | ||
|
@@ -716,6 +754,25 @@ public void setWaitForPodSec(Integer waitForPodSec) { | |
this.waitForPodSec = waitForPodSec; | ||
} | ||
|
||
@Restricted(NoExternalUse.class) | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public PodTemplate.DescriptorImpl getTemplateDescriptor() { | ||
return (PodTemplate.DescriptorImpl) Jenkins.get().getDescriptorOrDie(PodTemplate.class); | ||
} | ||
|
||
/** | ||
* Creating a new template. | ||
*/ | ||
@POST | ||
public HttpResponse doCreate(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, Descriptor.FormException { | ||
Jenkins j = Jenkins.get(); | ||
j.checkPermission(Jenkins.ADMINISTER); | ||
PodTemplate newTemplate = getTemplateDescriptor().newInstance(req, req.getSubmittedForm()); | ||
addTemplate(newTemplate); | ||
j.save(); | ||
// take the user back. | ||
return FormApply.success("templates"); | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends Descriptor<Cloud> { | ||
@Override | ||
|
@@ -985,4 +1042,5 @@ public static void hpiRunInit() { | |
} | ||
} | ||
} | ||
|
||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2023, CloudBees Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:f="/lib/form"> | ||
<l:layout permission="${app.SYSTEM_READ}" title="${%New pod template}"> | ||
<j:set var="readOnlyMode" value="${!app.hasPermission(app.ADMINISTER)}"/> | ||
<l:breadcrumb title="${%New pod template }"/> | ||
<st:include page="sidepanel.jelly" it="${it}"/> | ||
<l:main-panel> | ||
<h1>${%New pod template settings}</h1> | ||
<f:form method="post" action="create" name="config" class="jenkins-form"> | ||
<!-- main body of the configuration --> | ||
|
||
<j:set var="descriptor" value="${it.templateDescriptor}"/> | ||
<st:include class="${descriptor.clazz}" page="config.jelly"/> | ||
<l:isAdmin> | ||
<f:bottomButtonBar> | ||
<f:submit value="${%Create}"/> | ||
</f:bottomButtonBar> | ||
</l:isAdmin> | ||
</f:form> | ||
<l:isAdmin> | ||
<st:adjunct includes="lib.form.confirm"/> | ||
</l:isAdmin> | ||
</l:main-panel> | ||
</l:layout> | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2023, CloudBees Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:t="/lib/hudson"> | ||
<l:header /> | ||
<l:side-panel> | ||
<l:tasks> | ||
<l:task contextMenu="false" href="." icon="symbol-computer" title="${%Status}"/> | ||
<l:task href="templates" icon="symbol-details" title="${%Pod Templates}"/> | ||
<l:task href="configure" icon="symbol-settings" | ||
title="${app.hasPermission(app.ADMINISTER) ? '%Configure' : '%View Configuration'}"/> | ||
<l:delete permission="${app.ADMINISTER}" title="${%Delete Cloud}" message="${%delete.cloud(it.displayName)}"/> | ||
<t:actions /> | ||
</l:tasks> | ||
<j:forEach var="action" items="${it.allActions}"> | ||
<st:include it="${action}" page="box.jelly" optional="true"/> | ||
</j:forEach> | ||
</l:side-panel> | ||
</j:jelly> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
delete.cloud=Delete the cloud? | ||
scherler marked this conversation as resolved.
Show resolved
Hide resolved
|
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 imagine this bump is there to retrieve some necessary updates from core?
Cause it is higher than the recommended minimum version: https://www.jenkins.io/doc/developer/tutorial-improve/update-base-jenkins-version/
And also it does not align with the bom anymore (bom is using
2.401.x
).If it is intended and mandatory to have
2.415
it could be interesting to write a comment explaining it and a TODO to align the bom as soon as available?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.
Afair this is to get
<l:delete ...>
.BOM should be bumped to the closest LTS which is
2.414.x
.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 change was suggested by @Vlatombe, we need a version after jenkinsci/jenkins#7658, other than that ...