From 22939b1817c81365e2c264d7d1e2abea889759b9 Mon Sep 17 00:00:00 2001 From: Benjamin Reed Date: Tue, 3 Dec 2024 15:01:13 -0500 Subject: [PATCH] fix: generate the values schema to not require external URLs fixes #431 --- .github/workflows/ci.yml | 5 ++ .github/workflows/lint.yml | 5 ++ .github/workflows/release.yml | 5 ++ .github/workflows/test.yml | 5 ++ .gitignore | 3 + ...lues.schema.json => values.schema.in.json} | 4 +- generate-values-schema.js | 16 +++++ package-lock.json | 68 +++++++++++++++++++ package.json | 22 ++++++ 9 files changed, 131 insertions(+), 2 deletions(-) rename charts/netbox/{values.schema.json => values.schema.in.json} (99%) create mode 100644 generate-values-schema.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b44cf4df..78c4dda0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,11 @@ jobs: with: fetch-depth: 0 + - name: Generate production values.yaml schema + run: | + npm --no-progress --no-audit ci + npm run schema + - name: Set up chart-testing uses: helm/chart-testing-action@v2.6.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ebbabb7e..63c7e7b8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,6 +23,11 @@ jobs: with: fetch-depth: 0 + - name: Generate production values.yaml schema + run: | + npm --no-progress --no-audit ci + npm run schema + - name: Lint Code Base uses: super-linter/super-linter/slim@v7.2.0 env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0787a50e..7bb5e994 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,11 @@ jobs: with: fetch-depth: 0 + - name: Generate production values.yaml schema + run: | + npm --no-progress --no-audit ci + npm run schema + - name: Configure Git run: | git config user.name "$GITHUB_ACTOR" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 025c46b9..4d35c7e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,11 @@ jobs: with: fetch-depth: 0 + - name: Generate production values.yaml schema + run: | + npm --no-progress --no-audit ci + npm run schema + - name: Set up Helm uses: azure/setup-helm@v4.2.0 diff --git a/.gitignore b/.gitignore index 0a52c0e8..60193bbb 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ dist/ values-*.yaml .history /public + +/charts/netbox/values.schema.json +/node_modules diff --git a/charts/netbox/values.schema.json b/charts/netbox/values.schema.in.json similarity index 99% rename from charts/netbox/values.schema.json rename to charts/netbox/values.schema.in.json index 51cd2001..ddbee924 100644 --- a/charts/netbox/values.schema.json +++ b/charts/netbox/values.schema.in.json @@ -894,7 +894,7 @@ "description": "https://artifacthub.io/packages/helm/bitnami/postgresql", "allOf": [ { - "$ref": "https://raw.githubusercontent.com/bitnami/charts/master/bitnami/postgresql/values.schema.json" + "$ref": "https://raw.githubusercontent.com/bitnami/charts/refs/tags/postgresql/16.2.4/bitnami/postgresql/values.schema.json" }, { "properties": { @@ -935,7 +935,7 @@ "description": "https://artifacthub.io/packages/helm/bitnami/redis", "allOf": [ { - "$ref": "https://raw.githubusercontent.com/bitnami/charts/master/bitnami/redis/values.schema.json" + "$ref": "https://raw.githubusercontent.com/bitnami/charts/refs/tags/redis/20.4.0/bitnami/redis/values.schema.json" }, { "properties": { diff --git a/generate-values-schema.js b/generate-values-schema.js new file mode 100644 index 00000000..3e757aea --- /dev/null +++ b/generate-values-schema.js @@ -0,0 +1,16 @@ +import $RefParser from '@apidevtools/json-schema-ref-parser' +import fs from 'fs' + +const mySchema = JSON.parse( + fs.readFileSync('./charts/netbox/values.schema.in.json', 'utf-8') +) + +try { + await $RefParser.dereference(mySchema) + fs.writeFileSync( + './charts/netbox/values.schema.json', + JSON.stringify(mySchema, undefined, 2) + '\n' + ) +} catch (err) { + console.error(err) +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..650ad303 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,68 @@ +{ + "name": "netbox-chart", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "netbox-chart", + "version": "0.1.0", + "license": "MIT", + "devDependencies": { + "@apidevtools/json-schema-ref-parser": "^11.7.2" + } + }, + "node_modules/@apidevtools/json-schema-ref-parser": { + "version": "11.7.2", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-11.7.2.tgz", + "integrity": "sha512-4gY54eEGEstClvEkGnwVkTkrx0sqwemEFG5OSRRn3tD91XH0+Q8XIkYIfo7IwEWPpJZwILb9GUXeShtplRc/eA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.15", + "js-yaml": "^4.1.0" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://github.com/sponsors/philsturgeon" + } + }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..472a7c00 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "netbox-chart", + "version": "0.1.0", + "type": "module", + "description": "NetBox Helm Chart", + "repository": { + "type": "git", + "url": "git+https://github.com/netboxcommunity/helm-chart.git" + }, + "author": "Benjamin Reed ", + "license": "MIT", + "bugs": { + "url": "https://github.com/netboxcommunity/helm-chart/issues" + }, + "homepage": "https://github.com/netboxcommunity/helm-chart#readme", + "scripts": { + "schema": "node ./generate-values-schema.js" + }, + "devDependencies": { + "@apidevtools/json-schema-ref-parser": "^11.7.2" + } +}