Skip to content

Commit ff59da7

Browse files
ipaqsaCopilot
andauthored
[feature] application hooks (#85)
Signed-off-by: Stepan Paksashvili <stepan.paksashvili@flant.com> Signed-off-by: Stepan Paksashvili <81509933+ipaqsa@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 6a0de0d commit ff59da7

35 files changed

Lines changed: 1496 additions & 582 deletions

examples/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212

1313
[Dockerfile and Makefile for building](https://github.com/deckhouse/module-sdk/tree/main/examples/scripts)
1414

15-
[Module hook example with settings checking](https://github.com/deckhouse/module-sdk/tree/main/examples/settings-check)
15+
[Settings check example](https://github.com/deckhouse/module-sdk/tree/main/examples/settings-check)
16+
17+
[Application hook single file example](https://github.com/deckhouse/module-sdk/tree/main/examples/single-file-app-example)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Single File Application Hooks Example
2+
In this example you can build binary from one file.
3+
4+
### Run
5+
6+
To get list of your registered hooks
7+
```bash
8+
go run . hook list
9+
```
10+
11+
To get configs of your registered hooks
12+
```bash
13+
go run . hook config
14+
```
15+
16+
To dump configs of your registered hooks in file
17+
```bash
18+
go run . hook dump
19+
```
20+
21+
To run registered hook with index '0' (you can see index of your hook in output of "hook list" command)
22+
```bash
23+
go run . hook run 0
24+
```
25+
26+
By default, all logs in hooks are suppressed and he waiting for files in default folders.
27+
To make them available, you must add env variable LOG_LEVEL and CREATE_FILES.
28+
```bash
29+
CREATE_FILES=true LOG_LEVEL=INFO go run . hook run 0
30+
```
31+
32+
### Build
33+
```bash
34+
go build -o example-application-hooks .
35+
```
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
module singlefileexample
2+
3+
go 1.24
4+
5+
require (
6+
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20250814094423-e9f108b41a1a
7+
github.com/deckhouse/module-sdk v0.0.0
8+
github.com/onsi/ginkgo v1.16.5
9+
github.com/onsi/gomega v1.36.1
10+
k8s.io/apimachinery v0.32.10
11+
)
12+
13+
require (
14+
github.com/DataDog/gostackparse v0.7.0 // indirect
15+
github.com/beorn7/perks v1.0.1 // indirect
16+
github.com/caarlos0/env/v11 v11.3.1 // indirect
17+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
18+
github.com/containerd/stargz-snapshotter/estargz v0.16.3 // indirect
19+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
20+
github.com/docker/cli v28.2.2+incompatible // indirect
21+
github.com/docker/distribution v2.8.3+incompatible // indirect
22+
github.com/docker/docker-credential-helpers v0.9.3 // indirect
23+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
24+
github.com/ettle/strcase v0.2.0 // indirect
25+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
26+
github.com/fsnotify/fsnotify v1.7.0 // indirect
27+
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
28+
github.com/go-logr/logr v1.4.3 // indirect
29+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
30+
github.com/go-openapi/jsonreference v0.20.2 // indirect
31+
github.com/go-openapi/swag v0.23.0 // indirect
32+
github.com/gogo/protobuf v1.3.2 // indirect
33+
github.com/gojuno/minimock/v3 v3.4.7 // indirect
34+
github.com/golang/protobuf v1.5.4 // indirect
35+
github.com/google/btree v1.1.3 // indirect
36+
github.com/google/gnostic-models v0.6.8 // indirect
37+
github.com/google/go-cmp v0.7.0 // indirect
38+
github.com/google/go-containerregistry v0.20.6 // indirect
39+
github.com/google/gofuzz v1.2.0 // indirect
40+
github.com/google/uuid v1.6.0 // indirect
41+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
42+
github.com/jonboulle/clockwork v0.4.0 // indirect
43+
github.com/josharian/intern v1.0.0 // indirect
44+
github.com/json-iterator/go v1.1.12 // indirect
45+
github.com/klauspost/compress v1.18.0 // indirect
46+
github.com/mailru/easyjson v0.7.7 // indirect
47+
github.com/mitchellh/go-homedir v1.1.0 // indirect
48+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
49+
github.com/modern-go/reflect2 v1.0.2 // indirect
50+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
51+
github.com/nxadm/tail v1.4.8 // indirect
52+
github.com/opencontainers/go-digest v1.0.0 // indirect
53+
github.com/opencontainers/image-spec v1.1.1 // indirect
54+
github.com/pkg/errors v0.9.1 // indirect
55+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
56+
github.com/prometheus/client_golang v1.20.5 // indirect
57+
github.com/prometheus/client_model v0.6.1 // indirect
58+
github.com/prometheus/common v0.55.0 // indirect
59+
github.com/prometheus/procfs v0.15.1 // indirect
60+
github.com/sergi/go-diff v1.3.1 // indirect
61+
github.com/sirupsen/logrus v1.9.3 // indirect
62+
github.com/spf13/cobra v1.9.1 // indirect
63+
github.com/spf13/pflag v1.0.6 // indirect
64+
github.com/sylabs/oci-tools v0.16.0 // indirect
65+
github.com/tidwall/gjson v1.18.0 // indirect
66+
github.com/tidwall/match v1.1.1 // indirect
67+
github.com/tidwall/pretty v1.2.0 // indirect
68+
github.com/vbatts/tar-split v0.12.1 // indirect
69+
github.com/x448/float16 v0.8.4 // indirect
70+
golang.org/x/net v0.36.0 // indirect
71+
golang.org/x/oauth2 v0.30.0 // indirect
72+
golang.org/x/sync v0.16.0 // indirect
73+
golang.org/x/sys v0.33.0 // indirect
74+
golang.org/x/term v0.29.0 // indirect
75+
golang.org/x/text v0.22.0 // indirect
76+
golang.org/x/time v0.8.0 // indirect
77+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
78+
google.golang.org/protobuf v1.36.3 // indirect
79+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
80+
gopkg.in/inf.v0 v0.9.1 // indirect
81+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
82+
gopkg.in/yaml.v3 v3.0.1 // indirect
83+
gotest.tools/v3 v3.5.1 // indirect
84+
k8s.io/api v0.32.10 // indirect
85+
k8s.io/apiextensions-apiserver v0.32.10 // indirect
86+
k8s.io/client-go v0.32.10 // indirect
87+
k8s.io/klog/v2 v2.130.1 // indirect
88+
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
89+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
90+
sigs.k8s.io/controller-runtime v0.20.4 // indirect
91+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
92+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
93+
sigs.k8s.io/yaml v1.4.0 // indirect
94+
)
95+
96+
replace github.com/deckhouse/deckhouse/dhctl => github.com/deckhouse/deckhouse/dhctl v0.0.0-20241122092255-d267ec38bcdd
97+
98+
replace github.com/deckhouse/module-sdk => ../../../

0 commit comments

Comments
 (0)