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

set-project-id relies on apply-setter to edit project #2690

Open
yuwenma opened this issue Jan 29, 2022 · 5 comments
Open

set-project-id relies on apply-setter to edit project #2690

yuwenma opened this issue Jan 29, 2022 · 5 comments
Assignees
Labels
area/fn-catalog Functions Catalog bug Something isn't working p1 triaged Issue has been triaged by adding an `area/` label

Comments

@yuwenma
Copy link
Contributor

yuwenma commented Jan 29, 2022

As the name shows, set-project-id should be safely used as a declarative function in Kptfile. However, it is only used as an imperative function that changes Kptfile only:
Running kpt fn eval --image gcr.io/kpt-fn/set-project-id adds a new apply-setter function to Kptfile. See README.

The set-project-id cannot be used in Kptfile directly. errors

failed to set project-id setter: ... please include --include-meta-resources flag if a Kptfile is present

include-meta-resources is not supported in kpt fn render. Even if supported, it won't edit the actual resource files but only change Kptfile file.

Under the hood, set-project-id relies on apply-setter to do the real work. This is an anti-pattern of relying on set-project-id and other specific functions to build a setter free configurations.

@yuwenma yuwenma added the bug Something isn't working label Jan 29, 2022
@yuwenma yuwenma changed the title set-project-id cannot detect setters in Kptfile set-project-id relies on apply-setter to edit project Jan 29, 2022
@morgante
Copy link
Contributor

Was this a regression? It seems like he original purpose of set-project-id has significantly diverged from what it was meant to be in the first place. go/set-project-id

@yuwenma
Copy link
Contributor Author

yuwenma commented Jan 31, 2022

@morgante Correct. Current set-project-id is a regression and also introduces a bug to KCC blueprints:
Though set-project-id adds annotation cnrm.cloud.google.com/project-id, it doesn't give it the setter comment which means the annotation's project-id will be out of sync with other project-id once apply-setter runs.

I see the rationale behind set-project-id from go/set-project-id. I propose we remove set-project-id for now and I will come up with a solution (hopefully within this week).

@morgante
Copy link
Contributor

I am not supportive of removing set-project-id. It sounds like it was poorly implemented in the first place, but we should fix it instead of removing it.

I'm still not sure I follow the issue. If you don't use setters at all, does set-project-id not work?

@yuwenma
Copy link
Contributor Author

yuwenma commented Jan 31, 2022

"remove set-project-id" --> Rename set-project-id to something imperative (like add-project-id-setter) since it can only be run as imperative function. And also fix the issues I mentioned.

As a workaround before a setter free solution, I'm fine with the function to rely on apply-setter and modify the Kptfile file. But it should not be treated as curated and should not use misleading names.

@morgante
Copy link
Contributor

morgante commented Jan 31, 2022

"remove set-project-id" --> Rename set-project-id to something imperative (like add-project-id-setter) since it can only be run as imperative function. And also fix the issues I mentioned.

It was never intended to be "imperative-only." It sounds like the original implementation was done incorrectly, as go/set-project-id was meant to be usable in both imperative and declarative workflows.

I have no interest in a separate "imperative-only" function. Please focus on updating the existing function to match the spec I provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/fn-catalog Functions Catalog bug Something isn't working p1 triaged Issue has been triaged by adding an `area/` label
Projects
None yet
Development

No branches or pull requests

4 participants