Skip to content

Commit 8bf0070

Browse files
committed
Rename property to server; improve javadoc
1 parent 9bdb851 commit 8bf0070

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

library/src/integrationTest/kotlin/com/gabrielfeo/develocity/api/DevelocityApiIntegrationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DevelocityApiIntegrationTest {
3535
env = FakeEnv()
3636
assertDoesNotThrow {
3737
val config = Config(
38-
develocityUrl = URL("https://example.com/"),
38+
server = URL("https://example.com/"),
3939
accessKey = { "example.com=example-token" }
4040
)
4141
DevelocityApi.newInstance(config)

library/src/main/kotlin/com/gabrielfeo/develocity/api/Config.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,30 @@ data class Config(
4444
?: "off",
4545

4646
/**
47-
* Provides the base URL of a Develocity instance. By default, uses
48-
* environment variable `DEVELOCITY_URL`. Must be a valid URL with no path segments (trailing slash OK) or query parameters.
47+
* Provides the URL of a Develocity server to use in API requests. By default, uses environment
48+
* variable `DEVELOCITY_URL`. Must be a valid URL with no path segments (trailing slash OK) or
49+
* query parameters.
50+
*
51+
* Example value: `https://develocity.example.com/`
4952
*/
50-
val develocityUrl: URL =
53+
val server: URL =
5154
env["DEVELOCITY_URL"]
5255
?.let { URL(it) }
5356
?: error(ERROR_NULL_DEVELOCITY_URL),
5457

5558
/**
56-
* Provides the access key for a Develocity API instance. By default, resolves to the first
57-
* key from these sources that matches the host of [develocityUrl]:
59+
* Provides the access key for the Develocity server. By default, resolves to the first key from
60+
* these sources that matches the host of [server]:
5861
*
5962
* - variable `DEVELOCITY_ACCESS_KEY`
6063
* - variable `GRADLE_ENTERPRISE_ACCESS_KEY`
6164
* - file `$GRADLE_USER_HOME/.gradle/develocity/keys.properties` or, if `GRADLE_USER_HOME` is
6265
* not set, `~/.gradle/develocity/keys.properties`
6366
* - file `~/.m2/.develocity/keys.properties`
6467
*
65-
* Refer to Develocity documentation for details on the format of such variables and files:
68+
* Example value: `develocity.example.com=abcdefg1234567`
69+
*
70+
* Refer to Develocity documentation for more details on the format of such variables and files:
6671
*
6772
* - [Develocity Gradle Plugin User Manual][1]
6873
* - [Develocity Maven Extension User Manual][2]
@@ -73,7 +78,7 @@ data class Config(
7378
* @throws IllegalArgumentException if no matching key is found.
7479
*/
7580
val accessKey: () -> String = {
76-
val host = develocityUrl.host
81+
val host = server.host
7782
requireNotNull(accessKeyResolver.resolve(host)) { ERROR_NULL_ACCESS_KEY }
7883
},
7984

@@ -119,7 +124,7 @@ data class Config(
119124
) {
120125

121126
init {
122-
requireValidBaseUrl(develocityUrl)
127+
requireValidBaseUrl(server)
123128
}
124129

125130
/**

library/src/main/kotlin/com/gabrielfeo/develocity/api/internal/Retrofit.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal fun buildRetrofit(
1212
client: OkHttpClient,
1313
moshi: Moshi,
1414
) = with(Retrofit.Builder()) {
15-
val base = config.develocityUrl
15+
val base = config.server
1616
val baseStr = base.toString().let { if (it.endsWith("/")) it else "$it/" }
1717
baseUrl(baseStr)
1818
addConverterFactory(ScalarsConverterFactory.create())

library/src/test/kotlin/com/gabrielfeo/develocity/api/ConfigTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,35 @@ class ConfigTest {
3737
}
3838

3939
@Test
40-
fun `Given URL set in env, develocityUrl is env URL`() {
40+
fun `Given server URL set in env, server is correct URL`() {
4141
(env as FakeEnv)["DEVELOCITY_URL"] = "https://example.com/"
42-
assertEquals(URL("https://example.com/"), Config().develocityUrl)
42+
assertEquals(URL("https://example.com/"), Config().server)
4343
}
4444

4545
@Test
46-
fun `Given custom URL passed, develocityUrl is custom URL`() {
47-
val config = Config(develocityUrl = URL("https://custom.example.com/"))
48-
assertEquals(URL("https://custom.example.com/"), config.develocityUrl)
46+
fun `Given server URL set in code, server is correct URL`() {
47+
val config = Config(server = URL("https://custom.example.com/"))
48+
assertEquals(URL("https://custom.example.com/"), config.server)
4949
}
5050

5151
@Test
5252
fun `Given URL with path, error`() {
5353
assertFails {
54-
Config(develocityUrl = URL("https://example.com/foo"))
54+
Config(server = URL("https://example.com/foo"))
5555
}
5656
}
5757

5858
@Test
5959
fun `Given URL with query, error`() {
6060
assertFails {
61-
Config(develocityUrl = URL("https://example.com?foo=bar"))
61+
Config(server = URL("https://example.com?foo=bar"))
6262
}
6363
}
6464

6565
@Test
6666
fun `Given invalid URL, error`() {
6767
assertFails {
68-
Config(develocityUrl = URL("https:/example.com&"))
68+
Config(server = URL("https:/example.com&"))
6969
}
7070
}
7171

0 commit comments

Comments
 (0)