@@ -112,6 +112,15 @@ def _controller_gen_rbac_impl(ctx):
112112 files = depset ([outputdir ]),
113113 )
114114
115+ def _controller_gen_webhook_impl (ctx ):
116+ outputdir = ctx .actions .declare_directory (ctx .label .name )
117+
118+ _controller_gen_action (ctx , "webhook" , [outputdir ], outputdir .path )
119+
120+ return DefaultInfo (
121+ files = depset ([outputdir ]),
122+ )
123+
115124COMMON_ATTRS = {
116125 "srcs" : attr .label_list (
117126 allow_empty = False ,
@@ -146,7 +155,7 @@ def _crd_extra_attrs():
146155 })
147156 return ret
148157
149- def _rbac_extra_args ():
158+ def _rbac_extra_attrs ():
150159 ret = COMMON_ATTRS
151160 ret .update ({
152161 "roleName" : attr .string (
@@ -155,6 +164,10 @@ def _rbac_extra_args():
155164 })
156165 return ret
157166
167+ def _webhook_extra_attrs ():
168+ ret = COMMON_ATTRS
169+ return ret
170+
158171def _toolchains ():
159172 return [
160173 "@io_bazel_rules_go//go:toolchain" ,
@@ -173,16 +186,25 @@ _controller_gen_object = rule(
173186 implementation = _controller_gen_object_impl ,
174187 attrs = COMMON_ATTRS ,
175188 toolchains = _toolchains (),
176- doc = "Run the code generation part of controller-gen. " +
189+ doc = "Run the code generating portion of controller-gen. " +
177190 "You can use the name of this rule as part of the `srcs` attribute " +
178191 " of a `go_library` rule." ,
179192)
180193
181194_controller_gen_rbac = rule (
182195 implementation = _controller_gen_rbac_impl ,
183- attrs = _rbac_extra_args (),
196+ attrs = _rbac_extra_attrs (),
184197 toolchains = _toolchains (),
185- doc = "Run the role binding generator part of controller-gen" ,
198+ doc = "Run the role binding generating portion of controller-gen. " +
199+ "The output directory will be `rbac`." ,
200+ )
201+
202+ _controller_gen_webhook = rule (
203+ implementation = _controller_gen_webhook_impl ,
204+ attrs = _webhook_extra_attrs (),
205+ toolchains = _toolchains (),
206+ doc = "Run the webhook generating portion of controller-gen. " +
207+ "The output directory will be the name of the rule." ,
186208)
187209
188210def _maybe_add_gopath_dep (name , kwargs ):
@@ -206,3 +228,7 @@ def controller_gen_object(name, **kwargs):
206228def controller_gen_rbac (name , ** kwargs ):
207229 _maybe_add_gopath_dep (name , kwargs )
208230 _controller_gen_rbac (name = name , ** kwargs )
231+
232+ def controller_gen_webhook (name , ** kwargs ):
233+ _maybe_add_gopath_dep (name , kwargs )
234+ _controller_gen_webhook (name = name , ** kwargs )
0 commit comments