From 90eb9b74049de4f0d24fc058ede675914ac1f478 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Fri, 6 Oct 2023 14:29:25 +0200 Subject: [PATCH] feat: add environment variable for push helm package --- README.md | 7 +++ package-lock.json | 46 ++++++++++++++++++- package.json | 1 + plugins/nx-helm-plugin/package.json | 1 + .../src/executors/build/executor.ts | 8 +++- 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d71d036..adc04d9 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,10 @@ [![License](https://img.shields.io/github/license/1000kit/nx-plugins?style=for-the-badge&logo=apache)](https://www.apache.org/licenses/LICENSE-2.0) [![Release version](https://img.shields.io/npm/v/%401000kit%2Fnx-helm-plugin?style=for-the-badge&logo=npm)](https://www.npmjs.com/package/@1000kit/nx-helm-plugin) + + +## Configuration + +### nx-helm-plugin + +To push helm package to OCI registry, you need to update the options.push property of your project target or use the INPUT_TKIT_HELM_PUSH environment variable. \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1dc040c..cb2a7f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,15 @@ { "name": "@1000kit/nx-plugins", - "version": "0.0.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@1000kit/nx-plugins", - "version": "0.0.0", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { + "@nx-tools/core": "^5.0.3", "@nx/devkit": "16.9.1", "@nx/plugin": "^16.9.1", "@swc/helpers": "~0.5.2", @@ -57,6 +58,19 @@ "node": ">=0.10.0" } }, + "node_modules/@actions/exec": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", + "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", + "dependencies": { + "@actions/io": "^1.0.1" + } + }, + "node_modules/@actions/io": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", + "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" + }, "node_modules/@ampproject/remapping": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.1.tgz", @@ -2545,6 +2559,34 @@ "@nx/workspace": "16.9.1" } }, + "node_modules/@nx-tools/core": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/@nx-tools/core/-/core-5.0.3.tgz", + "integrity": "sha512-Ao3hmQ9DC+E8d2bdR2xqix0cmHsCrZxe0GDNZfOgfCde1tUppPJ2Po/m3iFxI5gEFWuEEsCQFm9CRtaMuyc1Dg==", + "dependencies": { + "@actions/exec": "1.1.1", + "chalk": "4.1.2", + "ci-info": "3.8.0" + }, + "peerDependencies": { + "@nx/devkit": "^16.0.0", + "tslib": "^2.5.3" + } + }, + "node_modules/@nx-tools/core/node_modules/ci-info": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.8.0.tgz", + "integrity": "sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/sibiraj-s" + } + ], + "engines": { + "node": ">=8" + } + }, "node_modules/@nx/devkit": { "version": "16.9.1", "resolved": "https://registry.npmjs.org/@nx/devkit/-/devkit-16.9.1.tgz", diff --git a/package.json b/package.json index be04e5d..38d5c03 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "scripts": {}, "private": true, "dependencies": { + "@nx-tools/core": "^5.0.3", "@nx/devkit": "16.9.1", "@nx/plugin": "^16.9.1", "@swc/helpers": "~0.5.2", diff --git a/plugins/nx-helm-plugin/package.json b/plugins/nx-helm-plugin/package.json index c30e641..6b5fc15 100644 --- a/plugins/nx-helm-plugin/package.json +++ b/plugins/nx-helm-plugin/package.json @@ -15,6 +15,7 @@ "name": "Andrej Petras" }, "dependencies": { + "@nx-tools/core": "^5.0.3", "@nx/devkit": "16.9.1", "lodash.merge": "^4.6.2", "tslib": "^2.3.0", diff --git a/plugins/nx-helm-plugin/src/executors/build/executor.ts b/plugins/nx-helm-plugin/src/executors/build/executor.ts index 35eeefd..6b4fc51 100644 --- a/plugins/nx-helm-plugin/src/executors/build/executor.ts +++ b/plugins/nx-helm-plugin/src/executors/build/executor.ts @@ -5,6 +5,7 @@ import { exec } from 'child_process'; import * as fs from 'fs'; import { parse, stringify } from 'yaml'; import merge from 'lodash.merge'; +import { getBooleanInput } from '@nx-tools/core'; export default async function runExecutor(options: BuildExecutorSchema, context: ExecutorContext) { @@ -18,6 +19,9 @@ export default async function runExecutor(options: BuildExecutorSchema, context: const chartName = options.chartName || context.projectName; const helmDir = projSourceDir + '/' + options.dir; + const prefix = 'tkit_helm' + const push = getBooleanInput('push', { prefix, fallback: `${options.push}` || 'false' }); + console.info('%s helm directory: %s', _prefix, helmDir) @@ -35,8 +39,8 @@ export default async function runExecutor(options: BuildExecutorSchema, context: await cmd(_prefix, `helm package ${context.cwd}/${helmDir} --version ${options.version}`); const packageFile = context.cwd + '/' + chartName + '-' + options.version + ".tgz"; - if (options.push) { - await cmd(_prefix, `helm push ${packageFile} ${options.registry}`); + if (push) { + await cmd(_prefix, `helm push ${packageFile} ${options.registry}`); } else { console.info('%s skip push release version of the helm chart file %s', _prefix, packageFile); }