Skip to content

Turn source image project into a combobox. #505

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.labels.LabelAtom;
import hudson.util.ComboBoxModel;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -98,20 +98,17 @@
public static final String DEFAULT_RUN_AS_USER = "jenkins";
public static final String METADATA_LINUX_STARTUP_SCRIPT_KEY = "startup-script";
public static final String METADATA_WINDOWS_STARTUP_SCRIPT_KEY = "windows-startup-script-ps1";
public static final List<String> KNOWN_IMAGE_PROJECTS = Collections.unmodifiableList(new ArrayList<String>() {
{
add("centos-cloud");
add("coreos-cloud");
add("cos-cloud");
add("debian-cloud");
add("rhel-cloud");
add("suse-cloud");
add("suse-sap-cloud");
add("ubuntu-os-cloud");
add("windows-cloud");
add("windows-sql-cloud");
}
});
public static final List<String> KNOWN_IMAGE_PROJECTS = List.of(
"centos-cloud",
"coreos-cloud",
"cos-cloud",
"debian-cloud",
"rhel-cloud",
"suse-cloud",
"suse-sap-cloud",
"ubuntu-os-cloud",
"windows-cloud",
"windows-sql-cloud");

private String description;
private String namePrefix;
Expand Down Expand Up @@ -834,16 +831,12 @@
}
}

public ListBoxModel doFillBootDiskSourceImageProjectItems(
@AncestorInPath Jenkins context,
public ComboBoxModel doFillBootDiskSourceImageProjectItems(

Check warning

Code scanning / Jenkins Security Scan

Stapler: Missing POST/RequirePOST annotation Warning

Potential CSRF vulnerability: If DescriptorImpl#doFillBootDiskSourceImageProjectItems connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST
@QueryParameter("projectId") @RelativePath("..") final String projectId) {
checkPermissions(Jenkins.get(), Jenkins.ADMINISTER);
ListBoxModel items = new ListBoxModel();
items.add("");
ComboBoxModel items = new ComboBoxModel();
items.add(projectId);
for (String v : KNOWN_IMAGE_PROJECTS) {
items.add(v);
}
items.addAll(KNOWN_IMAGE_PROJECTS);

Check warning on line 839 in src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 837-839 are not covered by tests
return items;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@

<f:section title="Boot Disk">
<f:entry field="bootDiskSourceImageProject" title="${%Image project}">
<f:select/>
<f:combobox/>
</f:entry>
<f:entry field="bootDiskSourceImageName" title="${%Image name}">
<f:select/>
Expand Down
Loading