feat(issue-559): allow sensitive values to be passable as plaintext#610
feat(issue-559): allow sensitive values to be passable as plaintext#610Breee wants to merge 1 commit intocrossplane:mainfrom
Conversation
📝 WalkthroughWalkthroughThis change introduces support for plaintext values in sensitive fields. A new Changes
Sequence Diagram(s)sequenceDiagram
participant Config as Configuration
participant FieldGen as Field Generator
participant Validator as Validation Builder
participant Processor as Resource Processor
participant TFState as Terraform State
Config->>FieldGen: AllowPlaintextValue = true
FieldGen->>FieldGen: Create regular field<br/>(AlternateFieldName set)
FieldGen->>FieldGen: Mark secret ref optional
FieldGen->>Validator: Field with AlternateFieldName
Validator->>Validator: Generate OR validation:<br/>primaryField OR alternateField
Validator->>Validator: Track alternate path in<br/>topLevelRequiredParam
Processor->>TFState: GetValue(tfPath)
alt Plaintext value exists
Processor->>Processor: Skip secret ref processing
else No plaintext value
Processor->>Processor: Process secret reference
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
allow sensitive values to be passable as plaintext
Draft for #559 to have a base for discussion. This shall give you an idea of the requirement i have.
This was the easiest implementation approach I found that is fully backwards compatible.
However, it does add some complexity to the builder logic and generated code, so I'm open to suggestions on how to make it cleaner or if we want to take a different approach.
In general i need some more flexibility with what i can pass in as secret and what i can pass in as plaintext for the provider-keycloak, as OIDC / SAML clients and tools vary alot in what they support and need.
Problem
Sensitive fields currently only support secret references. Users must create a Kubernetes Secret even if they just want to pass a value directly. This is inflexible and doesn't match how the underlying Terraform providers work (which accept plaintext).
Potential Solution
I Added a
AllowPlaintextValueconfig flag. When enabled, generates both the regular field AND the secret reference field for sensitive parameters. Users pick which one to use via OR validation (provide one or the other, not both).Runtime checks the plaintext field first, falls back to secret reference if not set. Its Backwards compatible so existing secret-only resources work unchanged.
Usage
Provider configuration:
See https://github.com/crossplane-contrib/provider-keycloak/blob/feat/upjet-test/config/oidc/config.go#L30
Generated CRD types will then look like this:
see https://github.com/crossplane-contrib/provider-keycloak/blob/feat/upjet-test/apis/cluster/oidc/v1alpha1/zz_identityprovider_types.go#L43
Example
After enabling
AllowPlaintextValue, users can choose:Testing
I Tested in provider-keycloak with both plaintext and secret reference patterns.
Both resources successfully created and synced in a dev cluster.