Skip to content

Commit cd2a4df

Browse files
committed
add API CA certs only feature
Signed-off-by: Oleksandr Krutko <[email protected]>
1 parent 1fecb12 commit cd2a4df

File tree

15 files changed

+254
-3
lines changed

15 files changed

+254
-3
lines changed

deploy/charts/trust-manager/templates/crd-trust.cert-manager.io_bundles.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,9 @@ spec:
391391
- key
392392
type: object
393393
type: object
394+
useCACertsOnly:
395+
description: Use only CAs certificates in a resulting Bundle
396+
type: boolean
394397
required:
395398
- sources
396399
type: object

deploy/crds/trust-manager.io_clusterbundles.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ spec:
419419
- message: 'any of the following fields must be provided: [configMap,
420420
secret]'
421421
rule: '[has(self.configMap), has(self.secret)].exists(x,x)'
422+
useCACertsOnly:
423+
description: Use only CAs certificates in a resulting Bundle
424+
type: boolean
422425
type: object
423426
status:
424427
description: Status of the Bundle. This is set and managed automatically.

deploy/crds/trust.cert-manager.io_bundles.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ spec:
409409
- key
410410
type: object
411411
type: object
412+
useCACertsOnly:
413+
description: Use only CAs certificates in a resulting Bundle
414+
type: boolean
412415
required:
413416
- sources
414417
type: object

pkg/apis/trust/v1alpha1/types_bundle.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ type BundleSpec struct {
6868
// Target is the target location in all namespaces to sync source data to.
6969
// +optional
7070
Target BundleTarget `json:"target,omitzero"`
71+
72+
// Use only CAs certificates in a resulting Bundle
73+
// +optional
74+
UseCACertsOnly bool `json:"useCACertsOnly"`
7175
}
7276

7377
// BundleSource is the set of sources whose data will be appended and synced to

pkg/apis/trust/v1alpha1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/trustmanager/v1alpha2/types_cluster_bundle.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ type BundleSpec struct {
8484
// Target is the target location in all namespaces to sync source data to.
8585
// +optional
8686
Target BundleTarget `json:"target,omitzero"`
87+
88+
// Use only CAs certificates in a resulting Bundle
89+
// +optional
90+
UseCACertsOnly bool `json:"useCACertsOnly"`
8791
}
8892

8993
// BundleSource is the set of sources whose data will be appended and synced to

pkg/applyconfigurations/trust/v1alpha1/bundlespec.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/applyconfigurations/trustmanager/v1alpha2/bundlespec.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bundle/bundle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func (b *bundle) reconcileBundle(ctx context.Context, req ctrl.Request) (statusP
105105
statusPatch = &trustapi.BundleStatus{
106106
DefaultCAPackageVersion: bundle.Status.DefaultCAPackageVersion,
107107
}
108-
resolvedBundle, err := b.bundleBuilder.BuildBundle(ctx, bundle.Spec.Sources)
108+
resolvedBundle, err := b.bundleBuilder.BuildBundle(ctx, bundle.Spec)
109109

110110
if err != nil {
111111
var reason, message string

pkg/bundle/internal/source/source.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,19 @@ type BundleBuilder struct {
5555
DefaultPackage *fspkg.Package
5656

5757
controller.Options
58+
59+
// Use only CAs certificates
60+
UseCACertsOnly bool
5861
}
5962

6063
// BuildBundle retrieves and concatenates all source bundle data for this Bundle object.
6164
// Each source data is validated and pruned to ensure that all certificates within are valid.
62-
func (b *BundleBuilder) BuildBundle(ctx context.Context, sources []trustapi.BundleSource) (BundleData, error) {
65+
func (b *BundleBuilder) BuildBundle(ctx context.Context, bundle trustapi.BundleSpec) (BundleData, error) {
6366
var resolvedBundle BundleData
67+
var sources = bundle.Sources
6468
resolvedBundle.CertPool = util.NewCertPool(
6569
util.WithFilteredExpiredCerts(b.FilterExpiredCerts),
70+
util.WithCACertsOnly(bundle.UseCACertsOnly),
6671
util.WithLogger(logf.FromContext(ctx).WithName("cert-pool")),
6772
)
6873

0 commit comments

Comments
 (0)