8000 optionalBlock that just has one field feels pointless · github-cloud/github-plugin@f2a02a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit f2a02a4

Browse files
committed
optionalBlock that just has one field feels pointless
And "custom API URL" is a poor wording when it really refers to GitHub Enterprise
1 parent 198d6c3 commit f2a02a4

File tree

9 files changed

+16
-34
lines changed

9 files changed

+16
-34
lines changed

src/main/java/org/jenkinsci/plugins/github/config/GitHubServerConfig.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ public class GitHubServerConfig extends AbstractDescribableImpl<GitHubServerConf
8282
*/
8383
private int clientCacheSize = DEFAULT_CLIENT_CACHE_SIZE_MB;
8484

85-
/**
86-
* only to set to default apiUrl when uncheck. Can be removed if optional block can nullify value if unchecked
87-
*/
88-
private transient boolean customApiUrl;
89-
9085
/**
9186
* To avoid creation of new one on every login with this config
9287
*/
@@ -98,28 +93,26 @@ public GitHubServerConfig(String credentialsId) {
9893
}
9994

10095
/**
101-
* {@link #customApiUrl} field should be defined earlier. Because of we get full content of optional block,
102-
* even if it already unchecked. So if we want to return api url to default value - custom value should affect
96+
* Set the API endpoint.
10397
*
10498
* @param apiUrl custom url if GH. Default value will be used in case of custom is unchecked or value is blank
10599
*/
106100
@DataBoundSetter
107101
public void setApiUrl(String apiUrl) {
108-
if (customApiUrl) {
109-
this.apiUrl = defaultIfBlank(apiUrl, GITHUB_URL);
110-
} else {
111-
this.apiUrl = GITHUB_URL;
112-
}
102+
this.apiUrl = defaultIfBlank(apiUrl, GITHUB_URL);
113103
}
114104

115105
/**
116-
* Should be called before {@link #setApiUrl(String)}
117106
*
118107
* @param customApiUrl true if optional block "Custom GH Api Url" checked in UI
108+
* @deprecated
109+
* just set {@link #setApiUrl(String)}
119110
*/
120111
@DataBoundSetter
121112
public void setCustomApiUrl(boolean customApiUrl) {
122-
this.customApiUrl = customApiUrl;
113+
if (!customApiUrl) {
114+
this.apiUrl = GITHUB_URL;
115+
}
123116
}
124117

125118
/**
@@ -138,6 +131,7 @@ public String getApiUrl() {
138131

139132
/**
140133
* @see #isUrlCustom(String)
134+
* @deprecated
141135
*/
142136
@Restricted(NoExternalUse.class)
143137
public boolean isCustomApiUrl() {
@@ -291,7 +285,6 @@ public FormValidation doVerifyCredentials(
291285
@QueryParameter Integer clientCacheSize) throws IOException {
292286

293287
GitHubServerConfig config = new GitHubServerConfig(credentialsId);
294-
config.setCustomApiUrl(isUrlCustom(apiUrl));
295288
config.setApiUrl(apiUrl);
296289
config.setClientCacheSize(clientCacheSize);
297290
GitHub gitHub = new GitHubLoginFunction().apply(config);

src/main/java/org/jenkinsci/plugins/github/migration/Migrator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.io.IOException;
1717

1818
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
19-
import static org.jenkinsci.plugins.github.config.GitHubServerConfig.isUrlCustom;
2019
import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from;
2120

2221
/**
@@ -83,7 +82,6 @@ public GitHubServerConfig apply(Credential input) {
8382
);
8483

8584
GitHubServerConfig gitHubServerConfig = new GitHubServerConfig(credentials.getId());
86-
gitHubServerConfig.setCustomApiUrl(isUrlCustom(input.getApiUrl()));
8785
gitHubServerConfig.setApiUrl(input.getApiUrl());
8886

8987
return gitHubServerConfig;

src/main/resources/org/jenkinsci/plugins/github/config/GitHubServerConfig/config.groovy

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ f.entry(title: _("Credentials"), field: "credentialsId") {
1414
c.select()
1515
}
1616

17-
f.optionalBlock(title: _("Custom GitHub API URL"),
18-
inline: true,
19-
field: "customApiUrl",
20-
checked: instance?.customApiUrl) {
21-
f.entry(title: _("GitHub API URL"), field: "apiUrl") {
22-
f.textbox(default: GitHubServerConfig.GITHUB_URL)
23-
}
17+
f.entry(title: _("API URL"), field: "apiUrl") {
18+
f.textbox(default: GitHubServerConfig.GITHUB_URL)
2419
}
2520

2621
f.advanced() {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div>
2+
If you use GitHub Enterprise, specify the API end point here
3+
(e.g., <code>https://ghe.acme.com/api/v3/</code>).
4+
The default value of <code>https://api.github.com</code>
5+
refers to the public github.com instance.
6+
</div>

src/main/resources/org/jenkinsci/plugins/github/config/GitHubServerConfig/help-customApiUrl.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/test/java/org/jenkinsci/plugins/github/config/GitHubServerConfigTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public void shouldMatchDefaultConfigWithGHDefaultHost() throws Exception {
5959
@Test
6060
public void shouldNotMatchNonDefaultConfigWithGHDefaultHost() throws Exception {
6161
GitHubServerConfig input = new GitHubServ F438 erConfig("");
62-
input.setCustomApiUrl(true);
6362
input.setApiUrl(CUSTOM_GH_SERVER);
6463
assertThat(withHost(DEFAULT_GH_API_HOST).apply(input), is(false));
6564
}

src/test/java/org/jenkinsci/plugins/github/internal/GitHubClientCacheCleanupTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public void shouldRemoveOnlyNotActiveCachedDirAfterClean() throws Exception {
7373
makeCachedRequestWithCredsId(CHANGED_CREDS_ID);
7474

7575
GitHubServerConfig config = new GitHubServerConfig(CHANGED_CREDS_ID);
76-
config.setCustomApiUrl(true);
7776
config.setApiUrl(github.serverConfig().getApiUrl());
7877
config.setClientCacheSize(1);
7978

@@ -87,7 +86,6 @@ public void shouldRemoveCacheWhichNotEnabled() throws Exception {
8786
makeCachedRequestWithCredsId(CHANGED_CREDS_ID);
8887

8988
GitHubServerConfig config = new GitHubServerConfig(CHANGED_CREDS_ID);
90-
config.setCustomApiUrl(true);
9189
config.setApiUrl(github.serverConfig().getApiUrl());
9290
config.setClientCacheSize(0);
9391

src/test/java/org/jenkinsci/plugins/github/internal/GitHubClientCacheOpsTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void shouldPointToSameCacheForOneConfig() throws Exception {
4949
@Test
5050
public void shouldPointToDifferentCachesOnChangedApiPath() throws Exception {
5151
GitHubServerConfig config = new GitHubServerConfig(CREDENTIALS_ID);
52-
config.setCustomApiUrl(true);
5352
config.setApiUrl(CUSTOM_API_URL);
5453

5554
GitHubServerConfig config2 = new GitHubServerConfig(CREDENTIALS_ID);

src/test/java/org/jenkinsci/plugins/github/test/GHMockRule.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public WireMockRule service() {
6363
*/
6464
public GitHubServerConfig serverConfig() {
6565
GitHubServerConfig conf = new GitHubServerConfig("creds");
66-
conf.setCustomApiUrl(true);
6766
conf.setApiUrl("http://localhost:" + service().port());
6867
return conf;
6968
}

0 commit comments

Comments
 (0)
0