Skip to content

Commit c1857de

Browse files
committed
WIP: code review + updated folder structure
Signed-off-by: Tim Ramlot <[email protected]>
1 parent a7aa36a commit c1857de

21 files changed

+863
-534
lines changed

TODO

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- maybe remove dependency on controller-runtime (use client-go directly instead)
2+
- make sure to re-reconcile certificates before they expire
3+
- Can we make the solution leader-election-less? Does it make sense that we use the existing cr leader election or should we create a seperate leader-election just for the logic in this library?
4+
- Scope down controller RBAC to single CA Secret resource.
5+
- Use cli flags in the program to list the injectables, allowing use to scope down the injectable RBAC.

go.mod

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module github.com/cert-manager/webhook-cert-lib
33
go 1.22.0
44

55
require (
6-
github.com/onsi/ginkgo/v2 v2.22.0
7-
github.com/onsi/gomega v1.36.0
6+
github.com/go-logr/logr v1.4.2
87
k8s.io/api v0.31.3
98
k8s.io/apimachinery v0.31.3
109
k8s.io/client-go v0.31.3
@@ -20,19 +19,15 @@ require (
2019
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
2120
github.com/fsnotify/fsnotify v1.7.0 // indirect
2221
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
23-
github.com/go-logr/logr v1.4.2 // indirect
24-
github.com/go-logr/zapr v1.3.0 // indirect
2522
github.com/go-openapi/jsonpointer v0.19.6 // indirect
2623
github.com/go-openapi/jsonreference v0.20.2 // indirect
2724
github.com/go-openapi/swag v0.22.4 // indirect
28-
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
2925
github.com/gogo/protobuf v1.3.2 // indirect
3026
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
3127
github.com/golang/protobuf v1.5.4 // indirect
3228
github.com/google/gnostic-models v0.6.8 // indirect
3329
github.com/google/go-cmp v0.6.0 // indirect
3430
github.com/google/gofuzz v1.2.0 // indirect
35-
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
3631
github.com/google/uuid v1.6.0 // indirect
3732
github.com/imdario/mergo v0.3.6 // indirect
3833
github.com/josharian/intern v1.0.0 // indirect
@@ -41,23 +36,22 @@ require (
4136
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4237
github.com/modern-go/reflect2 v1.0.2 // indirect
4338
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
39+
github.com/onsi/ginkgo/v2 v2.22.0 // indirect
40+
github.com/onsi/gomega v1.36.0 // indirect
4441
github.com/pkg/errors v0.9.1 // indirect
4542
github.com/prometheus/client_golang v1.19.1 // indirect
4643
github.com/prometheus/client_model v0.6.1 // indirect
4744
github.com/prometheus/common v0.55.0 // indirect
4845
github.com/prometheus/procfs v0.15.1 // indirect
4946
github.com/spf13/pflag v1.0.5 // indirect
5047
github.com/x448/float16 v0.8.4 // indirect
51-
go.uber.org/multierr v1.11.0 // indirect
52-
go.uber.org/zap v1.26.0 // indirect
5348
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
5449
golang.org/x/net v0.30.0 // indirect
5550
golang.org/x/oauth2 v0.21.0 // indirect
5651
golang.org/x/sys v0.26.0 // indirect
5752
golang.org/x/term v0.25.0 // indirect
5853
golang.org/x/text v0.19.0 // indirect
5954
golang.org/x/time v0.3.0 // indirect
60-
golang.org/x/tools v0.26.0 // indirect
6155
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
6256
google.golang.org/protobuf v1.35.1 // indirect
6357
gopkg.in/inf.v0 v0.9.1 // indirect

pkg/authority/api.go

Lines changed: 0 additions & 250 deletions
This file was deleted.

pkg/authority/api/api.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
Copyright The cert-manager Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package api
18+
19+
const (
20+
// DynamicAuthoritySecretLabel will - if set to "true" - make the dynamic
21+
// authority CA controller inject and maintain a dynamic CA.
22+
// The label must be added to Secret resource that want to denote that they
23+
// can be directly injected into injectables that have a
24+
// `inject-dynamic-ca-from-secret` label.
25+
// If an injectable references a Secret that does NOT have this annotation,
26+
// the dynamic ca-injector will refuse to inject the secret.
27+
DynamicAuthoritySecretLabel = "cert-manager.io/allow-dynamic-ca-injection"
28+
// WantInjectFromSecretNamespaceLabel is the label that specifies that a
29+
// particular object wants injection of dynamic CAs from secret in
30+
// namespace.
31+
// Must be used in conjunction with WantInjectFromSecretNameLabel.
32+
WantInjectFromSecretNamespaceLabel = "cert-manager.io/inject-dynamic-ca-from-secret-namespace"
33+
// WantInjectFromSecretNameLabel is the label that specifies that a
34+
// particular object wants injection of dynamic CAs from secret with name.
35+
// Must be used in conjunction with WantInjectFromSecretNamespaceLabel.
36+
WantInjectFromSecretNameLabel = "cert-manager.io/inject-dynamic-ca-from-secret-name"
37+
38+
// TLSCABundleKey is used as a data key in Secret resources to store a CA
39+
// certificate bundle.
40+
TLSCABundleKey = "ca-bundle.crt"
41+
42+
// RenewCertificateSecretAnnotation is an annotation that can be set to
43+
// an arbitrary value on a certificate secret to trigger a renewal of the
44+
// certificate managed in the secret.
45+
RenewCertificateSecretAnnotation = "renew.cert-manager.io/requestedAt"
46+
// RenewHandledCertificateSecretAnnotation is an annotation that will be set on a
47+
// certificate secret whenever a new certificate is renewed using the
48+
// RenewCertificateSecretAnnotation annotation.
49+
RenewHandledCertificateSecretAnnotation = "renew.cert-manager.io/lastRequestedAt"
50+
)

0 commit comments

Comments
 (0)