Skip to content

refactor: add GenerateManifest to decouple generating kustomizations from writing#1153

Open
rycli wants to merge 6 commits intofluxcd:mainfrom
rycli:fix/in-memory-kustomize-vfs
Open

refactor: add GenerateManifest to decouple generating kustomizations from writing#1153
rycli wants to merge 6 commits intofluxcd:mainfrom
rycli:fix/in-memory-kustomize-vfs

Conversation

@rycli
Copy link
Copy Markdown

@rycli rycli commented Mar 29, 2026

One half of changes necessary to resolve fluxcd/flux2#5781 ; foundation needed for the changes introduced by fluxcd/flux2#5794

These changes to kustomize_generator decouple the file reading/generating logic from the writing and cleanup steps.

The WriteFile function keeps the same behavior, so no change to existing callers; but it now wraps GenerateManifest internally which extracts the logic for generating kustomizations. This allows calling the generating logic directly without writing the files :-)

@rycli rycli force-pushed the fix/in-memory-kustomize-vfs branch 2 times, most recently from 8bc7bfb to 94b031e Compare March 29, 2026 19:21
@stefanprodan stefanprodan added enhancement New feature or request area/kustomize Kustomize related issues and pull requests labels Mar 30, 2026
@rycli rycli force-pushed the fix/in-memory-kustomize-vfs branch from 94b031e to 5dc2b1c Compare March 30, 2026 18:25
rycli added 4 commits April 2, 2026 14:02
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
@rycli rycli force-pushed the fix/in-memory-kustomize-vfs branch from 5dc2b1c to d3d47ff Compare April 2, 2026 12:02
return UnchangedAction, kpath, nil
kpath := filepath.Join(dirPath, kfilename)
if fs.Exists(kpath) && !fs.IsDir(kpath) {
data, err := os.ReadFile(kpath)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

rycli added 2 commits April 4, 2026 14:03
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Signed-off-by: Cyril Mengin <cyril@ryc.li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kustomize Kustomize related issues and pull requests enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'flux build kustomization' corrupts files when run concurrently

2 participants