-
Notifications
You must be signed in to change notification settings - Fork 1
Resource initializers
Resource initializers are applied to the newly created resource before it is accessible in the components file.
The order of initializers application is not determined, so each individual initializer should not rely on other initializers. To define initializer setup_resource
method is called on R
in the form R.setup_resource [resource(s)] do |r| ... end
. resource(s)
is the list of resource kinds to initialize specified by Strings or Symbols, for example, to add label application
with the value hello
to all ConfigMaps and Secrets you can declare the following initializer in Helpers file:
R.setup_resource :config_map, :secret do |c|
c.metadata.add_label application: :hello
end
Now, all the resources created by R.config_map
or R.secret
factories will have the label application
automatically assigned.
If the list of resources is not specified, then initializer will be called for any kind of resources. So, the following declaration will add application
label to all resources, no matter what kind they are:
R.setup_resource do |r|
r.metadata.add_label application: :hello
end