-
Notifications
You must be signed in to change notification settings - Fork 38
Support custom functions for data pre-processing #260
Comments
The conversion from CR to TF input file happens in
As opposed to external name config functions, I don't think we're seeing many cases that people need to change the schema of parameters that are used by TF (most of the time, they are additional and not input to TF itself). So, if we do it, I'd prefer it to be less intrusive as possible, for example it shouldn't change the way others are using Terrajet. I think it'd be best if we can let user write a // GetParameters of this Repository
func (tr *SecretParameters) GetParameters() (map[string]interface{}, error) {
// your logic
p, err := json.TFParser.Marshal(tr.Spec.ForProvider)
if err != nil {
return nil, err
}
base := map[string]interface{}{}
return base, json.TFParser.Unmarshal(p, &base)
} Once Terrajet sees that |
@muvaf Are we sure that GetParameters is the right place to look? I've been playing around with the generated code to see the results of interacting with GetParameters. I'm not seeing the contents of the SecretRef when I print out When I examine the Resource contents, I can see the SecretRef (secret name, key, etc), but I haven't yet found where we grab the secret data. Is this still in GetParameters? |
I think we want to provide the ability to inject a function here. This would enable providers to "sanitize" connection secrets coming from other providers. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
What problem are you facing?
The
vault_generic_secret
resource expects data to be formatted as JSON. It uses the Keys of this json to name secret fields when submitting to vault.An example Kubernetes Secret:
An example Vault Secret:
The resulting secret in vault would look like this:
If the secret is not json-formatted, it will fail apply and not be created.
In terraform, there are built-in functions which can re-format data as it is submitted to new resources. In a provider, we would need to perform this re-formatting in the controller.
This creates several issues:
How could Terrajet help solve your problem?
Allow injecting formatting logic for certain fields. In this example, we would like to be able to specifying a pre-format function in our
config.go
file. This could be added as "Formatted" option on the TerraformResource Schema:This would result would appear in the deepCopyInto method for parameters:
The text was updated successfully, but these errors were encountered: