Skip to content

Commit

Permalink
chore: add HelmRepository type
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 17, 2021
1 parent d92dc80 commit 949299e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/datasource/helm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,26 @@ export async function getRepositoryData(
throw err;
}
try {
const doc = yaml.safeLoad(res.body, { json: true });
interface HelmRepository {
entries: Record<
string,
{
home?: string;
sources?: string[];
version: string;
created: string;
}[]
>;
}
const doc: HelmRepository = yaml.safeLoad(res.body, {
json: true,
}) as any;
if (!is.plainObject<Record<string, unknown>>(doc)) {
logger.warn(`Failed to parse index.yaml from ${repository}`);
return null;
}
const result: ReleaseResult[] = Object.entries(doc.entries).map(
([k, v]: [string, any]): ReleaseResult => ({
([k, v]): ReleaseResult => ({
name: k,
homepage: v[0].home,
sourceUrl: v[0].sources ? v[0].sources[0] : undefined,
Expand Down

0 comments on commit 949299e

Please sign in to comment.