Skip to content

Commit

Permalink
fix(datasource/helm): Skip helm charts with no listed versions (#23223)
Browse files Browse the repository at this point in the history
  • Loading branch information
MJDSys committed Jul 17, 2023
1 parent 6b11746 commit ab7f679
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/modules/datasource/helm/__fixtures__/index_emptypackage.yaml
@@ -0,0 +1,19 @@
apiVersion: v1
entries:
aerospike: []
ambassador:
- apiVersion: v1
appVersion: 0.70.1
created: 2019-06-02T08:56:36.119470813Z
description: A Helm chart for Datawire Ambassador
digest: 880002d74accfc9dab1debcc78c134fb4989e73ff84b137ce7aa92bf4d726297
engine: gotpl
home: https://www.getambassador.io/
icon: https://www.getambassador.io/images/logo.png
name: ambassador
sources:
- https://github.com/datawire/ambassador
- https://github.com/prometheus/statsd_exporter
urls:
- https://charts.helm.sh/stable/packages/ambassador-2.7.0.tgz
version: 2.7.0
18 changes: 18 additions & 0 deletions lib/modules/datasource/helm/index.spec.ts
Expand Up @@ -167,6 +167,24 @@ describe('modules/datasource/helm/index', () => {
expect(releases).toMatchSnapshot();
});

it('returns list of versions for other packages if one packages has no versions', async () => {
httpMock
.scope('https://example-repository.com')
.get('/index.yaml')
.reply(200, Fixtures.get('index_emptypackage.yaml'));
const releases = await getPkgReleases({
datasource: HelmDatasource.id,
packageName: 'ambassador',
registryUrls: ['https://example-repository.com'],
});
expect(releases).toMatchObject({
homepage: 'https://www.getambassador.io/',
registryUrl: 'https://example-repository.com',
sourceUrl: 'https://github.com/datawire/ambassador',
releases: expect.toBeArrayOfSize(1),
});
});

it('adds trailing slash to subdirectories', async () => {
httpMock
.scope('https://example-repository.com')
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/datasource/helm/index.ts
Expand Up @@ -60,6 +60,9 @@ export class HelmDatasource extends Datasource {
}
const result: HelmRepositoryData = {};
for (const [name, releases] of Object.entries(doc.entries)) {
if (releases.length === 0) {
continue;
}
const latestRelease = releases[0];
const sourceUrl = findSourceUrl(latestRelease);
result[name] = {
Expand Down

0 comments on commit ab7f679

Please sign in to comment.