Skip to content

Commit 3c8e370

Browse files
authored
Merge pull request #1988 from Adirio/bump-addon
🌱 Bump addon *_types.go and controller.go templates
2 parents 6a676b1 + 6e1be3d commit 3c8e370

File tree

10 files changed

+27
-30
lines changed

10 files changed

+27
-30
lines changed

plugins/addon/controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import (
4747
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
4848
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
4949
50-
api "{{ .Resource.Path }}"
50+
{{ .Resource.ImportAlias }} "{{ .Resource.Path }}"
5151
)
5252
5353
var _ reconcile.Reconciler = &{{ .Resource.Kind }}Reconciler{}
@@ -69,12 +69,12 @@ func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) erro
6969
addon.Init()
7070
7171
labels := map[string]string{
72-
"k8s-app": "{{ .Resource.Kind | lower }}",
72+
"k8s-app": "{{ lower .Resource.Kind }}",
7373
}
7474
7575
watchLabels := declarative.SourceLabel(mgr.GetScheme())
7676
77-
if err := r.Reconciler.Init(mgr, &api.{{ .Resource.Kind }}{},
77+
if err := r.Reconciler.Init(mgr, &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{},
7878
declarative.WithObjectTransform(declarative.AddLabels(labels)),
7979
declarative.WithOwner(declarative.SourceAsOwner),
8080
declarative.WithLabels(watchLabels),
@@ -86,13 +86,13 @@ func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) erro
8686
return err
8787
}
8888
89-
c, err := controller.New("{{ .Resource.Kind | lower }}-controller", mgr, controller.Options{Reconciler: r})
89+
c, err := controller.New("{{ lower .Resource.Kind }}-controller", mgr, controller.Options{Reconciler: r})
9090
if err != nil {
9191
return err
9292
}
9393
9494
// Watch for changes to {{ .Resource.Kind }}
95-
err = c.Watch(&source.Kind{Type: &api.{{ .Resource.Kind }}{}}, &handler.EnqueueRequestForObject{})
95+
err = c.Watch(&source.Kind{Type: &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}}, &handler.EnqueueRequestForObject{})
9696
if err != nil {
9797
return err
9898
}

plugins/addon/type.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ import (
5757
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
5858
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
5959
60-
// {{.Resource.Kind}}Spec defines the desired state of {{.Resource.Kind}}
61-
type {{.Resource.Kind}}Spec struct {
60+
// {{ .Resource.Kind }}Spec defines the desired state of {{ .Resource.Kind }}
61+
type {{ .Resource.Kind }}Spec struct {
6262
addonv1alpha1.CommonSpec {{ JSONTag ",inline" }}
6363
addonv1alpha1.PatchSpec {{ JSONTag ",inline" }}
6464
@@ -80,7 +80,7 @@ type {{ .Resource.Kind }}Status struct {
8080
//+kubebuilder:resource:scope=Cluster
8181
{{- end }}
8282
83-
// {{.Resource.Kind}} is the Schema for the {{ .Resource.Plural }} API
83+
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
8484
type {{ .Resource.Kind }} struct {
8585
metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
8686
metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
@@ -92,7 +92,7 @@ type {{ .Resource.Kind }} struct {
9292
var _ addonv1alpha1.CommonObject = &{{ .Resource.Kind }}{}
9393
9494
func (o *{{ .Resource.Kind }}) ComponentName() string {
95-
return "{{ .Resource.Kind | lower }}"
95+
return "{{ lower .Resource.Kind }}"
9696
}
9797
9898
func (o *{{ .Resource.Kind }}) CommonSpec() addonv1alpha1.CommonSpec {
@@ -112,7 +112,6 @@ func (o *{{ .Resource.Kind }}) SetCommonStatus(s addonv1alpha1.CommonStatus) {
112112
}
113113
114114
//+kubebuilder:object:root=true
115-
{{ if not .Resource.API.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
116115
117116
// {{ .Resource.Kind }}List contains a list of {{ .Resource.Kind }}
118117
type {{ .Resource.Kind }}List struct {

testdata/project-v2-addon/api/v1/admiral_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func (o *Admiral) SetCommonStatus(s addonv1alpha1.CommonStatus) {
7777
}
7878

7979
//+kubebuilder:object:root=true
80-
//+kubebuilder:resource:scope=Cluster
8180

8281
// AdmiralList contains a list of Admiral
8382
type AdmiralList struct {

testdata/project-v2-addon/controllers/admiral_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &AdmiralReconciler{}
@@ -56,7 +56,7 @@ func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.Admiral{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.Admiral{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to Admiral
77-
err = c.Watch(&source.Kind{Type: &api.Admiral{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.Admiral{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

testdata/project-v2-addon/controllers/captain_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &CaptainReconciler{}
@@ -56,7 +56,7 @@ func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.Captain{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.Captain{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to Captain
77-
err = c.Watch(&source.Kind{Type: &api.Captain{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.Captain{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

testdata/project-v2-addon/controllers/firstmate_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &FirstMateReconciler{}
@@ -56,7 +56,7 @@ func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.FirstMate{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.FirstMate{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to FirstMate
77-
err = c.Watch(&source.Kind{Type: &api.FirstMate{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.FirstMate{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

testdata/project-v3-addon/api/v1/admiral_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ func (o *Admiral) SetCommonStatus(s addonv1alpha1.CommonStatus) {
7777
}
7878

7979
//+kubebuilder:object:root=true
80-
//+kubebuilder:resource:scope=Cluster
8180

8281
// AdmiralList contains a list of Admiral
8382
type AdmiralList struct {

testdata/project-v3-addon/controllers/admiral_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &AdmiralReconciler{}
@@ -56,7 +56,7 @@ func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.Admiral{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.Admiral{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to Admiral
77-
err = c.Watch(&source.Kind{Type: &api.Admiral{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.Admiral{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

testdata/project-v3-addon/controllers/captain_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &CaptainReconciler{}
@@ -56,7 +56,7 @@ func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.Captain{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.Captain{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to Captain
77-
err = c.Watch(&source.Kind{Type: &api.Captain{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.Captain{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

testdata/project-v3-addon/controllers/firstmate_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
3030
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
3131

32-
api "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
32+
crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
3333
)
3434

3535
var _ reconcile.Reconciler = &FirstMateReconciler{}
@@ -56,7 +56,7 @@ func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
5656

5757
watchLabels := declarative.SourceLabel(mgr.GetScheme())
5858

59-
if err := r.Reconciler.Init(mgr, &api.FirstMate{},
59+
if err := r.Reconciler.Init(mgr, &crewv1.FirstMate{},
6060
declarative.WithObjectTransform(declarative.AddLabels(labels)),
6161
declarative.WithOwner(declarative.SourceAsOwner),
6262
declarative.WithLabels(watchLabels),
@@ -74,7 +74,7 @@ func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
7474
}
7575

7676
// Watch for changes to FirstMate
77-
err = c.Watch(&source.Kind{Type: &api.FirstMate{}}, &handler.EnqueueRequestForObject{})
77+
err = c.Watch(&source.Kind{Type: &crewv1.FirstMate{}}, &handler.EnqueueRequestForObject{})
7878
if err != nil {
7979
return err
8080
}

0 commit comments

Comments
 (0)