-
Notifications
You must be signed in to change notification settings - Fork 237
Open
Labels
area/fn-sdkTypescript SDKTypescript SDKarea/hydrateenhancementNew feature or requestNew feature or requestp1triagedIssue has been triaged by adding an `area/` labelIssue has been triaged by adding an `area/` label
Description
Describe your problem
I am trying to write a generator function. Basically it inserts some data into a configmap, nothing too fancy.
My Kptfile looks like:
pipeline:
mutators:
- image: my-generator
configMap:
data: "..."
- image: gcr.io/kpt-fn/set-namespace:v0.1
configMap:
namespace: grafana
My function generates a new config, and inserts it into the list of items with merging:
rl.Items = append(rl.Items, yaml.NewRNode(&node))
rl.Items, err = filters.MergeFilter{}.Filter(rl.Items)
The problem is that the generator doesn't add a namespace, but then it later is added. This means that the second run of the pipeline ends up appending the config again - so we end up with 2x copies.
Possible solutions:
- Generator functions should not include namespace on merge key. This seems prone to failure in cases of multiple namespaces handled by one Kptfile
- Generator functions should always explicit set the namespace. This requires all generators to take a
namespace
param, and all usages to set it as well - a lot of churn and duplication. - When
configMap
is used, set the namespace equal to that of the Kptfile namespace. Bonus points ifset-namespace
also uses this. Then, the whole Kptfile could look like:
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: grafana
namespace: grafana
pipeline:
mutators:
- image: my-generator
configMap:
data: "..."
- image: gcr.io/kpt-fn/set-namespace:v0.1
configMap: {}
To get the namespace that should be used, functions can use rl.FunctionConfig.GetNamespace()
- if set-namespaces generates a duplicate resource, it could filter one of them out. This feels like the wrong solution - especially if it picks the wrong copy.
Metadata
Metadata
Assignees
Labels
area/fn-sdkTypescript SDKTypescript SDKarea/hydrateenhancementNew feature or requestNew feature or requestp1triagedIssue has been triaged by adding an `area/` labelIssue has been triaged by adding an `area/` label