Skip to content

Commit d7c9341

Browse files
authored
chore: Clean-up watcher handler client (#519)
* chore: Clean-up watcher handler client * bump klm and listener deps
1 parent 42ef0a6 commit d7c9341

File tree

7 files changed

+9
-28
lines changed

7 files changed

+9
-28
lines changed

runtime-watcher/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ require (
66
github.com/go-logr/logr v1.4.2
77
github.com/go-logr/zapr v1.3.0
88
github.com/google/uuid v1.6.0
9-
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250110082954-314c5d928b9c
10-
github.com/kyma-project/runtime-watcher/listener v0.0.0-20241016074354-1202c46411f6
9+
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250318075553-30eaaad97ff1
10+
github.com/kyma-project/runtime-watcher/listener v0.0.0-20250317130058-42ef0a646046
1111
github.com/onsi/ginkgo/v2 v2.23.0
1212
github.com/onsi/gomega v1.36.2
1313
github.com/prometheus/client_golang v1.21.1

runtime-watcher/go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6262
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
6363
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
6464
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
65-
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250110082954-314c5d928b9c h1:Oai1Ot8D+K+zWCI3+wcI+o4PbO494eu30c1VAg2WWjg=
66-
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250110082954-314c5d928b9c/go.mod h1:flQzAJyHCHjie+EIY7CA+Z4kmRA72GiMRZqKE2xnoq8=
67-
github.com/kyma-project/runtime-watcher/listener v0.0.0-20241016074354-1202c46411f6 h1:lQ4J8KeqUDCJY/e0cd9p1uQxySPVDB6lza+rRjIrJ/8=
68-
github.com/kyma-project/runtime-watcher/listener v0.0.0-20241016074354-1202c46411f6/go.mod h1:DbPx0iy1Xdu1NhFxvWcKoUHYRjmvnP4yzSxF5g4z1rw=
65+
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250318075553-30eaaad97ff1 h1:9vHmPoYn6fxhIVdBrRP2iqUrjTbLXyeTCFOUL1z5Fns=
66+
github.com/kyma-project/lifecycle-manager/api v0.0.0-20250318075553-30eaaad97ff1/go.mod h1:OPHMLeB0fYVzd6GNnbmJmJFIL45IECO4zedNAPPnnpM=
67+
github.com/kyma-project/runtime-watcher/listener v0.0.0-20250317130058-42ef0a646046 h1:03g/tseSGYf0Ob1ZP4qLHxHyqxBEFT0NjVP5frduRGE=
68+
github.com/kyma-project/runtime-watcher/listener v0.0.0-20250317130058-42ef0a646046/go.mod h1:JTkqD1px7OKETXWbXvBqGcZoaKw96S3J+6t/TlKFfNM=
6969
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
7070
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
7171
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=

runtime-watcher/internal/handler.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ const (
4141
namespaceNameEntityCount = 2
4242
)
4343

44-
func NewHandler(client client.Client,
45-
logger logr.Logger,
44+
func NewHandler(logger logr.Logger,
4645
config serverconfig.ServerConfig,
4746
parser requestparser.RequestParser,
4847
metrics watchermetrics.WatcherMetrics,
4948
) *Handler {
5049
return &Handler{
51-
client: client,
5250
logger: logger,
5351
config: config,
5452
requestParser: parser,
@@ -57,7 +55,6 @@ func NewHandler(client client.Client,
5755
}
5856

5957
type Handler struct {
60-
client client.Client
6158
logger logr.Logger
6259
config serverconfig.ServerConfig
6360
requestParser requestparser.RequestParser

runtime-watcher/internal/handler_suite_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
. "github.com/onsi/ginkgo/v2"
1515
. "github.com/onsi/gomega"
16-
"sigs.k8s.io/controller-runtime/pkg/client"
1716
"sigs.k8s.io/controller-runtime/pkg/envtest"
1817
logf "sigs.k8s.io/controller-runtime/pkg/log"
1918
"sigs.k8s.io/controller-runtime/pkg/log/zap"
@@ -30,7 +29,6 @@ var (
3029
kcpRecorder *httptest.ResponseRecorder
3130
kcpMockServer *httptest.Server
3231
testEnv *envtest.Environment
33-
k8sClient client.Client
3432
certProvider tlstest.CertProvider
3533
)
3634

@@ -52,10 +50,6 @@ var _ = BeforeSuite(func() {
5250

5351
Expect(err).NotTo(HaveOccurred())
5452

55-
k8sClient, err = client.New(cfg, client.Options{})
56-
Expect(err).NotTo(HaveOccurred())
57-
Expect(k8sClient).NotTo(BeNil())
58-
5953
kcpTestHandler := BootStrapKcpMockHandlers(moduleName)
6054
kcpRecorder = kcpTestHandler.Recorder
6155

runtime-watcher/internal/handler_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ var _ = Describe("given watched resource", Ordered, func() {
109109
decoder := serializer.NewCodecFactory(runtime.NewScheme()).UniversalDeserializer()
110110
requestParser := requestparser.NewRequestParser(decoder)
111111
metrics := watchermetrics.NewMetrics()
112-
handler := internal.NewHandler(k8sClient, logger, config, *requestParser, *metrics)
112+
handler := internal.NewHandler(logger, config, *requestParser, *metrics)
113113
skrRecorder := httptest.NewRecorder()
114114
handler.Handle(skrRecorder, request)
115115

runtime-watcher/main.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"k8s.io/apimachinery/pkg/runtime/serializer"
2929

3030
ctrl "sigs.k8s.io/controller-runtime"
31-
"sigs.k8s.io/controller-runtime/pkg/client"
3231
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3332

3433
"github.com/kyma-project/runtime-watcher/skr/internal"
@@ -68,14 +67,6 @@ func main() {
6867
}
6968
logger.Info("Server config successfully parsed: " + config.PrettyPrint())
7069

71-
restConfig := ctrl.GetConfigOrDie()
72-
restClient, err := client.New(restConfig, client.Options{})
73-
if err != nil {
74-
logger.Error(err, "rest client could not be determined for skr-webhook")
75-
return
76-
}
77-
logger.Info("REST client initialized")
78-
7970
decoder := serializer.NewCodecFactory(runtime.NewScheme()).UniversalDeserializer()
8071
requestParser := requestparser.NewRequestParser(decoder)
8172
metrics := watchermetrics.NewMetrics()
@@ -95,7 +86,7 @@ func main() {
9586
}()
9687
logger.Info("Metrics server started")
9788

98-
handler := internal.NewHandler(restClient, logger, config, *requestParser, *metrics)
89+
handler := internal.NewHandler(logger, config, *requestParser, *metrics)
9990
http.HandleFunc("/validate/", handler.Handle)
10091
server := http.Server{
10192
Addr: fmt.Sprintf(":%d", config.Port),

runtime-watcher/tests/e2e/utils/utils.go

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ func NewKyma(name, namespace, channel string) *v1beta2.Kyma {
3838
},
3939
Labels: map[string]string{
4040
shared.InstanceIDLabel: instanceIDLabelValue,
41-
shared.SyncLabel: shared.EnableLabelValue,
4241
},
4342
},
4443
Spec: v1beta2.KymaSpec{

0 commit comments

Comments
 (0)