Skip to content

Commit cbb245c

Browse files
authored
Merge pull request #2270 from rnc/VOLUME
Add trusted-ca configMap and require parameters.
2 parents fcb6903 + d83c2ba commit cbb245c

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

deploy/tasks/maven-deployment.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,25 @@ spec:
4141
description: Name of the processor image. Useful to override for development.
4242
type: string
4343
default: "quay.io/redhat-user-workloads/konflux-jbs-pnc-tenant/jvm-build-service/build-request-processor:latest"
44+
- name: caTrustConfigMapKey
45+
description: The name of the key in the ConfigMap that contains the
46+
CA bundle data.
47+
type: string
48+
default: ca-bundle.crt
49+
- name: caTrustConfigMapName
50+
description: The name of the ConfigMap to read CA bundle data from.
51+
type: string
52+
default: trusted-ca
4453
volumes:
4554
- name: workdir
4655
emptyDir: {}
56+
- name: trusted-ca
57+
configMap:
58+
name: $(params.caTrustConfigMapName)
59+
items:
60+
- key: $(params.caTrustConfigMapKey)
61+
path: ca-bundle.crt
62+
optional: true
4763
stepTemplate:
4864
volumeMounts:
4965
- mountPath: /var/workdir
@@ -74,6 +90,10 @@ spec:
7490
requests:
7591
cpu: 10m
7692
memory: 512Mi
93+
volumeMounts:
94+
- mountPath: /mnt/trusted-ca
95+
name: trusted-ca
96+
readOnly: true
7797
env:
7898
- name: MAVEN_PASSWORD
7999
valueFrom:
@@ -88,3 +108,13 @@ spec:
88108
- --mvn-repo=$(params.MVN_REPO)
89109
- --mvn-username=$(params.MVN_USERNAME)
90110
- --server-id=$(params.MVN_SERVER_ID)
111+
script: |
112+
#!/bin/bash
113+
set -e
114+
ca_bundle=/mnt/trusted-ca/ca-bundle.crt
115+
if [ -f "$ca_bundle" ]; then
116+
echo "INFO: Using mounted CA bundle: $ca_bundle"
117+
cp -vf $ca_bundle /etc/pki/ca-trust/source/anchors
118+
update-ca-trust
119+
fi
120+
/opt/jboss/container/java/run/run-java.sh $@

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/DeployCommand.java

+6-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@CommandLine.Command(name = "deploy")
2020
public class DeployCommand implements Runnable {
2121

22-
@CommandLine.Option(names = "--directory")
22+
@CommandLine.Option(names = "--directory", required = true)
2323
String artifactDirectory;
2424

2525
// Maven Repo Deployment specification
@@ -35,7 +35,7 @@ public class DeployCommand implements Runnable {
3535
@CommandLine.Option(names = "--mvn-settings")
3636
String mvnSettings;
3737

38-
@CommandLine.Option(names = "--mvn-repo")
38+
@CommandLine.Option(names = "--mvn-repo", required = true)
3939
String mvnRepo;
4040

4141
@CommandLine.Option(names = "--server-id")
@@ -59,7 +59,7 @@ public void run() {
5959
}
6060
System.setProperty("maven.settings", mvnSettings);
6161
}
62-
if (isNotEmpty(accessToken)) {
62+
if (accessToken.isPresent()) {
6363
String servers = """
6464
<settings>
6565
<!--
@@ -91,12 +91,9 @@ public void run() {
9191
System.setProperty("maven.settings", settings.toString());
9292
}
9393
}
94-
if (isNotEmpty(mvnRepo)) {
95-
// Maven Repo Deployment
96-
MavenRepositoryDeployer deployer = new MavenRepositoryDeployer(mvnCtx, mvnUser, mvnPassword.orElse(""), mvnRepo, serverId, deploymentPath);
97-
deployer.deploy();
98-
}
99-
94+
// Maven Repo Deployment
95+
MavenRepositoryDeployer deployer = new MavenRepositoryDeployer(mvnCtx, mvnUser, mvnPassword.orElse(""), mvnRepo, serverId, deploymentPath);
96+
deployer.deploy();
10097
} catch (Exception e) {
10198
Log.error("Deployment failed", e);
10299
throw new RuntimeException(e);

java-components/build-request-processor/src/test/java/com/redhat/hacbs/container/deploy/MavenDeployTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void testDeploy() throws IOException {
6464
DeployCommand deployCommand = new DeployCommand();
6565
deployCommand.mvnCtx = mvnContext;
6666
deployCommand.mvnPassword = Optional.empty();
67+
deployCommand.accessToken = Optional.empty();
6768
deployCommand.mvnRepo = deployment.toAbsolutePath().toUri().toString();
6869
deployCommand.artifactDirectory = onDiskRepo.toString();
6970

0 commit comments

Comments
 (0)