Skip to content

Commit 13d4c0a

Browse files
pkalsi97squakez
authored andcommitted
fix(jvm): consolidate caCert validation to init_containers and update docs
1 parent e07d0da commit 13d4c0a

File tree

10 files changed

+23
-99
lines changed

10 files changed

+23
-99
lines changed

docs/modules/ROOT/partials/apis/camel-k-crds.adoc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7801,8 +7801,7 @@ string
78017801
|
78027802
78037803
7804-
Path to a PEM-encoded CA certificate file. The file must be mounted
7805-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
7804+
Path to a PEM-encoded CA certificate file.
78067805
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
78077806
78087807
|`caCertMountPath` +
@@ -7819,7 +7818,6 @@ string
78197818
78207819
78217820
Required when caCert is set. Path to a file containing the truststore password.
7822-
The file must be mounted by the user using the mount trait.
78237821
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
78247822
78257823

docs/modules/traits/pages/jvm.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ Deprecated: no longer in use.
6464

6565
| jvm.ca-cert
6666
| string
67-
| Path to a PEM-encoded CA certificate file. The file must be mounted
68-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
67+
| Path to a PEM-encoded CA certificate file.
6968
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
7069

7170
| jvm.ca-cert-mount-path
@@ -76,7 +75,6 @@ Default: "/etc/camel/conf.d/_truststore"
7675
| jvm.ca-cert-password
7776
| string
7877
| Required when caCert is set. Path to a file containing the truststore password.
79-
The file must be mounted by the user using the mount trait.
8078
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
8179

8280
|===
@@ -153,4 +151,3 @@ This will automatically:
153151
3. Configure the JVM to use the generated truststore via `-Djavax.net.ssl.trustStore`
154152

155153
NOTE: The `ca-cert-password` option is **required** when using `ca-cert`. Both values must be file paths to the mounted secrets.
156-

helm/camel-k/crds/camel-k-crds.yaml

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4723,8 +4723,7 @@ spec:
47234723
type: array
47244724
caCert:
47254725
description: |-
4726-
Path to a PEM-encoded CA certificate file. The file must be mounted
4727-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
4726+
Path to a PEM-encoded CA certificate file.
47284727
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
47294728
type: string
47304729
caCertMountPath:
@@ -4735,7 +4734,6 @@ spec:
47354734
caCertPassword:
47364735
description: |-
47374736
Required when caCert is set. Path to a file containing the truststore password.
4738-
The file must be mounted by the user using the mount trait.
47394737
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
47404738
type: string
47414739
classpath:
@@ -7146,8 +7144,7 @@ spec:
71467144
type: array
71477145
caCert:
71487146
description: |-
7149-
Path to a PEM-encoded CA certificate file. The file must be mounted
7150-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
7147+
Path to a PEM-encoded CA certificate file.
71517148
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
71527149
type: string
71537150
caCertMountPath:
@@ -7158,7 +7155,6 @@ spec:
71587155
caCertPassword:
71597156
description: |-
71607157
Required when caCert is set. Path to a file containing the truststore password.
7161-
The file must be mounted by the user using the mount trait.
71627158
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
71637159
type: string
71647160
classpath:
@@ -9471,8 +9467,7 @@ spec:
94719467
type: array
94729468
caCert:
94739469
description: |-
9474-
Path to a PEM-encoded CA certificate file. The file must be mounted
9475-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
9470+
Path to a PEM-encoded CA certificate file.
94769471
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
94779472
type: string
94789473
caCertMountPath:
@@ -9483,7 +9478,6 @@ spec:
94839478
caCertPassword:
94849479
description: |-
94859480
Required when caCert is set. Path to a file containing the truststore password.
9486-
The file must be mounted by the user using the mount trait.
94879481
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
94889482
type: string
94899483
classpath:
@@ -11773,8 +11767,7 @@ spec:
1177311767
type: array
1177411768
caCert:
1177511769
description: |-
11776-
Path to a PEM-encoded CA certificate file. The file must be mounted
11777-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
11770+
Path to a PEM-encoded CA certificate file.
1177811771
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
1177911772
type: string
1178011773
caCertMountPath:
@@ -11785,7 +11778,6 @@ spec:
1178511778
caCertPassword:
1178611779
description: |-
1178711780
Required when caCert is set. Path to a file containing the truststore password.
11788-
The file must be mounted by the user using the mount trait.
1178911781
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
1179011782
type: string
1179111783
classpath:
@@ -20909,8 +20901,7 @@ spec:
2090920901
type: array
2091020902
caCert:
2091120903
description: |-
20912-
Path to a PEM-encoded CA certificate file. The file must be mounted
20913-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
20904+
Path to a PEM-encoded CA certificate file.
2091420905
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
2091520906
type: string
2091620907
caCertMountPath:
@@ -20921,7 +20912,6 @@ spec:
2092120912
caCertPassword:
2092220913
description: |-
2092320914
Required when caCert is set. Path to a file containing the truststore password.
20924-
The file must be mounted by the user using the mount trait.
2092520915
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
2092620916
type: string
2092720917
classpath:
@@ -23165,8 +23155,7 @@ spec:
2316523155
type: array
2316623156
caCert:
2316723157
description: |-
23168-
Path to a PEM-encoded CA certificate file. The file must be mounted
23169-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
23158+
Path to a PEM-encoded CA certificate file.
2317023159
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
2317123160
type: string
2317223161
caCertMountPath:
@@ -23177,7 +23166,6 @@ spec:
2317723166
caCertPassword:
2317823167
description: |-
2317923168
Required when caCert is set. Path to a file containing the truststore password.
23180-
The file must be mounted by the user using the mount trait.
2318123169
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
2318223170
type: string
2318323171
classpath:
@@ -33663,8 +33651,7 @@ spec:
3366333651
type: array
3366433652
caCert:
3366533653
description: |-
33666-
Path to a PEM-encoded CA certificate file. The file must be mounted
33667-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
33654+
Path to a PEM-encoded CA certificate file.
3366833655
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
3366933656
type: string
3367033657
caCertMountPath:
@@ -33675,7 +33662,6 @@ spec:
3367533662
caCertPassword:
3367633663
description: |-
3367733664
Required when caCert is set. Path to a file containing the truststore password.
33678-
The file must be mounted by the user using the mount trait.
3367933665
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
3368033666
type: string
3368133667
classpath:
@@ -35851,8 +35837,7 @@ spec:
3585135837
type: array
3585235838
caCert:
3585335839
description: |-
35854-
Path to a PEM-encoded CA certificate file. The file must be mounted
35855-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
35840+
Path to a PEM-encoded CA certificate file.
3585635841
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
3585735842
type: string
3585835843
caCertMountPath:
@@ -35863,7 +35848,6 @@ spec:
3586335848
caCertPassword:
3586435849
description: |-
3586535850
Required when caCert is set. Path to a file containing the truststore password.
35866-
The file must be mounted by the user using the mount trait.
3586735851
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
3586835852
type: string
3586935853
classpath:

