@@ -3,7 +3,7 @@ package v1alpha1
33import (
44 "fmt"
55
6- runtime "k8s.io/apimachinery/pkg/runtime"
6+ "k8s.io/apimachinery/pkg/runtime"
77 ctrl "sigs.k8s.io/controller-runtime"
88 logf "sigs.k8s.io/controller-runtime/pkg/log"
99 "sigs.k8s.io/controller-runtime/pkg/webhook"
@@ -13,9 +13,9 @@ import (
1313// log is for logging in this package.
1414var cdk8sappproxylog = logf .Log .WithName ("cdk8sappproxy-resource" )
1515
16- func (r * Cdk8sAppProxy ) SetupWebhookWithManager (mgr ctrl.Manager ) error {
16+ func (c * Cdk8sAppProxy ) SetupWebhookWithManager (mgr ctrl.Manager ) error {
1717 return ctrl .NewWebhookManagedBy (mgr ).
18- For (r ).
18+ For (c ).
1919 Complete ()
2020}
2121
@@ -25,17 +25,17 @@ func (r *Cdk8sAppProxy) SetupWebhookWithManager(mgr ctrl.Manager) error {
2525var _ webhook.Defaulter = & Cdk8sAppProxy {}
2626
2727// Default implements webhook.CustomDefaulter so a webhook will be registered for the type.
28- func (r * Cdk8sAppProxy ) Default () {
29- cdk8sappproxylog .Info ("default" , "name" , r .Name )
28+ func (c * Cdk8sAppProxy ) Default () {
29+ cdk8sappproxylog .Info ("default" , "name" , c .Name )
3030
31- // Set default git reference if not specified
32- if r .Spec .GitRepository != nil && r .Spec .GitRepository .Reference == "" {
33- r .Spec .GitRepository .Reference = "main"
31+ // Set the default git reference if not specified
32+ if c .Spec .GitRepository != nil && c .Spec .GitRepository .Reference == "" {
33+ c .Spec .GitRepository .Reference = "main"
3434 }
3535
36- // Set default path if not specified
37- if r .Spec .GitRepository != nil && r .Spec .GitRepository .Path == "" {
38- r .Spec .GitRepository .Path = "."
36+ // Set the default path if not specified
37+ if c .Spec .GitRepository != nil && c .Spec .GitRepository .Path == "" {
38+ c .Spec .GitRepository .Path = "."
3939 }
4040}
4141
@@ -44,42 +44,42 @@ func (r *Cdk8sAppProxy) Default() {
4444var _ webhook.Validator = & Cdk8sAppProxy {}
4545
4646// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
47- func (r * Cdk8sAppProxy ) ValidateCreate () (admission.Warnings , error ) {
48- cdk8sappproxylog .Info ("validate create" , "name" , r .Name )
47+ func (c * Cdk8sAppProxy ) ValidateCreate () (admission.Warnings , error ) {
48+ cdk8sappproxylog .Info ("validate create" , "name" , c .Name )
4949
50- return r .validateCdk8sAppProxy ()
50+ return c .validateCdk8sAppProxy ()
5151}
5252
53- // ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
54- func (r * Cdk8sAppProxy ) ValidateUpdate (oldRaw runtime.Object ) (admission.Warnings , error ) {
55- cdk8sappproxylog .Info ("validate update" , "name" , r .Name )
53+ // ValidateUpdate implement webhook.CustomValidator so a webhook will be registered for the type.
54+ func (c * Cdk8sAppProxy ) ValidateUpdate (oldRaw runtime.Object ) (admission.Warnings , error ) {
55+ cdk8sappproxylog .Info ("validate update" , "name" , c .Name )
5656
57- return r .validateCdk8sAppProxy ()
57+ return c .validateCdk8sAppProxy ()
5858}
5959
6060// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
61- func (r * Cdk8sAppProxy ) ValidateDelete () (admission.Warnings , error ) {
62- cdk8sappproxylog .Info ("validate delete" , "name" , r .Name )
61+ func (c * Cdk8sAppProxy ) ValidateDelete () (admission.Warnings , error ) {
62+ cdk8sappproxylog .Info ("validate delete" , "name" , c .Name )
6363
6464 // No validation needed for delete
6565 return nil , nil
6666}
6767
68- func (r * Cdk8sAppProxy ) validateCdk8sAppProxy () (admission.Warnings , error ) {
68+ func (c * Cdk8sAppProxy ) validateCdk8sAppProxy () (admission.Warnings , error ) {
6969 var allErrs []error
7070
7171 // Validate that either LocalPath or GitRepository is specified, but not both
72- if r .Spec .LocalPath != "" && r .Spec .GitRepository != nil {
72+ if c .Spec .LocalPath != "" && c .Spec .GitRepository != nil {
7373 allErrs = append (allErrs , fmt .Errorf ("only one of localPath or gitRepository can be specified" ))
7474 }
7575
76- if r .Spec .LocalPath == "" && r .Spec .GitRepository == nil {
76+ if c .Spec .LocalPath == "" && c .Spec .GitRepository == nil {
7777 allErrs = append (allErrs , fmt .Errorf ("either localPath or gitRepository must be specified" ))
7878 }
7979
8080 // Validate GitRepository fields if specified
81- if r .Spec .GitRepository != nil {
82- if r .Spec .GitRepository .URL == "" {
81+ if c .Spec .GitRepository != nil {
82+ if c .Spec .GitRepository .URL == "" {
8383 allErrs = append (allErrs , fmt .Errorf ("gitRepository.url is required when gitRepository is specified" ))
8484 }
8585 }
0 commit comments