How to handle conditional mutations

25 views
Skip to first unread message

Baris Simsek

unread,
Dec 4, 2023, 5:31:53 PM12/4/23
to kpt-users
Hi,

I have 2 env. Prod and Dev. I need to add a certain annotation to certain resources only in dev env.

set-annotations updates all resources. I didn't see a mechanism to select target resources. So it doesn't seem adequate.

And those annotations only exist in dev. So apply-setters or replacement doesn't work since it's not a substitution of an existing string.

The only solution comes to mind is to use different YAML files for each environment which refutes Kpt's existence.

Any suggestion? ty!

Karl Isenberg

unread,
Dec 7, 2023, 3:10:25 PM12/7/23
to Baris Simsek, kpt-users
When you specify a function to run in the Kptfile pipeline mutators you can optionally specify selectors and exclude selectors.


And if you run the function via kpt fn eval, there are --match-* fields you can specify to select specific resources.

That said, I don't know of any way to select or exclude by file path.

Alternatively, you could make a dev package that embeds the prod package and includes an extra set-annotations mutator in the parent pipeline.

--
You received this message because you are subscribed to the Google Groups "kpt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kpt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kpt-users/6f978e0f-36a0-4ca8-9d2a-7efc669944a0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages