aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/datasource/helm/__snapshots__/index.spec.ts.snap2
-rw-r--r--lib/datasource/helm/index.spec.ts32
-rw-r--r--lib/datasource/helm/index.ts5
-rw-r--r--lib/datasource/rubygems/get.ts3
4 files changed, 28 insertions, 14 deletions
diff --git a/lib/datasource/helm/__snapshots__/index.spec.ts.snap b/lib/datasource/helm/__snapshots__/index.spec.ts.snap
index 11e2ce569c9..ce20b09edf6 100644
--- a/lib/datasource/helm/__snapshots__/index.spec.ts.snap
+++ b/lib/datasource/helm/__snapshots__/index.spec.ts.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`datasource/helm getReleases returns list of versions for normal response if index.yaml is not cached 1`] = `
+exports[`datasource/helm getReleases returns list of versions for normal response 1`] = `
Object {
"homepage": "https://www.getambassador.io/",
"name": "ambassador",
diff --git a/lib/datasource/helm/index.spec.ts b/lib/datasource/helm/index.spec.ts
index e4161036797..b86199f2450 100644
--- a/lib/datasource/helm/index.spec.ts
+++ b/lib/datasource/helm/index.spec.ts
@@ -21,7 +21,7 @@ describe('datasource/helm', () => {
expect(
await getReleases({
lookupName: undefined,
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
})
).toBeNull();
});
@@ -38,7 +38,7 @@ describe('datasource/helm', () => {
expect(
await getReleases({
lookupName: 'non_existent_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
})
).toBeNull();
});
@@ -49,7 +49,7 @@ describe('datasource/helm', () => {
expect(
await getReleases({
lookupName: 'non_existent_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
})
).toBeNull();
});
@@ -62,7 +62,7 @@ describe('datasource/helm', () => {
expect(
await getReleases({
lookupName: 'some_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
})
).toBeNull();
});
@@ -76,7 +76,7 @@ describe('datasource/helm', () => {
try {
await getReleases({
lookupName: 'some_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
});
} catch (err) {
e = err;
@@ -91,7 +91,7 @@ describe('datasource/helm', () => {
expect(
await getReleases({
lookupName: 'some_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
})
).toBeNull();
});
@@ -100,7 +100,7 @@ describe('datasource/helm', () => {
got.mockReturnValueOnce(res);
const releases = await getReleases({
lookupName: 'non_existent_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
});
expect(releases).toBeNull();
});
@@ -114,7 +114,7 @@ describe('datasource/helm', () => {
got.mockReturnValueOnce(res);
const releases = await getReleases({
lookupName: 'non_existent_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
});
expect(releases).toBeNull();
});
@@ -122,18 +122,28 @@ describe('datasource/helm', () => {
got.mockReturnValueOnce({ body: indexYaml });
const releases = await getReleases({
lookupName: 'non_existent_chart',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
});
expect(releases).toBeNull();
});
- it('returns list of versions for normal response if index.yaml is not cached', async () => {
+ it('returns list of versions for normal response', async () => {
got.mockReturnValueOnce({ body: indexYaml });
const releases = await getReleases({
lookupName: 'ambassador',
- registryUrls: ['example-repository.com'],
+ registryUrls: ['https://example-repository.com'],
});
expect(releases).not.toBeNull();
expect(releases).toMatchSnapshot();
});
+ it('adds trailing slash to subdirectories', async () => {
+ got.mockReturnValueOnce({ body: indexYaml });
+ await getReleases({
+ lookupName: 'ambassador',
+ registryUrls: ['https://example-repository.com/subdir'],
+ });
+ expect(got.mock.calls[0][0]).toEqual(
+ 'https://example-repository.com/subdir/index.yaml'
+ );
+ });
});
});
diff --git a/lib/datasource/helm/index.ts b/lib/datasource/helm/index.ts
index ad29e349439..d646d07d217 100644
--- a/lib/datasource/helm/index.ts
+++ b/lib/datasource/helm/index.ts
@@ -3,6 +3,7 @@ import yaml from 'js-yaml';
import { logger } from '../../logger';
import * as globalCache from '../../util/cache/global';
import { Http } from '../../util/http';
+import { ensureTrailingSlash } from '../../util/url';
import { DatasourceError, GetReleasesConfig, ReleaseResult } from '../common';
export const id = 'helm';
@@ -25,7 +26,9 @@ export async function getRepositoryData(
}
let res: any;
try {
- res = await http.get('index.yaml', { baseUrl: repository });
+ res = await http.get('index.yaml', {
+ baseUrl: ensureTrailingSlash(repository),
+ });
if (!res || !res.body) {
logger.warn(`Received invalid response from ${repository}`);
return null;
diff --git a/lib/datasource/rubygems/get.ts b/lib/datasource/rubygems/get.ts
index 7a0874087e0..91e72767f0d 100644
--- a/lib/datasource/rubygems/get.ts
+++ b/lib/datasource/rubygems/get.ts
@@ -2,6 +2,7 @@ import { OutgoingHttpHeaders } from 'http';
import { logger } from '../../logger';
import { Http } from '../../util/http';
import { maskToken } from '../../util/mask';
+import { ensureTrailingSlash } from '../../util/url';
import { ReleaseResult } from '../common';
import { id } from './common';
import { FORBIDDEN, NOT_FOUND, UNAUTHORIZED } from './errors';
@@ -39,7 +40,7 @@ const fetch = async ({ dependency, registry, path }): Promise<any> => {
const headers = getHeaders();
const name = `${path}/${dependency}.json`;
- const baseUrl = registry;
+ const baseUrl = ensureTrailingSlash(registry);
logger.trace({ dependency }, `RubyGems lookup request: ${baseUrl} ${name}`);
const response = (await http.getJson(name, { baseUrl, headers })) || {