Skip to content
Snippets Groups Projects
Unverified Commit 21d2aeb7 authored by Sergei Zharinov's avatar Sergei Zharinov Committed by GitHub
Browse files

refactor(terraform): Use util function for cache dir creation (#10588)

parent 11f89147
No related merge requests found
......@@ -10,8 +10,9 @@ import type {
import { logger } from '../../../logger';
import * as packageCache from '../../../util/cache/package';
import * as fs from '../../../util/fs';
import { ensureCacheDir } from '../../../util/fs';
import { Http } from '../../../util/http';
import { getCacheDir, repositoryRegex } from './util';
import { repositoryRegex } from './util';
const http = new Http(TerraformProviderDatasource.id);
const hashCacheTTL = 10080; // in seconds == 1 week
......@@ -75,7 +76,7 @@ async function getReleaseBackendIndex(
export async function calculateHashes(
builds: TerraformBuild[]
): Promise<string[]> {
const cacheDir = await getCacheDir();
const cacheDir = await ensureCacheDir('./others/terraform');
// for each build download ZIP, extract content and generate hash for all containing files
const hashes = await pMap(
......
import { join } from 'upath';
import { getAdminConfig } from '../../../config/admin';
import { logger } from '../../../logger';
import { ensureDir, getSiblingFileName, readLocalFile } from '../../../util/fs';
import { getSiblingFileName, readLocalFile } from '../../../util/fs';
import { get as getVersioning } from '../../../versioning';
import type { UpdateArtifactsResult } from '../../types';
import type {
......@@ -210,10 +207,3 @@ export function writeLockUpdates(
},
};
}
export async function getCacheDir(): Promise<string> {
const cacheDir = join(getAdminConfig().cacheDir, './others/terraform');
await ensureDir(cacheDir);
logger.debug(`Using terraform cache: ${cacheDir}`);
return cacheDir;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment