Naming strategies are available only for the binding.operators.coreos.com
API group.
Naming strategies use Go templates to help you define custom binding names through the service binding request. Naming strategies apply for all attributes including the mappings in the serviceBinding
custom resource (CR).
A backing service projects the binding names as files or environment variables into the workload. If a workload expects the projected binding names in a particular format, but the binding names to be projected from the backing service are not available in that format, then you can change the binding names using naming strategies.
Predefined post-processing functions
While using naming strategies, depending on the expectations or requirements of your workload, you can use the following predefined post-processing functions in any combination to convert the character strings:
-
upper
: Converts the character strings into capital or uppercase letters.
-
lower
: Converts the character strings into lowercase letters.
-
title
: Converts the character strings where the first letter of each word is capitalized except for certain minor words.
Predefined naming strategies
Binding names declared through annotations are processed for their name change before their projection into the workload according to the following predefined naming strategies:
-
none
: When applied, there are no changes in the binding names.
Example
After the template compilation, the binding names take the {{ .name }}
form.
host: hippo-pgbouncer
port: 5432
-
upper
: Applied when no namingStrategy
is defined. When applied, converts all the character strings of the binding name key into capital or uppercase letters.
Example
After the template compilation, the binding names take the {{ .service.kind | upper}}_{{ .name | upper }}
form.
DATABASE_HOST: hippo-pgbouncer
DATABASE_PORT: 5432
If your workload requires a different format, you can define a custom naming strategy and change the binding name using a prefix and a separator, for example, PORT_DATABASE
.
|
-
When the binding names are projected as files, by default the predefined none naming strategy is applied, and the binding names do not change.
-
When the binding names are projected as environment variables and no namingStrategy is defined, by default the predefined uppercase naming strategy is applied.
-
You can override the predefined naming strategies by defining custom naming strategies using different combinations of custom binding names and predefined post-processing functions.
|