File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ build-ack-generate: ## Build ack-generate binary
27
27
@go build ${GO_TAGS} ${GO_LDFLAGS} -o bin/ack-generate cmd/ack-generate/main.go
28
28
@echo " ok."
29
29
30
- build-controller : # # Generate controller code for SERVICE
30
+ build-controller : build-ack-generate # # Generate controller code for SERVICE
31
31
@./scripts/install-controller-gen.sh
32
32
@./scripts/build-controller.sh $(AWS_SERVICE )
33
33
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
20
20
21
21
"github.com/aws-controllers-k8s/code-generator/pkg/generate"
22
22
"github.com/aws-controllers-k8s/code-generator/pkg/generate/code"
23
+ ackgenconfig "github.com/aws-controllers-k8s/code-generator/pkg/generate/config"
23
24
"github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset"
24
25
ackmodel "github.com/aws-controllers-k8s/code-generator/pkg/model"
25
26
)
@@ -165,7 +166,12 @@ func Controller(
165
166
}
166
167
}
167
168
}
168
- if err = ts .Add ("pkg/resource/registry.go" , "pkg/resource/registry.go.tpl" , metaVars ); err != nil {
169
+
170
+ configVars := & templateConfigVars {
171
+ metaVars ,
172
+ g .GetConfig (),
173
+ }
174
+ if err = ts .Add ("pkg/resource/registry.go" , "pkg/resource/registry.go.tpl" , configVars ); err != nil {
169
175
return nil , err
170
176
}
171
177
@@ -203,3 +209,10 @@ type templateCmdVars struct {
203
209
templateset.MetaVars
204
210
SnakeCasedCRDNames []string
205
211
}
212
+
213
+ // templateConfigVars contains template variables for the templates that require
214
+ // access to the generator configuration definition
215
+ type templateConfigVars struct {
216
+ templateset.MetaVars
217
+ GeneratorConfig * ackgenconfig.Config
218
+ }
Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ type PrefixConfig struct {
68
68
StatusField string `json:"status_field,omitempty"`
69
69
}
70
70
71
+ // ResourceContainsSecret returns true if any of the fields in any resource are
72
+ // defined as secrets.
73
+ func (c * Config ) ResourceContainsSecret () bool {
74
+ for _ , resource := range c .Resources {
75
+ for _ , field := range resource .Fields {
76
+ if field .IsSecret {
77
+ return true
78
+ }
79
+ }
80
+ }
81
+ return false
82
+ }
83
+
71
84
// New returns a new Config object given a supplied
72
85
// path to a config file
73
86
func New (
Original file line number Diff line number Diff line change @@ -682,6 +682,12 @@ func (g *Generator) ApplyShapeIgnoreRules() {
682
682
}
683
683
}
684
684
685
+ // GetConfig returns the configuration option used to define the current
686
+ // generator.
687
+ func (g * Generator ) GetConfig () * ackgenconfig.Config {
688
+ return g .cfg
689
+ }
690
+
685
691
// New returns a new Generator struct for a supplied API model.
686
692
// Optionally, pass a file path to a generator config file that can be used to
687
693
// instruct the code generator how to handle the API properly
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ import (
11
11
// +kubebuilder:rbac:groups=services.k8s.aws,resources=adoptedresources/status,verbs=get;update;patch
12
12
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch
13
13
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch
14
+ { { if .GeneratorConfig.ResourceContainsSecret -} }
15
+ // +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch
16
+ { {- end } }
14
17
15
18
var (
16
19
reg = ackrt.NewRegistry()
You can’t perform that action at this time.
0 commit comments