Skip to content

Commit bea5594

Browse files
authored
Merge pull request #51 from uswitch/feat/lifecycleSleep
Add support for `lifecycle.preStop.Sleep` and bump dependencies
2 parents f2c59fc + ba75424 commit bea5594

File tree

8 files changed

+268
-266
lines changed

8 files changed

+268
-266
lines changed

.github/workflows/push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.20"
16+
go-version: "1.23"
1717
- run: make test
1818

1919
build:
@@ -22,7 +22,7 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- uses: actions/setup-go@v5
2424
with:
25-
go-version: "1.20"
25+
go-version: "1.23"
2626
- run: make bin/vault-webhook-linux-amd64
2727
- uses: actions/upload-artifact@v4
2828
with:

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
golang 1.20
1+
golang 1.23

controller.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ type bindingAggregator struct {
2222
func NewListWatch(client *webhookclient.Clientset) *bindingAggregator {
2323
binder := &bindingAggregator{}
2424
watcher := cache.NewListWatchFromClient(client.VaultwebhookV1alpha1().RESTClient(), "databasecredentialbindings", "", fields.Everything())
25-
binder.store, binder.controller = cache.NewIndexerInformer(watcher, &v1alpha1.DatabaseCredentialBinding{}, time.Minute, binder, cache.Indexers{})
25+
26+
informerOptions := cache.InformerOptions{
27+
ListerWatcher: watcher,
28+
ObjectType: &v1alpha1.DatabaseCredentialBinding{},
29+
Handler: binder,
30+
ResyncPeriod: time.Minute,
31+
Indexers: cache.Indexers{},
32+
}
33+
binder.store, binder.controller = cache.NewInformerWithOptions(informerOptions)
2634
cacheSize := prometheus.NewCounterFunc(
2735
prometheus.CounterOpts{
2836
Name: "database_credential_binding_cache_size",
@@ -34,7 +42,8 @@ func NewListWatch(client *webhookclient.Clientset) *bindingAggregator {
3442
return binder
3543
}
3644

37-
func (b *bindingAggregator) OnAdd(obj interface{}) {
45+
// https://pkg.go.dev/k8s.io/client-go/tools/cache#ResourceEventHandler
46+
func (b *bindingAggregator) OnAdd(obj interface{}, isInInitialList bool) {
3847
log.Debugf("adding %+v", obj)
3948
}
4049

crd.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,26 @@ spec:
4141
preStop:
4242
description: This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention and others
4343
type: object
44+
oneOf:
45+
- required: ["exec"]
46+
- required: ["sleep"]
4447
properties:
4548
exec:
4649
description: Executes a specific command, inside the cgroups and namespaces of the Container.
4750
type: object
4851
properties:
4952
command:
5053
type: array
54+
minItems: 1
5155
items:
5256
type: string
57+
sleep:
58+
description: Pauses the container for a specified duration..
59+
type: object
60+
properties:
61+
seconds:
62+
type: integer
63+
minimum: 1
5364
names:
5465
kind: DatabaseCredentialBinding
5566
plural: databasecredentialbindings

go.mod

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,76 @@
11
module github.com/uswitch/vault-webhook
22

3-
go 1.20
3+
go 1.23.0
4+
5+
toolchain go1.23.6
46

57
require (
6-
github.com/prometheus/client_golang v1.15.1
7-
github.com/sirupsen/logrus v1.9.0
8+
github.com/prometheus/client_golang v1.20.5
9+
github.com/sirupsen/logrus v1.9.3
810
gopkg.in/alecthomas/kingpin.v2 v2.2.6
911
gopkg.in/fsnotify.v1 v1.4.7
10-
k8s.io/api v0.24.15
11-
k8s.io/apimachinery v0.24.15
12-
k8s.io/client-go v0.24.15
13-
k8s.io/code-generator v0.24.15
14-
sigs.k8s.io/controller-runtime v0.12.3
12+
k8s.io/api v0.32.2
13+
k8s.io/apimachinery v0.32.2
14+
k8s.io/client-go v0.32.2
15+
k8s.io/code-generator v0.32.2
16+
sigs.k8s.io/controller-runtime v0.20.2
1517
)
1618

1719
require (
1820
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
19-
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
21+
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
2022
github.com/beorn7/perks v1.0.1 // indirect
21-
github.com/cespare/xxhash/v2 v2.2.0 // indirect
22-
github.com/davecgh/go-spew v1.1.1 // indirect
23-
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
24-
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
25-
github.com/fsnotify/fsnotify v1.6.0 // indirect
26-
github.com/go-logr/logr v1.2.4 // indirect
27-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
28-
github.com/go-openapi/jsonreference v0.20.1 // indirect
29-
github.com/go-openapi/swag v0.22.3 // indirect
23+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
24+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
25+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
26+
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
27+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
28+
github.com/fsnotify/fsnotify v1.8.0 // indirect
29+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
30+
github.com/go-logr/logr v1.4.2 // indirect
31+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
32+
github.com/go-openapi/jsonreference v0.21.0 // indirect
33+
github.com/go-openapi/swag v0.23.0 // indirect
3034
github.com/gogo/protobuf v1.3.2 // indirect
31-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
32-
github.com/golang/protobuf v1.5.3 // indirect
33-
github.com/google/gnostic v0.5.7-v3refs // indirect
34-
github.com/google/go-cmp v0.5.9 // indirect
35-
github.com/google/gofuzz v1.1.0 // indirect
36-
github.com/google/uuid v1.3.0 // indirect
37-
github.com/imdario/mergo v0.3.12 // indirect
35+
github.com/golang/protobuf v1.5.4 // indirect
36+
github.com/google/btree v1.1.3 // indirect
37+
github.com/google/gnostic-models v0.6.9 // indirect
38+
github.com/google/go-cmp v0.6.0 // indirect
39+
github.com/google/gofuzz v1.2.0 // indirect
40+
github.com/google/uuid v1.6.0 // indirect
3841
github.com/josharian/intern v1.0.0 // indirect
3942
github.com/json-iterator/go v1.1.12 // indirect
40-
github.com/mailru/easyjson v0.7.7 // indirect
41-
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
43+
github.com/klauspost/compress v1.17.11 // indirect
44+
github.com/mailru/easyjson v0.9.0 // indirect
4245
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4346
github.com/modern-go/reflect2 v1.0.2 // indirect
4447
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4548
github.com/pkg/errors v0.9.1 // indirect
46-
github.com/prometheus/client_model v0.4.0 // indirect
47-
github.com/prometheus/common v0.42.0 // indirect
48-
github.com/prometheus/procfs v0.9.0 // indirect
49-
github.com/rogpeppe/go-internal v1.11.0 // indirect
50-
github.com/spf13/pflag v1.0.5 // indirect
51-
golang.org/x/mod v0.10.0 // indirect
52-
golang.org/x/net v0.10.0 // indirect
53-
golang.org/x/oauth2 v0.5.0 // indirect
54-
golang.org/x/sys v0.8.0 // indirect
55-
golang.org/x/term v0.8.0 // indirect
56-
golang.org/x/text v0.9.0 // indirect
57-
golang.org/x/time v0.3.0 // indirect
58-
golang.org/x/tools v0.9.1 // indirect
59-
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
60-
google.golang.org/appengine v1.6.7 // indirect
61-
google.golang.org/protobuf v1.30.0 // indirect
49+
github.com/prometheus/client_model v0.6.1 // indirect
50+
github.com/prometheus/common v0.62.0 // indirect
51+
github.com/prometheus/procfs v0.15.1 // indirect
52+
github.com/spf13/pflag v1.0.6 // indirect
53+
github.com/x448/float16 v0.8.4 // indirect
54+
golang.org/x/mod v0.21.0 // indirect
55+
golang.org/x/net v0.35.0 // indirect
56+
golang.org/x/oauth2 v0.26.0 // indirect
57+
golang.org/x/sync v0.11.0 // indirect
58+
golang.org/x/sys v0.30.0 // indirect
59+
golang.org/x/term v0.29.0 // indirect
60+
golang.org/x/text v0.22.0 // indirect
61+
golang.org/x/time v0.10.0 // indirect
62+
golang.org/x/tools v0.26.0 // indirect
63+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
64+
google.golang.org/protobuf v1.36.5 // indirect
65+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
6266
gopkg.in/inf.v0 v0.9.1 // indirect
63-
gopkg.in/yaml.v2 v2.4.0 // indirect
6467
gopkg.in/yaml.v3 v3.0.1 // indirect
65-
k8s.io/apiextensions-apiserver v0.24.15 // indirect
66-
k8s.io/component-base v0.24.15 // indirect
67-
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect
68-
k8s.io/klog/v2 v2.90.1 // indirect
69-
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
70-
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
71-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
72-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
73-
sigs.k8s.io/yaml v1.3.0 // indirect
74-
)
68+
k8s.io/apiextensions-apiserver v0.32.2 // indirect
69+
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
70+
k8s.io/klog/v2 v2.130.1 // indirect
71+
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7 // indirect
72+
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
73+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
74+
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect
75+
sigs.k8s.io/yaml v1.4.0 // indirect
76+
)

0 commit comments

Comments
 (0)