Skip to content

Commit fb9b96b

Browse files
authored
Update all dependencies, conforming to the new controller-runtime API (#3949)
1 parent a325cc7 commit fb9b96b

File tree

54 files changed

+20430
-5208
lines changed

Some content is hidden

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

54 files changed

+20430
-5208
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM --platform=$BUILDPLATFORM golang:1.22.4 as builder
2+
FROM --platform=$BUILDPLATFORM golang:1.24.0 as builder
33

44
WORKDIR /workspace
55

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ ifeq (, $(wildcard $(GOBIN)/controller-gen))
320320
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
321321
cd $$CONTROLLER_GEN_TMP_DIR ;\
322322
go mod init tmp ;\
323-
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\
323+
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2 ;\
324324
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
325325
}
326326
endif

apis/actions.github.com/v1alpha1/autoscalinglistener_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ type AutoscalingListenerSpec struct {
6868
// AutoscalingListenerStatus defines the observed state of AutoscalingListener
6969
type AutoscalingListenerStatus struct{}
7070

71-
//+kubebuilder:object:root=true
72-
//+kubebuilder:subresource:status
73-
//+kubebuilder:printcolumn:JSONPath=".spec.githubConfigUrl",name=GitHub Configure URL,type=string
74-
//+kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetNamespace",name=AutoscalingRunnerSet Namespace,type=string
75-
//+kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetName",name=AutoscalingRunnerSet Name,type=string
71+
// +kubebuilder:object:root=true
72+
// +kubebuilder:subresource:status
73+
// +kubebuilder:printcolumn:JSONPath=".spec.githubConfigUrl",name=GitHub Configure URL,type=string
74+
// +kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetNamespace",name=AutoscalingRunnerSet Namespace,type=string
75+
// +kubebuilder:printcolumn:JSONPath=".spec.autoscalingRunnerSetName",name=AutoscalingRunnerSet Name,type=string
7676

7777
// AutoscalingListener is the Schema for the autoscalinglisteners API
7878
type AutoscalingListener struct {
@@ -83,7 +83,7 @@ type AutoscalingListener struct {
8383
Status AutoscalingListenerStatus `json:"status,omitempty"`
8484
}
8585

86-
//+kubebuilder:object:root=true
86+
// +kubebuilder:object:root=true
8787

8888
// AutoscalingListenerList contains a list of AutoscalingListener
8989
type AutoscalingListenerList struct {

apis/actions.github.com/v1alpha1/autoscalingrunnerset_types.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ import (
3131

3232
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
3333

34-
//+kubebuilder:object:root=true
35-
//+kubebuilder:subresource:status
36-
//+kubebuilder:printcolumn:JSONPath=".spec.minRunners",name=Minimum Runners,type=integer
37-
//+kubebuilder:printcolumn:JSONPath=".spec.maxRunners",name=Maximum Runners,type=integer
38-
//+kubebuilder:printcolumn:JSONPath=".status.currentRunners",name=Current Runners,type=integer
39-
//+kubebuilder:printcolumn:JSONPath=".status.state",name=State,type=string
40-
//+kubebuilder:printcolumn:JSONPath=".status.pendingEphemeralRunners",name=Pending Runners,type=integer
41-
//+kubebuilder:printcolumn:JSONPath=".status.runningEphemeralRunners",name=Running Runners,type=integer
42-
//+kubebuilder:printcolumn:JSONPath=".status.finishedEphemeralRunners",name=Finished Runners,type=integer
43-
//+kubebuilder:printcolumn:JSONPath=".status.deletingEphemeralRunners",name=Deleting Runners,type=integer
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
36+
// +kubebuilder:printcolumn:JSONPath=".spec.minRunners",name=Minimum Runners,type=integer
37+
// +kubebuilder:printcolumn:JSONPath=".spec.maxRunners",name=Maximum Runners,type=integer
38+
// +kubebuilder:printcolumn:JSONPath=".status.currentRunners",name=Current Runners,type=integer
39+
// +kubebuilder:printcolumn:JSONPath=".status.state",name=State,type=string
40+
// +kubebuilder:printcolumn:JSONPath=".status.pendingEphemeralRunners",name=Pending Runners,type=integer
41+
// +kubebuilder:printcolumn:JSONPath=".status.runningEphemeralRunners",name=Running Runners,type=integer
42+
// +kubebuilder:printcolumn:JSONPath=".status.finishedEphemeralRunners",name=Finished Runners,type=integer
43+
// +kubebuilder:printcolumn:JSONPath=".status.deletingEphemeralRunners",name=Deleting Runners,type=integer
4444

4545
// AutoscalingRunnerSet is the Schema for the autoscalingrunnersets API
4646
type AutoscalingRunnerSet struct {
@@ -242,7 +242,7 @@ type AutoscalingRunnerSetStatus struct {
242242

243243
// EphemeralRunner counts separated by the stage ephemeral runners are in, taken from the EphemeralRunnerSet
244244

245-
//+optional
245+
// +optional
246246
PendingEphemeralRunners int `json:"pendingEphemeralRunners"`
247247
// +optional
248248
RunningEphemeralRunners int `json:"runningEphemeralRunners"`
@@ -278,7 +278,7 @@ func (ars *AutoscalingRunnerSet) RunnerSetSpecHash() string {
278278
return hash.ComputeTemplateHash(&spec)
279279
}
280280

281-
//+kubebuilder:object:root=true
281+
// +kubebuilder:object:root=true
282282

283283
// AutoscalingRunnerSetList contains a list of AutoscalingRunnerSet
284284
type AutoscalingRunnerSetList struct {

apis/actions.github.com/v1alpha1/ephemeralrunner_types.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525
// It represents the name of the container running the self-hosted runner image.
2626
const EphemeralRunnerContainerName = "runner"
2727

28-
//+kubebuilder:object:root=true
29-
//+kubebuilder:subresource:status
28+
// +kubebuilder:object:root=true
29+
// +kubebuilder:subresource:status
3030
// +kubebuilder:printcolumn:JSONPath=".spec.githubConfigUrl",name="GitHub Config URL",type=string
3131
// +kubebuilder:printcolumn:JSONPath=".status.runnerId",name=RunnerId,type=number
3232
// +kubebuilder:printcolumn:JSONPath=".status.phase",name=Status,type=string
@@ -69,9 +69,6 @@ func (er *EphemeralRunner) HasContainerHookConfigured() bool {
6969

7070
// EphemeralRunnerSpec defines the desired state of EphemeralRunner
7171
type EphemeralRunnerSpec struct {
72-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
73-
// Important: Run "make" to regenerate code after modifying this file
74-
7572
// +required
7673
GitHubConfigUrl string `json:"githubConfigUrl,omitempty"`
7774

@@ -90,15 +87,11 @@ type EphemeralRunnerSpec struct {
9087
// +optional
9188
GitHubServerTLS *GitHubServerTLSConfig `json:"githubServerTLS,omitempty"`
9289

93-
// +required
9490
corev1.PodTemplateSpec `json:",inline"`
9591
}
9692

9793
// EphemeralRunnerStatus defines the observed state of EphemeralRunner
9894
type EphemeralRunnerStatus struct {
99-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
100-
// Important: Run "make" to regenerate code after modifying this file
101-
10295
// Turns true only if the runner is online.
10396
// +optional
10497
Ready bool `json:"ready"`
@@ -144,7 +137,7 @@ type EphemeralRunnerStatus struct {
144137
JobDisplayName string `json:"jobDisplayName,omitempty"`
145138
}
146139

147-
//+kubebuilder:object:root=true
140+
// +kubebuilder:object:root=true
148141

149142
// EphemeralRunnerList contains a list of EphemeralRunner
150143
type EphemeralRunnerList struct {

apis/actions.github.com/v1alpha1/ephemeralrunnerset_types.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ type EphemeralRunnerSetSpec struct {
2626
Replicas int `json:"replicas,omitempty"`
2727
// PatchID is the unique identifier for the patch issued by the listener app
2828
PatchID int `json:"patchID"`
29-
29+
// EphemeralRunnerSpec is the spec of the ephemeral runner
3030
EphemeralRunnerSpec EphemeralRunnerSpec `json:"ephemeralRunnerSpec,omitempty"`
3131
}
3232

3333
// EphemeralRunnerSetStatus defines the observed state of EphemeralRunnerSet
3434
type EphemeralRunnerSetStatus struct {
3535
// CurrentReplicas is the number of currently running EphemeralRunner resources being managed by this EphemeralRunnerSet.
3636
CurrentReplicas int `json:"currentReplicas"`
37-
38-
// EphemeralRunner counts separated by the stage ephemeral runners are in
39-
4037
// +optional
4138
PendingEphemeralRunners int `json:"pendingEphemeralRunners"`
4239
// +optional
@@ -49,10 +46,10 @@ type EphemeralRunnerSetStatus struct {
4946
// +kubebuilder:subresource:status
5047
// +kubebuilder:printcolumn:JSONPath=".spec.replicas",name="DesiredReplicas",type="integer"
5148
// +kubebuilder:printcolumn:JSONPath=".status.currentReplicas", name="CurrentReplicas",type="integer"
52-
//+kubebuilder:printcolumn:JSONPath=".status.pendingEphemeralRunners",name=Pending Runners,type=integer
53-
//+kubebuilder:printcolumn:JSONPath=".status.runningEphemeralRunners",name=Running Runners,type=integer
54-
//+kubebuilder:printcolumn:JSONPath=".status.finishedEphemeralRunners",name=Finished Runners,type=integer
55-
//+kubebuilder:printcolumn:JSONPath=".status.deletingEphemeralRunners",name=Deleting Runners,type=integer
49+
// +kubebuilder:printcolumn:JSONPath=".status.pendingEphemeralRunners",name=Pending Runners,type=integer
50+
// +kubebuilder:printcolumn:JSONPath=".status.runningEphemeralRunners",name=Running Runners,type=integer
51+
// +kubebuilder:printcolumn:JSONPath=".status.finishedEphemeralRunners",name=Finished Runners,type=integer
52+
// +kubebuilder:printcolumn:JSONPath=".status.deletingEphemeralRunners",name=Deleting Runners,type=integer
5653

5754
// EphemeralRunnerSet is the Schema for the ephemeralrunnersets API
5855
type EphemeralRunnerSet struct {
@@ -63,7 +60,7 @@ type EphemeralRunnerSet struct {
6360
Status EphemeralRunnerSetStatus `json:"status,omitempty"`
6461
}
6562

66-
//+kubebuilder:object:root=true
63+
// +kubebuilder:object:root=true
6764

6865
// EphemeralRunnerSetList contains a list of EphemeralRunnerSet
6966
type EphemeralRunnerSetList struct {

apis/actions.summerwind.net/v1alpha1/runner_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,19 @@ type RunnerStatusRegistration struct {
317317
type WorkVolumeClaimTemplate struct {
318318
StorageClassName string `json:"storageClassName"`
319319
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes"`
320-
Resources corev1.ResourceRequirements `json:"resources"`
320+
Resources corev1.VolumeResourceRequirements `json:"resources"`
321321
}
322322

323323
func (w *WorkVolumeClaimTemplate) validate() error {
324-
if w.AccessModes == nil || len(w.AccessModes) == 0 {
325-
return errors.New("Access mode should have at least one mode specified")
324+
if len(w.AccessModes) == 0 {
325+
return errors.New("access mode should have at least one mode specified")
326326
}
327327

328328
for _, accessMode := range w.AccessModes {
329329
switch accessMode {
330330
case corev1.ReadWriteOnce, corev1.ReadWriteMany:
331331
default:
332-
return fmt.Errorf("Access mode %v is not supported", accessMode)
332+
return fmt.Errorf("access mode %v is not supported", accessMode)
333333
}
334334
}
335335
return nil

apis/actions.summerwind.net/v1alpha1/runner_webhook.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"context"
21+
"fmt"
22+
2023
apierrors "k8s.io/apimachinery/pkg/api/errors"
2124
"k8s.io/apimachinery/pkg/runtime"
2225
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -32,36 +35,51 @@ var runnerLog = logf.Log.WithName("runner-resource")
3235
func (r *Runner) SetupWebhookWithManager(mgr ctrl.Manager) error {
3336
return ctrl.NewWebhookManagedBy(mgr).
3437
For(r).
38+
WithDefaulter(&RunnerDefaulter{}).
39+
WithValidator(&RunnerValidator{}).
3540
Complete()
3641
}
3742

3843
// +kubebuilder:webhook:path=/mutate-actions-summerwind-dev-v1alpha1-runner,verbs=create;update,mutating=true,failurePolicy=fail,groups=actions.summerwind.dev,resources=runners,versions=v1alpha1,name=mutate.runner.actions.summerwind.dev,sideEffects=None,admissionReviewVersions=v1beta1
3944

40-
var _ webhook.Defaulter = &Runner{}
45+
var _ webhook.CustomDefaulter = &RunnerDefaulter{}
46+
47+
type RunnerDefaulter struct{}
4148

4249
// Default implements webhook.Defaulter so a webhook will be registered for the type
43-
func (r *Runner) Default() {
50+
func (*RunnerDefaulter) Default(ctx context.Context, obj runtime.Object) error {
4451
// Nothing to do.
52+
return nil
4553
}
4654

4755
// +kubebuilder:webhook:path=/validate-actions-summerwind-dev-v1alpha1-runner,verbs=create;update,mutating=false,failurePolicy=fail,groups=actions.summerwind.dev,resources=runners,versions=v1alpha1,name=validate.runner.actions.summerwind.dev,sideEffects=None,admissionReviewVersions=v1beta1
4856

49-
var _ webhook.Validator = &Runner{}
57+
var _ webhook.CustomValidator = &RunnerValidator{}
58+
59+
type RunnerValidator struct{}
5060

5161
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
52-
func (r *Runner) ValidateCreate() (admission.Warnings, error) {
62+
func (*RunnerValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
63+
r, ok := obj.(*Runner)
64+
if !ok {
65+
return nil, fmt.Errorf("expected Runner object, got %T", obj)
66+
}
5367
runnerLog.Info("validate resource to be created", "name", r.Name)
5468
return nil, r.Validate()
5569
}
5670

5771
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
58-
func (r *Runner) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
72+
func (*RunnerValidator) ValidateUpdate(ctx context.Context, old, obj runtime.Object) (admission.Warnings, error) {
73+
r, ok := obj.(*Runner)
74+
if !ok {
75+
return nil, fmt.Errorf("expected Runner object, got %T", obj)
76+
}
5977
runnerLog.Info("validate resource to be updated", "name", r.Name)
6078
return nil, r.Validate()
6179
}
6280

6381
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
64-
func (r *Runner) ValidateDelete() (admission.Warnings, error) {
82+
func (*RunnerValidator) ValidateDelete(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
6583
return nil, nil
6684
}
6785

apis/actions.summerwind.net/v1alpha1/runnerdeployment_webhook.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"context"
21+
"fmt"
22+
2023
apierrors "k8s.io/apimachinery/pkg/api/errors"
2124
"k8s.io/apimachinery/pkg/runtime"
2225
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -32,36 +35,51 @@ var runnerDeploymentLog = logf.Log.WithName("runnerdeployment-resource")
3235
func (r *RunnerDeployment) SetupWebhookWithManager(mgr ctrl.Manager) error {
3336
return ctrl.NewWebhookManagedBy(mgr).
3437
For(r).
38+
WithDefaulter(&RunnerDeploymentDefaulter{}).
39+
WithValidator(&RunnerDeploymentValidator{}).
3540
Complete()
3641
}
3742

3843
// +kubebuilder:webhook:path=/mutate-actions-summerwind-dev-v1alpha1-runnerdeployment,verbs=create;update,mutating=true,failurePolicy=fail,groups=actions.summerwind.dev,resources=runnerdeployments,versions=v1alpha1,name=mutate.runnerdeployment.actions.summerwind.dev,sideEffects=None,admissionReviewVersions=v1beta1
3944

40-
var _ webhook.Defaulter = &RunnerDeployment{}
45+
var _ webhook.CustomDefaulter = &RunnerDeploymentDefaulter{}
46+
47+
type RunnerDeploymentDefaulter struct{}
4148

4249
// Default implements webhook.Defaulter so a webhook will be registered for the type
43-
func (r *RunnerDeployment) Default() {
50+
func (*RunnerDeploymentDefaulter) Default(context.Context, runtime.Object) error {
4451
// Nothing to do.
52+
return nil
4553
}
4654

4755
// +kubebuilder:webhook:path=/validate-actions-summerwind-dev-v1alpha1-runnerdeployment,verbs=create;update,mutating=false,failurePolicy=fail,groups=actions.summerwind.dev,resources=runnerdeployments,versions=v1alpha1,name=validate.runnerdeployment.actions.summerwind.dev,sideEffects=None,admissionReviewVersions=v1beta1
4856

49-
var _ webhook.Validator = &RunnerDeployment{}
57+
var _ webhook.CustomValidator = &RunnerDeploymentValidator{}
58+
59+
type RunnerDeploymentValidator struct{}
5060

5161
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
52-
func (r *RunnerDeployment) ValidateCreate() (admission.Warnings, error) {
62+
func (*RunnerDeploymentValidator) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
63+
r, ok := obj.(*RunnerDeployment)
64+
if !ok {
65+
return nil, fmt.Errorf("expected RunnerDeployment object, got %T", obj)
66+
}
5367
runnerDeploymentLog.Info("validate resource to be created", "name", r.Name)
5468
return nil, r.Validate()
5569
}
5670

5771
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
58-
func (r *RunnerDeployment) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
72+
func (*RunnerDeploymentValidator) ValidateUpdate(ctx context.Context, old, obj runtime.Object) (admission.Warnings, error) {
73+
r, ok := obj.(*RunnerDeployment)
74+
if !ok {
75+
return nil, fmt.Errorf("expected RunnerDeployment object, got %T", obj)
76+
}
5977
runnerDeploymentLog.Info("validate resource to be updated", "name", r.Name)
6078
return nil, r.Validate()
6179
}
6280

6381
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
64-
func (r *RunnerDeployment) ValidateDelete() (admission.Warnings, error) {
82+
func (*RunnerDeploymentValidator) ValidateDelete(context.Context, runtime.Object) (admission.Warnings, error) {
6583
return nil, nil
6684
}
6785

0 commit comments

Comments
 (0)