File tree Expand file tree Collapse file tree 11 files changed +38
-45
lines changed
v2/scaffolds/internal/templates
v3/scaffolds/internal/templates/controllers
project-v2-addon/controllers
project-v3-addon/controllers Expand file tree Collapse file tree 11 files changed +38
-45
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,9 @@ type {{ .Resource.Kind }}Status struct {
87
87
88
88
//+kubebuilder:object:root=true
89
89
//+kubebuilder:subresource:status
90
- {{ if not .Resource.API.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
90
+ {{- if not .Resource.API.Namespaced }}
91
+ //+kubebuilder:resource:scope=Cluster
92
+ {{- end }}
91
93
92
94
// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
93
95
type {{ .Resource.Kind }} struct {
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ import (
78
78
// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
79
79
type {{ .Resource.Kind }}Reconciler struct {
80
80
client.Client
81
- Log logr.Logger
81
+ Log logr.Logger
82
82
Scheme *runtime.Scheme
83
83
}
84
84
Original file line number Diff line number Diff line change @@ -64,11 +64,7 @@ func (f *Controller) SetTemplateDefaults() error {
64
64
//nolint:lll
65
65
const controllerTemplate = `{{ .Boilerplate }}
66
66
67
- {{if and .MultiGroup .Resource.Group }}
68
- package {{ .Resource.PackageName }}
69
- {{else}}
70
- package controllers
71
- {{end}}
67
+ package {{ if and .MultiGroup .Resource.Group }}{{ .Resource.PackageName }}{{ else }}controllers{{ end }}
72
68
73
69
import (
74
70
"context"
@@ -84,7 +80,7 @@ import (
84
80
// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
85
81
type {{ .Resource.Kind }}Reconciler struct {
86
82
client.Client
87
- Log logr.Logger
83
+ Log logr.Logger
88
84
Scheme *runtime.Scheme
89
85
}
90
86
Original file line number Diff line number Diff line change @@ -35,6 +35,10 @@ const controllerTemplate = `{{ .Boilerplate }}
35
35
package controllers
36
36
37
37
import (
38
+ "github.com/go-logr/logr"
39
+ "k8s.io/apimachinery/pkg/runtime"
40
+ ctrl "sigs.k8s.io/controller-runtime"
41
+ "sigs.k8s.io/controller-runtime/pkg/client"
38
42
"sigs.k8s.io/controller-runtime/pkg/controller"
39
43
"sigs.k8s.io/controller-runtime/pkg/handler"
40
44
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -43,11 +47,6 @@ import (
43
47
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
44
48
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
45
49
46
- "github.com/go-logr/logr"
47
- "k8s.io/apimachinery/pkg/runtime"
48
- ctrl "sigs.k8s.io/controller-runtime"
49
- "sigs.k8s.io/controller-runtime/pkg/client"
50
-
51
50
api "{{ .Resource.Path }}"
52
51
)
53
52
@@ -56,7 +55,7 @@ var _ reconcile.Reconciler = &{{ .Resource.Kind }}Reconciler{}
56
55
// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
57
56
type {{ .Resource.Kind }}Reconciler struct {
58
57
client.Client
59
- Log logr.Logger
58
+ Log logr.Logger
60
59
Scheme *runtime.Scheme
61
60
62
61
declarative.Reconciler
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ type {{ .Resource.Kind }}Status struct {
76
76
77
77
//+kubebuilder:object:root=true
78
78
//+kubebuilder:subresource:status
79
- {{ if not .Resource.API.Namespaced }} //+kubebuilder:resource:scope=Cluster {{ end }}
79
+ {{- if not .Resource.API.Namespaced }}
80
+ //+kubebuilder:resource:scope=Cluster
81
+ {{- end }}
80
82
81
83
// {{.Resource.Kind}} is the Schema for the {{ .Resource.Plural }} API
82
84
type {{ .Resource.Kind }} struct {
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ limitations under the License.
17
17
package controllers
18
18
19
19
import (
20
+ "github.com/go-logr/logr"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ ctrl "sigs.k8s.io/controller-runtime"
23
+ "sigs.k8s.io/controller-runtime/pkg/client"
20
24
"sigs.k8s.io/controller-runtime/pkg/controller"
21
25
"sigs.k8s.io/controller-runtime/pkg/handler"
22
26
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -25,11 +29,6 @@ import (
25
29
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
26
30
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
27
31
28
- "github.com/go-logr/logr"
29
- "k8s.io/apimachinery/pkg/runtime"
30
- ctrl "sigs.k8s.io/controller-runtime"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
-
33
32
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
34
33
)
35
34
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ limitations under the License.
17
17
package controllers
18
18
19
19
import (
20
+ "github.com/go-logr/logr"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ ctrl "sigs.k8s.io/controller-runtime"
23
+ "sigs.k8s.io/controller-runtime/pkg/client"
20
24
"sigs.k8s.io/controller-runtime/pkg/controller"
21
25
"sigs.k8s.io/controller-runtime/pkg/handler"
22
26
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -25,11 +29,6 @@ import (
25
29
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
26
30
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
27
31
28
- "github.com/go-logr/logr"
29
- "k8s.io/apimachinery/pkg/runtime"
30
- ctrl "sigs.k8s.io/controller-runtime"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
-
33
32
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
34
33
)
35
34
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ limitations under the License.
17
17
package controllers
18
18
19
19
import (
20
+ "github.com/go-logr/logr"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ ctrl "sigs.k8s.io/controller-runtime"
23
+ "sigs.k8s.io/controller-runtime/pkg/client"
20
24
"sigs.k8s.io/controller-runtime/pkg/controller"
21
25
"sigs.k8s.io/controller-runtime/pkg/handler"
22
26
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -25,11 +29,6 @@ import (
25
29
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
26
30
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
27
31
28
- "github.com/go-logr/logr"
29
- "k8s.io/apimachinery/pkg/runtime"
30
- ctrl "sigs.k8s.io/controller-runtime"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
-
33
32
api "sigs.k8s.io/kubebuilder/testdata/project-v2-addon/api/v1"
34
33
)
35
34
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ limitations under the License.
17
17
package controllers
18
18
19
19
import (
20
+ "github.com/go-logr/logr"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ ctrl "sigs.k8s.io/controller-runtime"
23
+ "sigs.k8s.io/controller-runtime/pkg/client"
20
24
"sigs.k8s.io/controller-runtime/pkg/controller"
21
25
"sigs.k8s.io/controller-runtime/pkg/handler"
22
26
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -25,11 +29,6 @@ import (
25
29
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
26
30
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
27
31
28
- "github.com/go-logr/logr"
29
- "k8s.io/apimachinery/pkg/runtime"
30
- ctrl "sigs.k8s.io/controller-runtime"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
-
33
32
api "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
34
33
)
35
34
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ limitations under the License.
17
17
package controllers
18
18
19
19
import (
20
+ "github.com/go-logr/logr"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ ctrl "sigs.k8s.io/controller-runtime"
23
+ "sigs.k8s.io/controller-runtime/pkg/client"
20
24
"sigs.k8s.io/controller-runtime/pkg/controller"
21
25
"sigs.k8s.io/controller-runtime/pkg/handler"
22
26
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -25,11 +29,6 @@ import (
25
29
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/status"
26
30
"sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative"
27
31
28
- "github.com/go-logr/logr"
29
- "k8s.io/apimachinery/pkg/runtime"
30
- ctrl "sigs.k8s.io/controller-runtime"
31
- "sigs.k8s.io/controller-runtime/pkg/client"
32
-
33
32
api "sigs.k8s.io/kubebuilder/testdata/project-v3-addon/api/v1"
34
33
)
35
34
You can’t perform that action at this time.
0 commit comments