Skip to content
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

Don't mask deployment target from the CLI #34678

Merged
merged 1 commit into from
Jul 12, 2023
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
9 changes: 6 additions & 3 deletions devtools/cli/src/main/java/io/quarkus/cli/deploy/Kind.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.cli.deploy;

import java.util.Optional;

import io.quarkus.cli.BuildToolContext;
import picocli.CommandLine;

Expand All @@ -20,15 +22,16 @@ public enum DeploymentKind {
}

@CommandLine.Option(names = { "--deployment-kind" }, description = "The kind of resource to generate and deploy")
public DeploymentKind kind = DeploymentKind.Deployment;
public Optional<DeploymentKind> kind;

@Override
public void populateContext(BuildToolContext context) {
super.populateContext(context);
context.getPropertiesOptions().properties.put(String.format(QUARKUS_DEPLOY_FORMAT, KIND), "true");
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, kind.name());
context.getForcedExtensions().add(KIND_EXTENSION);
context.getForcedExtensions().add(CONTAINER_IMAGE_EXTENSION);
kind.ifPresent(k -> {
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, k.name());
});
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.cli.deploy;

import java.util.Optional;

import io.quarkus.cli.BuildToolContext;
import picocli.CommandLine;

Expand All @@ -20,17 +22,19 @@ public enum DeploymentKind {
}

@CommandLine.Option(names = { "--deployment-kind" }, description = "The kind of resource to generate and deploy")
public DeploymentKind kind = DeploymentKind.Deployment;
public Optional<DeploymentKind> kind;

