Skip to content

Commit

Permalink
Merge branch 'master' into implement-terraform-service-discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor committed Jul 10, 2020
2 parents 639b843 + db698b5 commit 482412e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
14 changes: 14 additions & 0 deletions lib/datasource/terraform-provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import URL from 'url';
import { logger } from '../../logger';
import * as packageCache from '../../util/cache/package';
import { Http } from '../../util/http';
import { GetReleasesConfig, ReleaseResult } from '../common';
import { ServiceDiscoveryResult } from '../terraform-module';
Expand Down Expand Up @@ -94,6 +95,17 @@ export async function getReleases({
}: GetReleasesConfig): Promise<ReleaseResult | null> {
const repository = `hashicorp/${lookupName}`;

const cacheNamespace = 'terraform-provider';
const pkgUrl = `${registryUrl}/${repository}`;
const cachedResult = await packageCache.get<ReleaseResult>(
cacheNamespace,
pkgUrl
);
// istanbul ignore if
if (cachedResult) {
return cachedResult;
}

logger.debug({ lookupName }, 'terraform-provider.getDependencies()');
let dep: ReleaseResult = null;
const registryHost = URL.parse(registryUrl).host;
Expand All @@ -102,5 +114,7 @@ export async function getReleases({
} else {
dep = await queryRegistry(lookupName, registryUrl, repository);
}
const cacheMinutes = 30;
await packageCache.set(cacheNamespace, pkgUrl, dep, cacheMinutes);
return dep;
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"@types/global-agent": "2.1.0",
"@types/got": "9.6.11",
"@types/ini": "1.3.30",
"@types/jest": "26.0.3",
"@types/jest": "26.0.4",
"@types/js-yaml": "3.12.4",
"@types/json-dup-key-validator": "1.0.0",
"@types/json5": "0.0.30",
Expand All @@ -210,7 +210,7 @@
"@types/markdown-table": "2.0.0",
"@types/moment-timezone": "0.5.13",
"@types/nock": "10.0.3",
"@types/node": "12.12.47",
"@types/node": "12.12.48",
"@types/node-emoji": "1.8.1",
"@types/parse-link-header": "1.0.0",
"@types/registry-auth-token": "3.3.0",
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1578,10 +1578,10 @@
"@types/istanbul-lib-coverage" "*"
"@types/istanbul-lib-report" "*"

"@types/jest@26.0.3":
version "26.0.3"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.3.tgz#79534e0e94857171c0edc596db0ebe7cb7863251"
integrity sha512-v89ga1clpVL/Y1+YI0eIu1VMW+KU7Xl8PhylVtDKVWaSUHBHYPLXMQGBdrpHewaKoTvlXkksbYqPgz8b4cmRZg==
"@types/jest@26.0.4":
version "26.0.4"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.4.tgz#d2e513e85aca16992816f192582b5e67b0b15efb"
integrity sha512-4fQNItvelbNA9+sFgU+fhJo8ZFF+AS4Egk3GWwCW2jFtViukXbnztccafAdLhzE/0EiCogljtQQXP8aQ9J7sFg==
dependencies:
jest-diff "^25.2.1"
pretty-format "^25.2.1"
Expand Down Expand Up @@ -1683,10 +1683,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.14.tgz#24a0b5959f16ac141aeb0c5b3cd7a15b7c64cbce"
integrity sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==

"@types/node@12.12.47":
version "12.12.47"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.47.tgz#5007b8866a2f9150de82335ca7e24dd1d59bdfb5"
integrity sha512-yzBInQFhdY8kaZmqoL2+3U5dSTMrKaYcb561VU+lDzAYvqt+2lojvBEy+hmpSNuXnPTx7m9+04CzWYOUqWME2A==
"@types/node@12.12.48":
version "12.12.48"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.48.tgz#4135f064eeed9fcfb4756deea5ba2caa11603391"
integrity sha512-m3Nmo/YaDUfYzdCQlxjF5pIy7TNyDTAJhIa//xtHcF0dlgYIBKULKnmloCPtByDxtZXrWV8Pge1AKT6/lRvVWg==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down

0 comments on commit 482412e

Please sign in to comment.