pkg/apis/camel/v1/trait/jvm.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ type JVMTrait struct {
4242
Jar string `json:"jar,omitempty" property:"jar"`
4343
// A list of JVM agents to download and execute with format `<agent-name>;<agent-url>[;<jvm-agent-options>]`.
4444
Agents []string `json:"agents,omitempty" property:"agents"`
45-
// Path to a PEM-encoded CA certificate file. The file must be mounted
46-
// by the user using the mount trait (e.g., mount.configs or mount.secrets).
45+
// Path to a PEM-encoded CA certificate file.
4746
// Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
4847
CACert string `json:"caCert,omitempty" property:"ca-cert"`
4948
// The path where the generated truststore will be mounted.
5049
// Default: "/etc/camel/conf.d/_truststore"
5150
CACertMountPath string `json:"caCertMountPath,omitempty" property:"ca-cert-mount-path"`
5251
// Required when caCert is set. Path to a file containing the truststore password.
53-
// The file must be mounted by the user using the mount trait.
5452
// Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
5553
CACertPassword string `json:"caCertPassword,omitempty" property:"ca-cert-password"`
5654
}

pkg/resources/config/crd/bases/camel.apache.org_integrationplatforms.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,7 @@ spec:
14741474
type: array
14751475
caCert:
14761476
description: |-
1477-
Path to a PEM-encoded CA certificate file. The file must be mounted
1478-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
1477+
Path to a PEM-encoded CA certificate file.
14791478
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
14801479
type: string
14811480
caCertMountPath:
@@ -1486,7 +1485,6 @@ spec:
14861485
caCertPassword:
14871486
description: |-
14881487
Required when caCert is set. Path to a file containing the truststore password.
1489-
The file must be mounted by the user using the mount trait.
14901488
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
14911489
type: string
14921490
classpath:
@@ -3897,8 +3895,7 @@ spec:
38973895
type: array
38983896
caCert:
38993897
description: |-
3900-
Path to a PEM-encoded CA certificate file. The file must be mounted
3901-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
3898+
Path to a PEM-encoded CA certificate file.
39023899
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
39033900
type: string
39043901
caCertMountPath:
@@ -3909,7 +3906,6 @@ spec:
39093906
caCertPassword:
39103907
description: |-
39113908
Required when caCert is set. Path to a file containing the truststore password.
3912-
The file must be mounted by the user using the mount trait.
39133909
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
39143910
type: string
39153911
classpath:

pkg/resources/config/crd/bases/camel.apache.org_integrationprofiles.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,8 +1342,7 @@ spec:
13421342
type: array
13431343
caCert:
13441344
description: |-
1345-
Path to a PEM-encoded CA certificate file. The file must be mounted
1346-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
1345+
Path to a PEM-encoded CA certificate file.
13471346
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
13481347
type: string
13491348
caCertMountPath:
@@ -1354,7 +1353,6 @@ spec:
13541353
caCertPassword:
13551354
description: |-
13561355
Required when caCert is set. Path to a file containing the truststore password.
1357-
The file must be mounted by the user using the mount trait.
13581356
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
13591357
type: string
13601358
classpath:
@@ -3644,8 +3642,7 @@ spec:
36443642
type: array
36453643
caCert:
36463644
description: |-
3647-
Path to a PEM-encoded CA certificate file. The file must be mounted
3648-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
3645+
Path to a PEM-encoded CA certificate file.
36493646
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
36503647
type: string
36513648
caCertMountPath:
@@ -3656,7 +3653,6 @@ spec:
36563653
caCertPassword:
36573654
description: |-
36583655
Required when caCert is set. Path to a file containing the truststore password.
3659-
The file must be mounted by the user using the mount trait.
36603656
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
36613657
type: string
36623658
classpath:

pkg/resources/config/crd/bases/camel.apache.org_integrations.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8156,8 +8156,7 @@ spec:
81568156
type: array
81578157
caCert:
81588158
description: |-
8159-
Path to a PEM-encoded CA certificate file. The file must be mounted
8160-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
8159+
Path to a PEM-encoded CA certificate file.
81618160
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
81628161
type: string
81638162
caCertMountPath:
@@ -8168,7 +8167,6 @@ spec:
81688167
caCertPassword:
81698168
description: |-
81708169
Required when caCert is set. Path to a file containing the truststore password.
8171-
The file must be mounted by the user using the mount trait.
81728170
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
81738171
type: string
81748172
classpath:
@@ -10412,8 +10410,7 @@ spec:
1041210410
type: array
1041310411
caCert:
1041410412
description: |-
10415-
Path to a PEM-encoded CA certificate file. The file must be mounted
10416-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
10413+
Path to a PEM-encoded CA certificate file.
1041710414
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
1041810415
type: string
1041910416
caCertMountPath:
@@ -10424,7 +10421,6 @@ spec:
1042410421
caCertPassword:
1042510422
description: |-
1042610423
Required when caCert is set. Path to a file containing the truststore password.
10427-
The file must be mounted by the user using the mount trait.
1042810424
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
1042910425
type: string
1043010426
classpath:

pkg/resources/config/crd/bases/camel.apache.org_pipes.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8212,8 +8212,7 @@ spec:
82128212
type: array
82138213
caCert:
82148214
description: |-
8215-
Path to a PEM-encoded CA certificate file. The file must be mounted
8216-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
8215+
Path to a PEM-encoded CA certificate file.
82178216
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
82188217
type: string
82198218
caCertMountPath:
@@ -8224,7 +8223,6 @@ spec:
82248223
caCertPassword:
82258224
description: |-
82268225
Required when caCert is set. Path to a file containing the truststore password.
8227-
The file must be mounted by the user using the mount trait.
82288226
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
82298227
type: string
82308228
classpath:
@@ -10400,8 +10398,7 @@ spec:
1040010398
type: array
1040110399
caCert:
1040210400
description: |-
10403-
Path to a PEM-encoded CA certificate file. The file must be mounted
10404-
by the user using the mount trait (e.g., mount.configs or mount.secrets).
10401+
Path to a PEM-encoded CA certificate file.
1040510402
Example: "/etc/camel/conf.d/_secrets/my-ca/ca.crt"
1040610403
type: string
1040710404
caCertMountPath:
@@ -10412,7 +10409,6 @@ spec:
1041210409
caCertPassword:
1041310410
description: |-
1041410411
Required when caCert is set. Path to a file containing the truststore password.
10415-
The file must be mounted by the user using the mount trait.
1041610412
Example: "/etc/camel/conf.d/_secrets/truststore-pass/password"
1041710413
type: string
1041810414
classpath:

pkg/trait/jvm.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
158158
args = append(args, httpProxyArgs...)
159159
}
160160

161-
caCertArgs, err := t.configureCaCert()
162-
if err != nil {
163-
return err
164-
}
165-
if caCertArgs != nil {
161+
if caCertArgs := t.configureCaCert(); caCertArgs != nil {
166162
args = append(args, caCertArgs...)
167163
}
168164

@@ -379,17 +375,13 @@ func getLegacyCamelQuarkusDependenciesPaths() *sets.Set {
379375
}
380376

381377
// configureCACert configures the CA certificate truststore and returns the JVM arguments.
382-
func (t *jvmTrait) configureCaCert() ([]string, error) {
383-
if err := t.validateCACertConfig(); err != nil {
384-
return nil, err
385-
}
386-
378+
func (t *jvmTrait) configureCaCert() []string {
387379
if t.CACert == "" {
388-
return nil, nil
380+
return nil
389381
}
390382

391383
return []string{
392384
"-Djavax.net.ssl.trustStore=" + t.getTrustStorePath(),
393385
fmt.Sprintf("-Djavax.net.ssl.trustStorePassword=$(%s)", truststorePasswordEnvVar),
394-
}, nil
386+
}
395387
}

0 commit comments

Comments
 (0)