Skip to content
Snippets Groups Projects
Unverified Commit dc9c2054 authored by Usman's avatar Usman Committed by GitHub
Browse files

feat(manager/flux): support system manifest inside subdirectories (#18605)

parent c8349473
No related branches found
No related tags found
No related merge requests found
...@@ -48,6 +48,43 @@ describe('modules/manager/flux/artifacts', () => { ...@@ -48,6 +48,43 @@ describe('modules/manager/flux/artifacts', () => {
]); ]);
}); });
it('detects system manifests in subdirectories', async () => {
const snapshots = mockExecAll({ stdout: '', stderr: '' });
fs.readLocalFile.mockResolvedValueOnce('old');
fs.readLocalFile.mockResolvedValueOnce('test');
const res = await updateArtifacts({
packageFileName:
'clusters/my-cluster/flux-system/gitops-toolkit/gotk-components.yaml',
updatedDeps: [
{
newVersion: '1.0.1',
managerData: {
components:
'source-controller,kustomize-controller,helm-controller,notification-controller',
},
},
],
newPackageFileContent: '',
config: {},
});
expect(res).toEqual([
{
file: {
type: 'addition',
path: 'clusters/my-cluster/flux-system/gitops-toolkit/gotk-components.yaml',
contents: 'test',
},
},
]);
expect(snapshots).toMatchObject([
{
cmd: 'flux install --export --components source-controller,kustomize-controller,helm-controller,notification-controller > clusters/my-cluster/flux-system/gitops-toolkit/gotk-components.yaml',
},
]);
});
it('ignores non-system manifests', async () => { it('ignores non-system manifests', async () => {
const res = await updateArtifacts({ const res = await updateArtifacts({
packageFileName: 'not-a-system-manifest.yaml', packageFileName: 'not-a-system-manifest.yaml',
......
import { regEx } from '../../../util/regex'; import { regEx } from '../../../util/regex';
export const systemManifestRegex = '(^|/)flux-system/gotk-components\\.yaml$'; export const systemManifestRegex =
'(^|\\/)flux-system\\/(?:.+\\/)?gotk-components\\.yaml$';
export function isSystemManifest(file: string): boolean { export function isSystemManifest(file: string): boolean {
return regEx(systemManifestRegex).test(file); return regEx(systemManifestRegex).test(file);
} }
...@@ -31,7 +31,7 @@ Updating system manifests requires that either: ...@@ -31,7 +31,7 @@ Updating system manifests requires that either:
### Non-configured fileMatch ### Non-configured fileMatch
By default, the `flux` manager will only match `flux-system/gotk-components.yaml` (i.e. system manifest) files. By default, the `flux` manager will only match `flux-system/{.,**}/gotk-components.yaml` (i.e. system manifest) files.
This is because there is no commonly accepted file/directory naming convention for Flux manifests and we don't want to check every single `*.yaml` file in repositories just in case some of them have Flux definitions. This is because there is no commonly accepted file/directory naming convention for Flux manifests and we don't want to check every single `*.yaml` file in repositories just in case some of them have Flux definitions.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment