Skip to content

Commit d0c6963

Browse files
dongjiang1989jiang dong
andauthored
Update golang version 1.24 && controller-runtime version v0.20.4 (#20)
* update golang version 1.24 && controller-runtime Signed-off-by: dongjiang <[email protected]> * add case Signed-off-by: dongjiang <[email protected]> * update golang v1.24 Signed-off-by: dongjiang <[email protected]> * update version Signed-off-by: jiang dong <[email protected]> --------- Signed-off-by: dongjiang <[email protected]> Signed-off-by: jiang dong <[email protected]> Co-authored-by: jiang dong <[email protected]>
1 parent 7385872 commit d0c6963

File tree

2,839 files changed

+225174
-112572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,839 files changed

+225174
-112572
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ updates:
1717
directory: /
1818
schedule:
1919
interval: daily
20+
21+
- package-ecosystem: docker
22+
directory: /hack/build/
23+
schedule:
24+
interval: daily

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
-
3838
name: Checkout
3939
uses: actions/checkout@v4
40+
- name: install Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version-file: go.mod
4044
-
4145
name: Set up QEMU
4246
uses: docker/setup-qemu-action@v3

.github/workflows/release.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ jobs:
3535
- id: git-branch
3636
run: |
3737
echo "git-branch=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')" >> "$GITHUB_OUTPUT"
38+
- name: install Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version-file: go.mod
3842
-
3943
name: Set up QEMU
4044
uses: docker/setup-qemu-action@v3

cmd/main.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ import (
2424
// to ensure that exec-entrypoint and run can make use of them.
2525
_ "k8s.io/client-go/plugin/pkg/client/auth"
2626

27+
corev1 "k8s.io/api/core/v1"
2728
"k8s.io/apimachinery/pkg/runtime"
2829
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2930
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3031
ctrl "sigs.k8s.io/controller-runtime"
32+
"sigs.k8s.io/controller-runtime/pkg/builder"
3133
"sigs.k8s.io/controller-runtime/pkg/healthz"
3234
"sigs.k8s.io/controller-runtime/pkg/log/zap"
35+
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
36+
"sigs.k8s.io/controller-runtime/pkg/webhook"
3337

3438
injector "github.com/kubeservice-stack/custom-limit-range/pkg/injector"
3539
customv1 "github.com/kubeservice-stack/custom-limit-range/pkg/webhook"
36-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3740
)
3841

3942
var (
@@ -67,13 +70,18 @@ func main() {
6770
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
6871

6972
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
70-
Scheme: scheme,
71-
MetricsBindAddress: metricsAddr,
72-
Port: 9443,
73+
Scheme: scheme,
74+
Metrics: metricsserver.Options{
75+
BindAddress: metricsAddr,
76+
},
77+
WebhookServer: webhook.NewServer(
78+
webhook.Options{
79+
CertDir: certsDir,
80+
Port: 9443,
81+
}),
7382
HealthProbeBindAddress: probeAddr,
7483
LeaderElection: enableLeaderElection,
7584
LeaderElectionID: "28efb73e.cmss.com",
76-
CertDir: certsDir,
7785
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
7886
// when the Manager ends. This requires the binary to immediately end when the
7987
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
@@ -91,13 +99,6 @@ func main() {
9199
os.Exit(1)
92100
}
93101

94-
mgr.GetWebhookServer().Register("/mutate", &webhook.Admission{Handler: injector.NewPodAnnotatorMutate(mgr.GetClient())})
95-
96-
if err = (&customv1.CustomLimitRange{}).SetupWebhookWithManager(mgr); err != nil {
97-
setupLog.Error(err, "unable to create webhook", "webhook", "CustomLimitRange")
98-
os.Exit(1)
99-
}
100-
101102
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
102103
setupLog.Error(err, "unable to set up health check")
103104
os.Exit(1)
@@ -107,6 +108,20 @@ func main() {
107108
os.Exit(1)
108109
}
109110

111+
if err = (&customv1.CustomLimitRange{}).SetupWebhookWithManager(mgr); err != nil {
112+
setupLog.Error(err, "unable to create webhook", "webhook", "CustomLimitRange")
113+
os.Exit(1)
114+
}
115+
116+
if err := builder.WebhookManagedBy(mgr).
117+
For(&corev1.Pod{}).
118+
WithCustomPath("/mutate").
119+
WithDefaulter(&injector.PodAnnotator{Client: mgr.GetClient()}).
120+
Complete(); err != nil {
121+
setupLog.Error(err, "unable to create webhook", "webhook", "Pod")
122+
os.Exit(1)
123+
}
124+
110125
setupLog.Info("starting manager")
111126
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
112127
setupLog.Error(err, "problem running manager")

go.mod

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,70 @@
11
module github.com/kubeservice-stack/custom-limit-range
22

3-
go 1.18
3+
go 1.24
44

55
require (
66
github.com/jessevdk/go-flags v1.6.1
77
github.com/sirupsen/logrus v1.9.3
88
github.com/stretchr/testify v1.10.0
9-
k8s.io/api v0.26.1
10-
k8s.io/apimachinery v0.26.1
11-
k8s.io/client-go v0.26.1
12-
sigs.k8s.io/controller-runtime v0.14.5
9+
k8s.io/api v0.32.2
10+
k8s.io/apimachinery v0.32.2
11+
k8s.io/client-go v0.32.2
12+
sigs.k8s.io/controller-runtime v0.20.4
1313
)
1414

1515
require (
1616
github.com/beorn7/perks v1.0.1 // indirect
17-
github.com/cespare/xxhash/v2 v2.1.2 // indirect
18-
github.com/davecgh/go-spew v1.1.1 // indirect
19-
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
20-
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
21-
github.com/fsnotify/fsnotify v1.6.0 // indirect
22-
github.com/go-logr/logr v1.2.3 // indirect
23-
github.com/go-logr/zapr v1.2.3 // indirect
24-
github.com/go-openapi/jsonpointer v0.19.5 // indirect
25-
github.com/go-openapi/jsonreference v0.20.0 // indirect
26-
github.com/go-openapi/swag v0.19.14 // indirect
17+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
18+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
19+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
20+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
21+
github.com/fsnotify/fsnotify v1.7.0 // indirect
22+
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
25+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
26+
github.com/go-openapi/jsonreference v0.20.2 // indirect
27+
github.com/go-openapi/swag v0.23.0 // indirect
2728
github.com/gogo/protobuf v1.3.2 // indirect
28-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
29-
github.com/golang/protobuf v1.5.2 // indirect
30-
github.com/google/gnostic v0.5.7-v3refs // indirect
31-
github.com/google/go-cmp v0.5.9 // indirect
32-
github.com/google/gofuzz v1.1.0 // indirect
33-
github.com/google/uuid v1.1.2 // indirect
34-
github.com/imdario/mergo v0.3.12 // indirect
29+
github.com/golang/protobuf v1.5.4 // indirect
30+
github.com/google/btree v1.1.3 // indirect
31+
github.com/google/gnostic-models v0.6.8 // indirect
32+
github.com/google/go-cmp v0.6.0 // indirect
33+
github.com/google/gofuzz v1.2.0 // indirect
34+
github.com/google/uuid v1.6.0 // indirect
3535
github.com/josharian/intern v1.0.0 // indirect
3636
github.com/json-iterator/go v1.1.12 // indirect
37-
github.com/mailru/easyjson v0.7.6 // indirect
38-
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
37+
github.com/mailru/easyjson v0.7.7 // indirect
3938
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4039
github.com/modern-go/reflect2 v1.0.2 // indirect
4140
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
4241
github.com/pkg/errors v0.9.1 // indirect
43-
github.com/pmezard/go-difflib v1.0.0 // indirect
44-
github.com/prometheus/client_golang v1.14.0 // indirect
45-
github.com/prometheus/client_model v0.3.0 // indirect
46-
github.com/prometheus/common v0.37.0 // indirect
47-
github.com/prometheus/procfs v0.8.0 // indirect
42+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
43+
github.com/prometheus/client_golang v1.19.1 // indirect
44+
github.com/prometheus/client_model v0.6.1 // indirect
45+
github.com/prometheus/common v0.55.0 // indirect
46+
github.com/prometheus/procfs v0.15.1 // indirect
4847
github.com/spf13/pflag v1.0.5 // indirect
49-
go.uber.org/atomic v1.7.0 // indirect
50-
go.uber.org/multierr v1.6.0 // indirect
51-
go.uber.org/zap v1.24.0 // indirect
48+
github.com/x448/float16 v0.8.4 // indirect
49+
go.uber.org/multierr v1.11.0 // indirect
50+
go.uber.org/zap v1.27.0 // indirect
5251
golang.org/x/net v0.36.0 // indirect
53-
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
52+
golang.org/x/oauth2 v0.23.0 // indirect
53+
golang.org/x/sync v0.11.0 // indirect
5454
golang.org/x/sys v0.30.0 // indirect
5555
golang.org/x/term v0.29.0 // indirect
5656
golang.org/x/text v0.22.0 // indirect
57-
golang.org/x/time v0.3.0 // indirect
58-
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
59-
google.golang.org/appengine v1.6.7 // indirect
60-
google.golang.org/protobuf v1.33.0 // indirect
57+
golang.org/x/time v0.7.0 // indirect
58+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
59+
google.golang.org/protobuf v1.35.1 // indirect
60+
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
6161
gopkg.in/inf.v0 v0.9.1 // indirect
62-
gopkg.in/yaml.v2 v2.4.0 // indirect
6362
gopkg.in/yaml.v3 v3.0.1 // indirect
64-
k8s.io/apiextensions-apiserver v0.26.1 // indirect
65-
k8s.io/component-base v0.26.1 // indirect
66-
k8s.io/klog/v2 v2.80.1 // indirect
67-
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
68-
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
69-
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
70-
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
71-
sigs.k8s.io/yaml v1.3.0 // indirect
63+
k8s.io/apiextensions-apiserver v0.32.1 // indirect
64+
k8s.io/klog/v2 v2.130.1 // indirect
65+
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
66+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
67+
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
68+
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
69+
sigs.k8s.io/yaml v1.4.0 // indirect
7270
)

0 commit comments

Comments
 (0)