Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a way to escape the setter syntax #3965

Open
mgoltzsche opened this issue May 16, 2023 · 1 comment
Open

Support a way to escape the setter syntax #3965

mgoltzsche opened this issue May 16, 2023 · 1 comment
Labels
area/fn-catalog Functions Catalog enhancement New feature or request triaged Issue has been triaged by adding an `area/` label

Comments

@mgoltzsche
Copy link

mgoltzsche commented May 16, 2023

Problem

I want to deploy a kpt package using FluxCD but its variable substitution syntax clashes with kpt's setter syntax when both are used in the same field like in this example Deployment patch (that aims to enforce a redeployment when a secret name that is provided as substitution variable to a FluxCD Kustomization resource changes, falling back to a default Secret name that is maintained using a kpt setter, based on a blueprint):

...
        envFrom:
        - secretRef:
            name: ${APP_CONFIG_SECRET_NAME:=mopidy-defaults} # kpt-set: ${APP_CONFIG_SECRET_NAME:=${name}-defaults}

When running kpt fn render (using kpt 1.0.0-beta.32) in the root directory of the mopidy-container repo, it fails with the following output:

Package "mopidy-container": 
[RUNNING] "gcr.io/kpt-fn/apply-setters:v0.2.0"
[FAIL] "gcr.io/kpt-fn/apply-setters:v0.2.0" in 100ms
  Results:
    [error]: failed to apply setters: values for setters [${APP_CONFIG_SECRET_NAME:=mopidy-defaults}] must be provided
  Stderr:
    "values for setters [${APP_CONFIG_SECRET_NAME:=mopidy-defaults}] must be providedvalues for setters [${APP_CONFIG_SECRET_NAME:=mopidy-defaults}] must be provided"
  Exit code: 1

kpt apply-setters function interprets the FluxCD Kustomization variable expression as kpt setter variable.

Proposed solution

To disambiguate the syntax, kpt should support an escape character (such as \ or $; in absence of string literal expressions).
Using \ as escape character, a working version of the broken example snippet from above could look as follows:

...
        envFrom:
        - secretRef:
            name: ${APP_CONFIG_SECRET_NAME:=mopidy-defaults} # kpt-set: \${APP_CONFIG_SECRET_NAME:=${name}-defaults}

Workaround

Don't mix FluxCD variables with kpt setters within the same field and accept that the variable fallback value (for development) is static (same for every app that inherits the blueprint):

        envFrom:
        - secretRef:
            name: ${APP_NAME:=app}-defaultconfig
        - secretRef:
            name: ${APP_CONFIG_SECRET_NAME:=app-defaultconfig}

Thus, there is no urgent need to solve this issue but it would be nice to have.

@mgoltzsche mgoltzsche added the enhancement New feature or request label May 16, 2023
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 17, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind the default Secret in addition to the user-defined one in order to update the app's default configuration along with the rest of the manifest.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 17, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind the default Secret in addition to the user-defined one in order to update the app's default configuration along with the rest of the manifest.
@droot droot added the area/fn-catalog Functions Catalog label May 17, 2023
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
mgoltzsche added a commit to mgoltzsche/mopidy-container that referenced this issue May 18, 2023
* Don't use kpt setters and FluxCD variables within the same field, see kptdev/kpt#3965.
* Bind default Secret in addition to the user-defined one in order to allow for app updates to also update the config.
@mortent
Copy link
Contributor

mortent commented Jun 22, 2023

Thanks for reporting this. It probably isn't at the top of our priorities at the moment, but we are open to contributions. It would also be interesting to think about how these scenarios would work without the dependence on setters, as they have some challenges as described in #3131.

@mortent mortent added the triaged Issue has been triaged by adding an `area/` label label Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fn-catalog Functions Catalog enhancement New feature or request triaged Issue has been triaged by adding an `area/` label
Projects
None yet
Development

No branches or pull requests

3 participants