Add prefix and suffix support to string generators
Is your feature request related to a problem? Please describe.
Some applications require generated identifiers to follow a specific format, including a fixed prefix and/or suffix around otherwise random content. For example, Garage Object Storage access keys can use a fixed GK prefix followed by random characters, such as GK7fa2c8d1e4b671aa9f3d8c22.
Currently, users must work around this limitation by using ExternalSecret.target.template to prepend or append text, implementing a Webhook Generator, or generating the value outside of ESO through CI/CD. These approaches add boilerplate and operational complexity for a requirement that is directly related to the generated string.
Describe the solution you'd like
Add generic, optional prefix and suffix support to ESO generators that produce string output, including PasswordGenerator and UUIDGenerator. A possible configuration could be:
spec:
length: 24
format:
prefix: GK
suffix: ""The exact API shape can be adjusted to fit existing generator conventions. The feature should:
- Apply consistently to string-producing generators.
- Preserve the existing generator behavior when
format,prefix, andsuffixare omitted. - Clearly document whether
lengthapplies to the generated portion or the final value. - Allow generated values to satisfy provider-specific formats without requiring a separate templating step.
For example, a Garage Object Storage generator configuration could produce an access key such as:
GK7fa2c8d1e4b671aa9f3d8c22This would provide less boilerplate, improved reusability, simpler configuration, and reduced operational overhead while remaining backwards compatible with existing generator specifications.
Describe alternatives you've considered
- ExternalSecret templating: Users can currently prepend or append text with a template such as
AWS_ACCESS_KEY_ID: "GK{{ .generated }}". This couples a formatting concern to each consumingExternalSecret, requires repeated template configuration, and becomes cumbersome when the same format is needed in multiple resources or generators. - Webhook Generators: A Webhook Generator can implement the desired format, but requires maintaining and operating an additional integration for functionality that is a small, generic transformation of an ESO-generated string. This introduces unnecessary implementation, deployment, and upgrade overhead.
- External generation through CI/CD: Generating values outside ESO adds another system and lifecycle to credential generation, complicates rotation and reconciliation, and can require additional secret distribution and access-control mechanisms.
Native generator support would centralize the format definition, improve reuse, reduce duplication, and keep generation and reconciliation within ESO.
Additional context
Garage Object Storage is a realistic example: its S3 access keys can follow a fixed GK prefix followed by generated characters, for example GK7fa2c8d1e4b671aa9f3d8c22. Generic prefix and suffix support would also benefit other systems that require provider-specific identifier formats.
The feature should be designed as an additive, backwards-compatible enhancement for string-producing generators. Existing configurations without prefix or suffix settings should produce the same output as they do today.
Source: external-secrets/external-secrets