Skip to content

Commit

Permalink
refactor: deprecate master-url for api-server-url
Browse files Browse the repository at this point in the history
  • Loading branch information
iocanel committed Feb 28, 2023
1 parent 8bf9f63 commit 244021e
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Optional<BuildToolDelegatingCommand> getParentCommand() {
@Override
public void populateContext(BuildToolContext context) {
Map<String, String> properties = context.getPropertiesOptions().properties;
kubernetesOptions.masterUrl.ifPresent(u -> properties.put("quarkus.kubernetes-client.master-url", u));
kubernetesOptions.masterUrl.ifPresent(u -> properties.put("quarkus.kubernetes-client.api-server-url", u));
kubernetesOptions.username.ifPresent(u -> properties.put("quarkus.kubernetes-client.username", u));
kubernetesOptions.password.ifPresent(p -> properties.put("quarkus.kubernetes-client.password", p));
kubernetesOptions.token.ifPresent(t -> properties.put("quarkus.kubernetes-client.token", t));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class KubernetesOptions {

@CommandLine.Option(order = 3, names = { "--master-url" }, description = "The URL of the kubernetes API server")
@CommandLine.Option(order = 3, names = { "--api-server-url" }, description = "The URL of the kubernetes API server")
public Optional<String> masterUrl;

@CommandLine.Option(order = 4, names = { "--username" }, description = "Kubernetes username")
Expand Down
6 changes: 3 additions & 3 deletions devtools/cli/src/test/java/io/quarkus/cli/CliHelpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void testDeployKubernetesHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "deploy", "kubernetes", "--help");
result.echoSystemOut();
assertThat(result.stdout).contains("Usage");
assertThat(result.stdout).contains("--master-url");
assertThat(result.stdout).contains("--api-server-url");
assertThat(result.stdout).contains("--token");
assertThat(result.stdout).contains("--namespace");
assertThat(result.stdout).contains("--deployment-kind");
Expand All @@ -318,7 +318,7 @@ public void testDeployOpenshiftHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "deploy", "openshift", "--help");
result.echoSystemOut();
assertThat(result.stdout).contains("Usage");
assertThat(result.stdout).contains("--master-url");
assertThat(result.stdout).contains("--api-server-url");
assertThat(result.stdout).contains("--token");
assertThat(result.stdout).contains("--namespace");
assertThat(result.stdout).contains("--deployment-kind");
Expand All @@ -330,7 +330,7 @@ public void testDeployKnativeHelp() throws Exception {
CliDriver.Result result = CliDriver.execute(workspaceRoot, "deploy", "knative", "--help");
result.echoSystemOut();
assertThat(result.stdout).contains("Usage");
assertThat(result.stdout).contains("--master-url");
assertThat(result.stdout).contains("--api-server-url");
assertThat(result.stdout).contains("--token");
assertThat(result.stdout).contains("--namespace");
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/deploying-to-openshift.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ oc login --token=myToken --server=myServerUrl
TIP: You can request the token via the _Copy Login Command_ link in the OpenShift web console.

Finally, you don't need to use the OpenShift CLI at all.
Instead, set the `quarkus.kubernetes-client.master-url` config property and authenticate with the `quarkus.kubernetes-client.token`, or `quarkus.kubernetes-client.username` and `quarkus.kubernetes-client.password` respectively:
Instead, set the `quarkus.kubernetes-client.api-server-url` config property and authenticate with the `quarkus.kubernetes-client.token`, or `quarkus.kubernetes-client.username` and `quarkus.kubernetes-client.password` respectively:

:build-additional-parameters: -Dquarkus.kubernetes-client.master-url=myServerUrl -Dquarkus.kubernetes-client.token=myToken
:build-additional-parameters: -Dquarkus.kubernetes-client.api-server-url=myServerUrl -Dquarkus.kubernetes-client.token=myToken
include::{includes}/devtools/build.adoc[]
:!build-additional-parameters:

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/kubernetes-dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The application is configured automatically.
Dev Services for Kubernetes is automatically enabled unless:

- `quarkus.kubernetes-client.devservices.enabled` is set to `false`
- the `master-url` is configured
- the `api-server-url` is configured
- a valid Kube config file is found and `quarkus.kubernetes-client.devservices.override-kubeconfig` is not set to `true`
- you include the `quarkus-test-kubernetes-client` dependency

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
public class DevServicesKubernetesProcessor {
private static final String KUBERNETES_CLIENT_DEVSERVICES_OVERRIDE_KUBECONFIG = "quarkus.kubernetes-client.devservices.override-kubeconfig";
private static final Logger log = Logger.getLogger(DevServicesKubernetesProcessor.class);
private static final String KUBERNETES_CLIENT_MASTER_URL = "quarkus.kubernetes-client.master-url";
private static final String KUBERNETES_CLIENT_MASTER_URL = "quarkus.kubernetes-client.api-server-url";
private static final String KUBERNETES_CLIENT_DEVSERVICES_FLAVOR = "quarkus.kubernetes-client.devservices.flavor";
private static final String DEFAULT_MASTER_URL_ENDING_WITH_SLASH = Config.DEFAULT_MASTER_URL + "/";

Expand Down Expand Up @@ -167,7 +167,7 @@ private RunningDevService startKubernetes(DockerStatusBuildItem dockerStatusBuil
return null;
}

// Check if kubernetes-client.master-url is set
// Check if kubernetes-client.api-server-url is set
if (ConfigUtils.isPropertyPresent(KUBERNETES_CLIENT_MASTER_URL)) {
log.debug("Not starting Dev Services for Kubernetes, the " + KUBERNETES_CLIENT_MASTER_URL + " is configured.");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public class KubernetesClientBuildConfig {
* URL of the Kubernetes API server
*/
@ConfigItem
public Optional<String> apiServerUrl;

/**
* Use api-server-url instead.
*/
@Deprecated(forRemoval = true)
@ConfigItem
public Optional<String> masterUrl;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Config createConfig(KubernetesClientBuildConfig buildConfig, TlsCo
.withConnectionTimeout((int) buildConfig.connectionTimeout.toMillis())
.withRequestTimeout((int) buildConfig.requestTimeout.toMillis())
.withRollingTimeout(buildConfig.rollingTimeout.toMillis())
.withMasterUrl(buildConfig.masterUrl.orElse(base.getMasterUrl()))
.withMasterUrl(buildConfig.apiServerUrl.or(() -> buildConfig.masterUrl).orElse(base.getMasterUrl()))
.withNamespace(buildConfig.namespace.orElse(base.getNamespace()))
.withUsername(buildConfig.username.orElse(base.getUsername()))
.withPassword(buildConfig.password.orElse(base.getPassword()))
Expand Down Expand Up @@ -67,7 +67,8 @@ public static KubernetesClient createClient() {
.orElse(Duration.ofMillis(base.getRequestTimeout())).toMillis())
.withRollingTimeout((int) config.getOptionalValue(PREFIX + "rolling-timeout", Duration.class)
.orElse(Duration.ofMillis(base.getRollingTimeout())).toMillis())
.withMasterUrl(config.getOptionalValue(PREFIX + "master-url", String.class).orElse(base.getMasterUrl()))
.withMasterUrl(config.getOptionalValue(PREFIX + "api-server-url", String.class)
.or(() -> config.getOptionalValue(PREFIX + "master-url", String.class)).orElse(base.getMasterUrl()))
.withNamespace(config.getOptionalValue(PREFIX + "namespace", String.class).orElse(base.getNamespace()))
.withUsername(config.getOptionalValue(PREFIX + "username", String.class).orElse(base.getUsername()))
.withPassword(config.getOptionalValue(PREFIX + "password", String.class).orElse(base.getPassword()))
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/istio/maven-invoker-way/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand Down Expand Up @@ -317,7 +317,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand Down Expand Up @@ -346,7 +346,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
# ensure that an attempt to deploy is made, but that the attempt fails (as we don't want to deploy this test application to a cluster that the runner of test may have configured)
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-master-url}
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-api-server-url}
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}
8 changes: 4 additions & 4 deletions integration-tests/kubernetes/maven-invoker-way/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<filterProperties>
<kubernetes-client-master-url>-Dquarkus.kubernetes-client.master-url=http://localhost:12345</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dquarkus.kubernetes-client.api-server-url=http://localhost:12345</kubernetes-client-api-server-url>
<build-result>failure</build-result>
</filterProperties>
</configuration>
Expand All @@ -304,7 +304,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand All @@ -330,7 +330,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand All @@ -356,7 +356,7 @@
<skipInvocation>${skipTests}</skipInvocation>
<filterProperties>
<!-- this is on purpose to make sure the property is expanded -->
<kubernetes-client-master-url>-Dinvalid-on-purpose</kubernetes-client-master-url>
<kubernetes-client-api-server-url>-Dinvalid-on-purpose</kubernetes-client-api-server-url>
<build-result>success</build-result>
</filterProperties>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
# ensure that an attempt to deploy is made, but that the attempt fails (as we don't want to deploy this test application to a cluster that the runner of test may have configured)
#invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-master-url}
#invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-api-server-url}
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
# ensure that an attempt to deploy is made, but that the attempt fails (as we don't want to deploy this test application to a cluster that the runner of test may have configured)
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-master-url}
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-api-server-url}
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
# ensure that an attempt to deploy is made, but that the attempt fails (as we don't want to deploy this test application to a cluster that the runner of test may have configured)
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-master-url}
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-api-server-url}
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
# ensure that an attempt to deploy is made, but that the attempt fails (as we don't want to deploy this test application to a cluster that the runner of test may have configured)
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-master-url}
invoker.goals=clean package -Dquarkus.kubernetes.deploy=true ${kubernetes-client-api-server-url}
# expect a failure since there is no Kubernetes cluster to deploy to
invoker.buildResult = ${build-result}

0 comments on commit 244021e

Please sign in to comment.