feat: support returning result in custom context key or environment#85
feat: support returning result in custom context key or environment#85tenstad wants to merge 14 commits intocrossplane-contrib:mainfrom
Conversation
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
…mFieldPath Signed-off-by: Amund Tenstad <github@amund.io>
… within context Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
…nvironment-configs Signed-off-by: Amund Tenstad <github@amund.io>
Signed-off-by: Amund Tenstad <github@amund.io>
…unction-environment-configs Signed-off-by: Amund Tenstad <github@amund.io>
…ment Signed-off-by: Amund Tenstad <github@amund.io>
| // Into is the key into which extra resources for this selector will be placed. | ||
| Into string `json:"into"` |
There was a problem hiding this comment.
This is a breaking change, we should keep into here and make it the default.
There was a problem hiding this comment.
on top of that it's changing the semantic completely, previously each resource could go to a different key in the context, now they all go to the same one specified at the top level, but at different paths. I'd keep the into here, add a defaultInto at the top level which can be overridden from the resource level one, and make the top level one just a string, mentioning apiextensions.crossplane.io/environment as a well-known key in the comments for both.
There was a problem hiding this comment.
I don't quite understand, and think it might be the into.contextKey thats confusing. It is not the same as into within extraResources.
The top level into specifies where to put the results (what key to use in response.SetContextKey). It's a sort of toggle between the behaviour of function-extra-resources and function-environment-configs.
type: Environmentusesapiextensions.crossplane.io/environment
(and also performs merge)type: Contextdefaults toapiextensions.crossplane.io/extra-resources
(but can be changed usingcontextKey: apiextensions.custom.io/custom)
The following into configuration would be the same as not specifying into at all, and has the same behaviour as the function has today.
into:
type: Context
# rename contextKey to just `context`?
contextKey: apiextensions.crossplane.io/extra-resources
extraResources:
- kind: Namespace
apiVersion: v1
into: obj-0
type: Reference
ref:
name: crossplane-systemThere was a problem hiding this comment.
And yeah, we can ofc keep extraResources[].into instead of renaming the field to toFieldPath.
Should we then support the suggested nesting, or keep the current functionality using a simple key.
extraResources:
- kind: Namespace
fromFieldPath: metadata.name # only extract metadata.name
into: resources.namespacesNested field path
apiextensions.crossplane.io/extra-resources:
resources:
namespaces: # nested inside of `resources`
- kube-system
- crossplane-systemSimple key
apiextensions.crossplane.io/extra-resources:
resources.namespaces: # just a simple single-layer key
- kube-system
- crossplane-systemThere was a problem hiding this comment.
The top level into might be a bad name, open to other suggestions.
It does two things, configures the context, and toggles between the behaviour of function-extra-resources and function-environment-configs.
Description of your changes
Related to https://crossplane.slack.com/archives/C08BBMDCH7W/p1769948003900819
Enables storing the fetched result in the environment (context) instead of the default context key used by this function. Makes it easy to load e.g. the data of a Secret or ConfigMap into environment (crossplane-contrib/function-environment-configs#78) and use it in patch and transform. Will also support loading namespace scoped EnvironmentConfigs into environment if such were to be created in the future.
To fetch a Secret into the environment:
Note: stacked on top of #84
See commit log for step by step implementation process.
Resolves crossplane-contrib/function-environment-configs#78
I have: