feat(manager/flux) undo refactoring upon review request

This commit is contained in:
Sebastian Sams 2024-12-20 07:55:18 +00:00
parent 88fd3792b2
commit 0899693f72
2 changed files with 18 additions and 21 deletions

View file

@ -1,6 +1,4 @@
import { regEx } from '../../../util/regex';
import type { HelmRepository } from './schema';
import type { FluxManifest } from './types';
export const systemManifestFileNameRegex = '(?:^|/)gotk-components\\.ya?ml$';
@ -10,19 +8,3 @@ export const systemManifestHeaderRegex =
export function isSystemManifest(file: string): boolean {
return regEx(systemManifestFileNameRegex).test(file);
}
export function collectHelmRepos(manifests: FluxManifest[]): HelmRepository[] {
const helmRepositories: HelmRepository[] = [];
for (const manifest of manifests) {
if (manifest.kind === 'resource') {
for (const resource of manifest.resources) {
if (resource.kind === 'HelmRepository') {
helmRepositories.push(resource);
}
}
}
}
return helmRepositories;
}

View file

@ -22,7 +22,6 @@ import type {
PackageFileContent,
} from '../types';
import {
collectHelmRepos,
isSystemManifest,
systemManifestHeaderRegex,
} from './common';
@ -305,7 +304,14 @@ export function extractPackageFile(
if (!manifest) {
return null;
}
const helmRepositories = collectHelmRepos([manifest]);
const helmRepositories: HelmRepository[] = [];
if (manifest.kind === 'resource') {
for (const resource of manifest.resources) {
if (resource.kind === 'HelmRepository') {
helmRepositories.push(resource);
}
}
}
let deps: PackageDependency[] | null = null;
switch (manifest.kind) {
case 'system':
@ -339,7 +345,16 @@ export async function extractAllPackageFiles(
}
}
const helmRepositories = collectHelmRepos(manifests);
const helmRepositories: HelmRepository[] = [];
for (const manifest of manifests) {
if (manifest.kind === 'resource') {
for (const resource of manifest.resources) {
if (resource.kind === 'HelmRepository') {
helmRepositories.push(resource);
}
}
}
}
for (const manifest of manifests) {
let deps: PackageDependency[] | null = null;