From ac0cd1267a2a20d2c40b664ed9ba83392631a980 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <36107+shazron@users.noreply.github.com> Date: Wed, 20 Jul 2022 20:14:02 +0800 Subject: [PATCH] fix: ACNA-1375 - updater for runtimes.json for aio app run --local (#557) --- .../get-runtimes.js | 52 +++++++++++++++++++ bin/openwhisk-standalone-config/runtimes.json | 24 ++++++--- package.json | 3 +- 3 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 bin/openwhisk-standalone-config/get-runtimes.js diff --git a/bin/openwhisk-standalone-config/get-runtimes.js b/bin/openwhisk-standalone-config/get-runtimes.js new file mode 100644 index 00000000..47f1b813 --- /dev/null +++ b/bin/openwhisk-standalone-config/get-runtimes.js @@ -0,0 +1,52 @@ +/* +Copyright 2021 Adobe. All rights reserved. +This file is licensed to you under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. You may obtain a copy +of the License at http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS +OF ANY KIND, either express or implied. See the License for the specific language +governing permissions and limitations under the License. +*/ + +const fetch = require('node-fetch') + +const DOCKER_ORG = 'adobeapiplatform' +const DOCKER_REPOS = { // repo-name:kind + 'adobe-action-nodejs-v10': 'nodejs:10', + 'adobe-action-nodejs-v12': 'nodejs:12', + 'adobe-action-nodejs-v14': 'nodejs:14', + 'adobe-action-nodejs-v16': 'nodejs:16', +} + +const DEFAULT_KIND = 'nodejs:16' + +async function main() { + const nodejs = [] + + for ([repoName, kind] of Object.entries(DOCKER_REPOS)) { + const data = await fetch(`https://registry.hub.docker.com/v2/repositories/${DOCKER_ORG}/${repoName}/tags`) + const json = await data.json() + const defaultKind = (kind === DEFAULT_KIND)? true : undefined + + nodejs.push({ + kind, + default: defaultKind, + image: { + prefix: DOCKER_ORG, + name: repoName, + tag: json.results[0].name + } + }) + } + + const output = { + runtimes: { + nodejs + } + } + console.log(JSON.stringify(output, null, 2)) + } + + main() + \ No newline at end of file diff --git a/bin/openwhisk-standalone-config/runtimes.json b/bin/openwhisk-standalone-config/runtimes.json index 468b7773..e3da9c85 100644 --- a/bin/openwhisk-standalone-config/runtimes.json +++ b/bin/openwhisk-standalone-config/runtimes.json @@ -2,12 +2,11 @@ "runtimes": { "nodejs": [ { - "kind": "nodejs:14", - "default": true, + "kind": "nodejs:10", "image": { "prefix": "adobeapiplatform", - "name": "adobe-action-nodejs-v14", - "tag": "3.0.28" + "name": "adobe-action-nodejs-v10", + "tag": "3.0.32" } }, { @@ -15,15 +14,24 @@ "image": { "prefix": "adobeapiplatform", "name": "adobe-action-nodejs-v12", - "tag": "3.0.28" + "tag": "3.0.32" } }, { - "kind": "nodejs:10", + "kind": "nodejs:14", "image": { "prefix": "adobeapiplatform", - "name": "adobe-action-nodejs-v10", - "tag": "3.0.28" + "name": "adobe-action-nodejs-v14", + "tag": "3.0.32" + } + }, + { + "kind": "nodejs:16", + "default": true, + "image": { + "prefix": "adobeapiplatform", + "name": "adobe-action-nodejs-v16", + "tag": "3.0.32" } } ] diff --git a/package.json b/package.json index 0ba752c4..0675a63c 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,8 @@ "prepack": "oclif manifest && oclif readme", "test": "npm run unit-tests && npm run lint", "unit-tests": "jest -c jest.config.js", - "version": "oclif readme && git add README.md" + "version": "oclif readme && git add README.md", + "update-openwhisk-runtimes": "node bin/openwhisk-standalone-config/get-runtimes.js > bin/openwhisk-standalone-config/runtimes.json" }, "bin": { "aio-next": "./bin/run"