Skip to content

Commit 68bffd3

Browse files
committed
chore: bump up operator-sdk to v1.41.x
Signed-off-by: vprashar2929 <[email protected]>
1 parent 8f6b9ad commit 68bffd3

File tree

45 files changed

+1113
-552
lines changed

Some content is hidden

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

45 files changed

+1113
-552
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ ifeq (,$(shell which opm 2>/dev/null))
461461
set -e ;\
462462
mkdir -p $(dir $(OPM)) ;\
463463
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
464-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\
464+
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55.0/$${OS}-$${ARCH}-opm ;\
465465
chmod +x $(OPM) ;\
466466
}
467467
else

api/v1alpha1/power_monitor_webhook.go

Lines changed: 69 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package v1alpha1
55

66
import (
7+
"context"
78
"fmt"
89

910
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -30,55 +31,99 @@ var DefaultSecurityConfig = SecurityConfig{
3031

3132
var pmonLog = logf.Log.WithName("power-monitor-resource")
3233

33-
func (r *PowerMonitor) SetupWebhookWithManager(mgr ctrl.Manager) error {
34-
return ctrl.NewWebhookManagedBy(mgr).
35-
For(r).
34+
// SetupWebhookWithManager registers the webhook for PowerMonitor in the manager.
35+
func SetupWebhookWithManager(mgr ctrl.Manager) error {
36+
return ctrl.NewWebhookManagedBy(mgr).For(&PowerMonitor{}).
37+
WithValidator(&PowerMonitorCustomValidator{}).
38+
WithDefaulter(&PowerMonitorCustomDefaulter{}).
3639
Complete()
3740
}
3841

3942
// +kubebuilder:webhook:path=/mutate-kepler-system-sustainable-computing-io-v1alpha1-powermonitor,mutating=true,failurePolicy=fail,sideEffects=None,groups=kepler.system.sustainable.computing.io,resources=powermonitors,verbs=create;update,versions=v1alpha1,name=mpowermonitor.kb.io,admissionReviewVersions=v1
4043

41-
var _ webhook.Defaulter = &PowerMonitor{}
44+
// PowerMonitorCustomDefaulter struct is responsible for setting default values on the custom resource of the
45+
// Kind PowerMonitor when those are created or updated.
46+
//
47+
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
48+
// as it is used only for temporary operations and does not need to be deeply copied.
49+
type PowerMonitorCustomDefaulter struct {
50+
// TODO(user): Add more fields as needed for defaulting
51+
}
52+
53+
var _ webhook.CustomDefaulter = &PowerMonitorCustomDefaulter{}
4254

43-
// Default implements webhook.Defaulter so a webhook will be registered for the type
44-
func (r *PowerMonitor) Default() {
45-
pmonLog.Info("default", "name", r.Name)
46-
if r.Spec.Kepler.Deployment.Security.Mode == "" {
55+
// Default implements webhook.CustomDefaulter so a webhook will be registered for the Kind PowerMonitor.
56+
func (d *PowerMonitorCustomDefaulter) Default(_ context.Context, obj runtime.Object) error {
57+
powerMonitor, ok := obj.(*PowerMonitor)
58+
59+
if !ok {
60+
return fmt.Errorf("expected a PowerMonitor object but got %T", obj)
61+
}
62+
pmonLog.Info("Defaulting for PowerMonitor", "name", powerMonitor.GetName())
63+
64+
if powerMonitor.Spec.Kepler.Deployment.Security.Mode == "" {
4765
pmonLog.Info("default", "mode", DefaultSecurityConfig.Mode)
48-
r.Spec.Kepler.Deployment.Security.Mode = DefaultSecurityConfig.Mode
66+
powerMonitor.Spec.Kepler.Deployment.Security.Mode = DefaultSecurityConfig.Mode
4967
}
50-
if r.Spec.Kepler.Deployment.Security.AllowedSANames == nil {
68+
if powerMonitor.Spec.Kepler.Deployment.Security.AllowedSANames == nil {
5169
pmonLog.Info("default", "allowed sa", DefaultSecurityConfig.AllowedSANames)
52-
r.Spec.Kepler.Deployment.Security.AllowedSANames = DefaultSecurityConfig.AllowedSANames
70+
powerMonitor.Spec.Kepler.Deployment.Security.AllowedSANames = DefaultSecurityConfig.AllowedSANames
5371
}
72+
73+
return nil
5474
}
5575

5676
// +kubebuilder:webhook:path=/validate-kepler-system-sustainable-computing-io-v1alpha1-powermonitor,mutating=false,failurePolicy=fail,sideEffects=None,groups=kepler.system.sustainable.computing.io,resources=powermonitors,verbs=create;update;delete,versions=v1alpha1,name=vpowermonitor.kb.io,admissionReviewVersions=v1
5777

58-
var _ webhook.Validator = &PowerMonitor{}
78+
// PowerMonitorCustomValidator struct is responsible for validating the PowerMonitor resource
79+
// when it is created, updated, or deleted.
80+
//
81+
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
82+
// as this struct is used only for temporary operations and does not need to be deeply copied.
83+
type PowerMonitorCustomValidator struct {
84+
// TODO(user): Add more fields as needed for validation
85+
}
5986

60-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
61-
func (r *PowerMonitor) ValidateCreate() (admission.Warnings, error) {
62-
pmonLog.Info("validate create", "name", r.Name)
87+
var _ webhook.CustomValidator = &PowerMonitorCustomValidator{}
6388

64-
// Example: Enforce a specific name if needed
65-
if r.Name != PowerMonitorInstanceName {
66-
return nil, apierrors.NewBadRequest(fmt.Sprintf("invalid name %q; name must be %q", r.Name, PowerMonitorInstanceName))
89+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type PowerMonitor.
90+
func (v *PowerMonitorCustomValidator) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
91+
powerMonitor, ok := obj.(*PowerMonitor)
92+
if !ok {
93+
return nil, fmt.Errorf("expected a PowerMonitor object but got %T", obj)
94+
}
95+
pmonLog.Info("Validation for PowerMonitor upon creation", "name", powerMonitor.GetName())
96+
97+
// Enforce a specific name if needed
98+
if powerMonitor.Name != PowerMonitorInstanceName {
99+
return nil, apierrors.NewBadRequest(fmt.Sprintf("invalid name %q; name must be %q", powerMonitor.Name, PowerMonitorInstanceName))
67100
}
68101

69102
return nil, nil
70103
}
71104

72-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
73-
func (r *PowerMonitor) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
74-
pmonLog.Info("validate update", "name", r.Name)
105+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type PowerMonitor.
106+
func (v *PowerMonitorCustomValidator) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
107+
powerMonitor, ok := newObj.(*PowerMonitor)
108+
if !ok {
109+
return nil, fmt.Errorf("expected a PowerMonitor object for the newObj but got %T", newObj)
110+
}
111+
pmonLog.Info("Validation for PowerMonitor upon update", "name", powerMonitor.GetName())
112+
113+
// TODO(user): fill in your validation logic upon object update.
75114

76115
return nil, nil
77116
}
78117

79-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
80-
func (r *PowerMonitor) ValidateDelete() (admission.Warnings, error) {
81-
pmonLog.Info("validate delete", "name", r.Name)
118+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type PowerMonitor.
119+
func (v *PowerMonitorCustomValidator) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
120+
powerMonitor, ok := obj.(*PowerMonitor)
121+
if !ok {
122+
return nil, fmt.Errorf("expected a PowerMonitor object but got %T", obj)
123+
}
124+
pmonLog.Info("Validation for PowerMonitor upon deletion", "name", powerMonitor.GetName())
125+
126+
// TODO(user): fill in your validation logic upon object deletion.
82127

83128
return nil, nil
84129
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=kepler-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
99
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
10-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.39.1
10+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.41.1
1111
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1212
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4
1313

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/managed-by: kustomize
7+
app.kubernetes.io/name: kepler-operator
8+
name: kepler-operator-kepler-admin-role
9+
rules:
10+
- apiGroups:
11+
- kepler.system.sustainable.computing.io
12+
resources:
13+
- keplers
14+
verbs:
15+
- '*'
16+
- apiGroups:
17+
- kepler.system.sustainable.computing.io
18+
resources:
19+
- keplers/status
20+
verbs:
21+
- get
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
app.kubernetes.io/created-by: kepler-operator
8+
app.kubernetes.io/instance: kepler-editor-role
9+
app.kubernetes.io/managed-by: kustomize
10+
app.kubernetes.io/name: clusterrole
11+
app.kubernetes.io/part-of: kepler-operator
12+
name: kepler-operator-kepler-editor-role
13+
rules:
14+
- apiGroups:
15+
- kepler.system.sustainable.computing.io
16+
resources:
17+
- keplers
18+
verbs:
19+
- create
20+
- delete
21+
- get
22+
- list
23+
- patch
24+
- update
25+
- watch
26+
- apiGroups:
27+
- kepler.system.sustainable.computing.io
28+
resources:
29+
- keplers/status
30+
verbs:
31+
- get
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
labels:
6+
app.kubernetes.io/component: rbac
7+
app.kubernetes.io/created-by: kepler-operator
8+
app.kubernetes.io/instance: kepler-viewer-role
9+
app.kubernetes.io/managed-by: kustomize
10+
app.kubernetes.io/name: clusterrole
11+
app.kubernetes.io/part-of: kepler-operator
12+
name: kepler-operator-kepler-viewer-role
13+
rules:
14+
- apiGroups:
15+
- kepler.system.sustainable.computing.io
16+
resources:
17+
- keplers
18+
verbs:
19+
- get
20+
- list
21+
- watch
22+
- apiGroups:
23+
- kepler.system.sustainable.computing.io
24+
resources:
25+
- keplers/status
26+
verbs:
27+
- get

bundle/manifests/kepler-operator.clusterserviceversion.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ metadata:
2727
capabilities: Seamless Upgrades
2828
categories: Monitoring
2929
containerImage: quay.io/sustainable_computing_io/kepler-operator:0.22.3
30-
createdAt: "2025-10-09T13:54:51Z"
30+
createdAt: "2025-11-13T06:04:17Z"
3131
description: Deploys and Manages Kepler on Kubernetes
32-
operators.operatorframework.io/builder: operator-sdk-v1.39.1
32+
operators.operatorframework.io/builder: operator-sdk-v1.41.1
3333
operators.operatorframework.io/internal-objects: |-
3434
[
3535
"powermonitorinternals.kepler.system.sustainable.computing.io"
@@ -243,12 +243,12 @@ spec:
243243
periodSeconds: 20
244244
name: manager
245245
ports:
246-
- containerPort: 9443
247-
name: webhook-server
248-
protocol: TCP
249246
- containerPort: 8080
250247
name: metrics
251248
protocol: TCP
249+
- containerPort: 9443
250+
name: webhook-server
251+
protocol: TCP
252252
readinessProbe:
253253
httpGet:
254254
path: /readyz

bundle/manifests/kepler.system.sustainable.computing.io_powermonitorinternals.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.17.2
5+
controller-gen.kubebuilder.io/version: v0.19.0
66
creationTimestamp: null
77
name: powermonitorinternals.kepler.system.sustainable.computing.io
88
spec:

bundle/manifests/kepler.system.sustainable.computing.io_powermonitors.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.17.2
5+
controller-gen.kubebuilder.io/version: v0.19.0
66
creationTimestamp: null
77
name: powermonitors.kepler.system.sustainable.computing.io
88
spec:

0 commit comments

Comments
 (0)