mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
fix(terraform): Adjust terraform ziphash fetching to mitigate caching issue (#25626)
This commit is contained in:
parent
6d48407d13
commit
a61e45b55d
3 changed files with 16 additions and 61 deletions
|
@ -426,18 +426,9 @@ describe('modules/datasource/terraform-provider/index', () => {
|
||||||
'fbdb892d9822ed0e4cb60f2fedbdbb556e4da0d88d3b942ae963ed6ff091e48f terraform-provider-azurerm_2.56.0_manifest.json'
|
'fbdb892d9822ed0e4cb60f2fedbdbb556e4da0d88d3b942ae963ed6ff091e48f terraform-provider-azurerm_2.56.0_manifest.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
const res = await terraformProviderDatasource.getZipHashes([
|
const res = await terraformProviderDatasource.getZipHashes(
|
||||||
{
|
'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_SHA256SUMS'
|
||||||
name: 'azurerm',
|
);
|
||||||
version: '2.56.0',
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
filename: 'terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
url: 'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
shasums_url:
|
|
||||||
'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_SHA256SUMS',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(res).toMatchObject([
|
expect(res).toMatchObject([
|
||||||
'500d4e787bf046bbe64c4853530aff3dfddee2fdbff0087d7b1e7a8c24388628',
|
'500d4e787bf046bbe64c4853530aff3dfddee2fdbff0087d7b1e7a8c24388628',
|
||||||
|
@ -446,27 +437,6 @@ describe('modules/datasource/terraform-provider/index', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not fetch anything when there are no builds passed in', async () => {
|
|
||||||
const res = await terraformProviderDatasource.getZipHashes([]);
|
|
||||||
|
|
||||||
expect(res).toBeEmptyArray();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not fetch anything when there is no shasums_url defined', async () => {
|
|
||||||
const res = await terraformProviderDatasource.getZipHashes([
|
|
||||||
{
|
|
||||||
name: 'azurerm',
|
|
||||||
version: '2.56.0',
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
filename: 'terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
url: 'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(res).toBeEmptyArray();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not hard fail when the ziphashes endpoint is not available', async () => {
|
it('does not hard fail when the ziphashes endpoint is not available', async () => {
|
||||||
httpMock
|
httpMock
|
||||||
.scope(secondaryUrl)
|
.scope(secondaryUrl)
|
||||||
|
@ -475,18 +445,9 @@ describe('modules/datasource/terraform-provider/index', () => {
|
||||||
)
|
)
|
||||||
.reply(404);
|
.reply(404);
|
||||||
|
|
||||||
const res = await terraformProviderDatasource.getZipHashes([
|
const res = await terraformProviderDatasource.getZipHashes(
|
||||||
{
|
'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_SHA256SUMS'
|
||||||
name: 'azurerm',
|
);
|
||||||
version: '2.56.0',
|
|
||||||
os: 'linux',
|
|
||||||
arch: 'amd64',
|
|
||||||
filename: 'terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
url: 'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_linux_amd64.zip',
|
|
||||||
shasums_url:
|
|
||||||
'https://releases.hashicorp.com/terraform-provider-azurerm/2.56.0/terraform-provider-azurerm_2.56.0_SHA256SUMS',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
expect(res).toBeUndefined();
|
expect(res).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
|
@ -284,20 +284,9 @@ export class TerraformProviderDatasource extends TerraformDatasource {
|
||||||
|
|
||||||
@cache({
|
@cache({
|
||||||
namespace: `datasource-${TerraformProviderDatasource.id}-zip-hashes`,
|
namespace: `datasource-${TerraformProviderDatasource.id}-zip-hashes`,
|
||||||
key: (registryURL: string, repository: string, version: string) =>
|
key: (zipHashUrl: string) => zipHashUrl,
|
||||||
`${registryURL}/${repository}/${version}`,
|
|
||||||
})
|
})
|
||||||
async getZipHashes(builds: TerraformBuild[]): Promise<string[] | undefined> {
|
async getZipHashes(zipHashUrl: string): Promise<string[] | undefined> {
|
||||||
if (builds.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const zipHashUrl = builds[0].shasums_url;
|
|
||||||
|
|
||||||
if (!zipHashUrl) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
// The hashes are formatted as the result of sha256sum in plain text, each line: <hash>\t<filename>
|
// The hashes are formatted as the result of sha256sum in plain text, each line: <hash>\t<filename>
|
||||||
let rawHashData: string;
|
let rawHashData: string;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -115,9 +115,14 @@ export class TerraformProviderHash {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zhHashes =
|
let zhHashes: string[] = [];
|
||||||
(await TerraformProviderHash.terraformDatasource.getZipHashes(builds)) ??
|
if (builds.length > 0 && builds[0].shasums_url) {
|
||||||
[];
|
zhHashes =
|
||||||
|
(await TerraformProviderHash.terraformDatasource.getZipHashes(
|
||||||
|
builds[0].shasums_url
|
||||||
|
)) ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
const h1Hashes = await TerraformProviderHash.calculateHashScheme1Hashes(
|
const h1Hashes = await TerraformProviderHash.calculateHashScheme1Hashes(
|
||||||
builds
|
builds
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue