Skip to content

Commit

Permalink
chore(sveltos): implement feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Bähler <[email protected]>
  • Loading branch information
oliverbaehler committed Aug 28, 2024
1 parent d33fb48 commit 3d3162f
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/modules/manager/sveltos/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,32 @@ export function extractPackageFile(
): PackageFileContent | null {
let definitions: ProfileDefinition[];
try {
definitions = parseYaml(content, {
definitions = parseYaml(content, null, {

Check failure on line 25 in lib/modules/manager/sveltos/extract.ts

View workflow job for this annotation

GitHub Actions / build

Expected 1-2 arguments, but got 3.

Check failure on line 25 in lib/modules/manager/sveltos/extract.ts

View workflow job for this annotation

GitHub Actions / lint-other

Expected 1-2 arguments, but got 3.
customSchema: ProfileDefinition,
});
} catch (err) {
logger.debug({ err, packageFile }, 'Failed to parse Sveltos definition.');
return null;
}

const deps = definitions.flatMap((definition) => {
// Use zod's safeParse method to check if the object matches the ProfileDefinition schema
const result = ProfileDefinition.safeParse(definition);
if (result.success) {
return processAppSpec(result.data, config);
}
return [];
});
const deps = definitions.flatMap((definition) =>
extractDefinition(definition, config),
);

return deps.length ? { deps } : null;
}

function extractDefinition(
definition: ProfileDefinition,
config?: ExtractConfig,
): PackageDependency[] {
const result = ProfileDefinition.safeParse(definition);
if (result.success) {
return processAppSpec(result.data, config);
}
return [];
}

function processHelmCharts(
source: SveltosHelmSource,
registryAliases: Record<string, string> | undefined,
Expand Down

0 comments on commit 3d3162f

Please sign in to comment.