@Override
public void populateContext(BuildToolContext context) {
super.populateContext(context);
context.getPropertiesOptions().properties.put(String.format(QUARKUS_DEPLOY_FORMAT, KUBERNETES), "true");
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, kind.name());
context.getForcedExtensions().add(KUBERNETES_EXTENSION);
context.getForcedExtensions().add(CONTAINER_IMAGE_EXTENSION);
kubernetesOptions.imageBuilder.or(implicitImageBuilder()).ifPresent(imageBuilder -> {
context.getForcedExtensions().add(CONTAINER_IMAGE_EXTENSION + "-" + imageBuilder);
});
kind.ifPresent(k -> {
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, k.name());
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.cli.deploy;

import java.util.Optional;

import io.quarkus.cli.BuildToolContext;
import picocli.CommandLine;

Expand All @@ -20,14 +22,16 @@ public enum DeploymentKind {
}

@CommandLine.Option(names = { "--deployment-kind" }, description = "The kind of resource to generate and deploy")
public DeploymentKind kind = DeploymentKind.Deployment;
public Optional<DeploymentKind> kind;

@Override
public void populateContext(BuildToolContext context) {
super.populateContext(context);
context.getPropertiesOptions().properties.put(String.format(QUARKUS_DEPLOY_FORMAT, MINIKUBE), "true");
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, kind.name());
context.getForcedExtensions().add(MINIKUBE_EXTENSION);
context.getForcedExtensions().add(CONTAINER_IMAGE_EXTENSION);
kind.ifPresent(k -> {
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, k.name());
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.cli.deploy;

import java.util.Optional;

import io.quarkus.cli.BuildToolContext;
import picocli.CommandLine;

Expand All @@ -20,14 +22,16 @@ public enum DeploymentKind {
}

@CommandLine.Option(names = { "--deployment-kind" }, description = "The kind of resource to generate and deploy")
public DeploymentKind kind = DeploymentKind.DeploymentConfig;
public Optional<DeploymentKind> kind;

@Override
public void populateContext(BuildToolContext context) {
super.populateContext(context);
context.getPropertiesOptions().properties.put(String.format(QUARKUS_DEPLOY_FORMAT, OPENSHIFT), "true");
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, kind.name());
context.getForcedExtensions().add(OPENSHIFT_EXTENSION);
kind.ifPresent(k -> {
context.getPropertiesOptions().properties.put(DEPLOYMENT_KIND, k.name());
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.cli.deploy;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
Expand Down Expand Up @@ -97,21 +98,23 @@ public void testUsage() throws Exception {
assertTrue(result.getStdout().contains("--no-daemon"));
assertTrue(result.getStdout().contains("--no-build-cache"));

testDeployer("kubernetes", "docker");
testDeployer("knative", "docker");
testDeployer("minikube", "docker");
testDeployer("kind", "docker");
testDeployer("openshift", "openshift");
testDeployer("kubernetes", "kubernetes", "docker");
testDeployer("minikube", "kubernetes", "docker");
testDeployer("kind", "kubernetes", "docker");
testDeployer("openshift", "openshift", "openshift");
testDeployer("knative", "knative", "docker");

}

protected void testDeployer(String deployer, String defaultImageBuilder) throws Exception {
protected void testDeployer(String deployer, String configGroup, String defaultImageBuilder) throws Exception {
CliDriver.Result result = CliDriver.execute(project, "deploy", deployer, "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("deploy"));
assertTrue(result.getStdout().contains("--no-daemon"));
assertTrue(result.getStdout().contains("--no-build-cache"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("--init-script="));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

result = CliDriver.execute(project, "deploy", deployer, "--image-build", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
Expand All @@ -121,6 +124,7 @@ protected void testDeployer(String deployer, String defaultImageBuilder) throws
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("--init-script="));
assertTrue(result.getStdout().contains("--image-builder=" + defaultImageBuilder));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

result = CliDriver.execute(project, "deploy", deployer, "--image-builder=jib", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
Expand All @@ -130,5 +134,19 @@ protected void testDeployer(String deployer, String defaultImageBuilder) throws
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("--init-script="));
assertTrue(result.getStdout().contains("--image-builder=jib"));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

if ("knative".equals(deployer)) {
return;
}
result = CliDriver.execute(project, "deploy", deployer, "--deployment-kind", "Deployment",
"--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("deploy"));
assertTrue(result.getStdout().contains("--no-daemon"));
assertTrue(result.getStdout().contains("--no-build-cache"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("--init-script="));
assertTrue(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind=Deployment"));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.cli.image;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.nio.file.Path;
Expand Down Expand Up @@ -48,32 +49,45 @@ public void testUsage() throws Exception {
result = CliDriver.execute(project, "deploy", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);

testDeployer("kubernetes", "docker");
testDeployer("knative", "docker");
testDeployer("minikube", "docker");
testDeployer("kind", "docker");
testDeployer("openshift", "openshift");
testDeployer("kubernetes", "kubernetes", "docker");
testDeployer("minikube", "kubernetes", "docker");
testDeployer("kind", "kubernetes", "docker");
testDeployer("openshift", "openshift", "openshift");
testDeployer("knative", "knative", "docker");
}

protected void testDeployer(String deployer, String defaultImageBuilder) throws Exception {
protected void testDeployer(String deployer, String configGroup, String defaultImageBuilder) throws Exception {
CliDriver.Result result = CliDriver.execute(project, "deploy", deployer, "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("quarkus:deploy"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.build=false"));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

result = CliDriver.execute(project, "deploy", deployer, "--image-build", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("quarkus:deploy"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.builder=" + defaultImageBuilder));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.build=true"));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

result = CliDriver.execute(project, "deploy", deployer, "--image-builder=jib", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("quarkus:deploy"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.builder=jib"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.build=true"));
assertFalse(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind"));

if ("knative".equals(deployer)) {
return;
}
result = CliDriver.execute(project, "deploy", deployer, "--deployment-kind", "Deployment", "--dry-run");
assertEquals(CommandLine.ExitCode.OK, result.getExitCode(), "Expected OK return code." + result);
assertTrue(result.getStdout().contains("quarkus:deploy"));
assertTrue(result.getStdout().contains("-Dquarkus." + deployer + ".deploy=true"));
assertTrue(result.getStdout().contains("-Dquarkus.container-image.build=false"));
assertTrue(result.getStdout().contains("-Dquarkus." + configGroup + ".deployment-kind=Deployment"));
}
}