refactor: add GenerateManifest to decouple generating kustomizations from writing#1153
Open
rycli wants to merge 6 commits intofluxcd:mainfrom
Open
refactor: add GenerateManifest to decouple generating kustomizations from writing#1153rycli wants to merge 6 commits intofluxcd:mainfrom
rycli wants to merge 6 commits intofluxcd:mainfrom
Conversation
3815efd to
6a89ab1
Compare
8bc7bfb to
94b031e
Compare
rycli
commented
Mar 29, 2026
94b031e to
5dc2b1c
Compare
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
5dc2b1c to
d3d47ff
Compare
stefanprodan
reviewed
Apr 3, 2026
kustomize/kustomize_generator.go
Outdated
| return UnchangedAction, kpath, nil | ||
| kpath := filepath.Join(dirPath, kfilename) | ||
| if fs.Exists(kpath) && !fs.IsDir(kpath) { | ||
| data, err := os.ReadFile(kpath) |
Member
There was a problem hiding this comment.
We are bypassing the secure FS with os.ReadFile maybe this would be better:
Suggested change
| data, err := os.ReadFile(kpath) | |
| data, err := fs.ReadFile(kpath) |
Author
There was a problem hiding this comment.
There's a few more occurrences of this, so if we want to be consistent we could keep an fs instance in the generator to use throughout. Implemented it in the latest commit, if that's a direction you'd like to go 🤔
(Also had to update a test accordingly; using the secure fs throughout had it passing tests on incorrect paths, from what I understand.)
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One half of changes necessary to resolve fluxcd/flux2#5781 ; foundation needed for the changes introduced by fluxcd/flux2#5794
These changes to
kustomize_generatordecouple the file reading/generating logic from the writing and cleanup steps.The
WriteFilefunction keeps the same behavior, so no change to existing callers; but it now wrapsGenerateManifestinternally which extracts the logic for generating kustomizations. This allows calling the generating logic directly without writing the files :-)