From 4068c944803f313ecd70e5d409816235771d35c2 Mon Sep 17 00:00:00 2001 From: LucaZanni Date: Tue, 1 Oct 2024 14:11:50 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Aggiungi=20il=20supporto=20per=20la?= =?UTF-8?q?=20dimensione=20del=20Persistent=20Volume=20Claim=20(PVC)=20=20?= =?UTF-8?q?=20nel=20README,=20action.yml=20e=20index.js=20per=20migliorare?= =?UTF-8?q?=20la=20configurabilit=C3=A0=20=20=20e=20la=20funzionalit=C3=A0?= =?UTF-8?q?=20dell'azione.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- action.yml | 3 +++ index.js | 23 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6177fa6..dbe46d0 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ jobs: | `memoryRequest`| The minimum amount of memory guaranteed for each container, expressed in MiB (e.g., 512Mi). | No |`512Mi`| | `cpuLimit`| The maximum amount of CPU a container can use, expressed in milliCPU (e.g., 1000m means one full CPU). | No |`1000m`| | `memoryLimit`| The maximum amount of memory a container can use, expressed in MiB (e.g., 1024Mi). | No |`1024Mi`| - +| `pvcSize` | Persistent Volume Claim size (e.g. 1Gi, 10Gi) | No | `1Gi` | ## Outputs This action produce artifact. diff --git a/action.yml b/action.yml index 61a787b..c2e7fe1 100644 --- a/action.yml +++ b/action.yml @@ -74,6 +74,9 @@ inputs: description: 'Output Directory path' required: false default: '.' + pvcSize: + description: 'Persistent Volume Claim size (e.g. 1Gi, 100m)' + required: false runs: using: 'node20' main: 'dist/index.js' diff --git a/index.js b/index.js index 6877ba3..75c9ebf 100644 --- a/index.js +++ b/index.js @@ -115,6 +115,9 @@ const config = { cpuLimit: core.getInput('cpuLimit') || defaultConfig.cpuLimit, memoryLimit: core.getInput('memoryLimit') || defaultConfig.memoryLimit }; +const pvcSize = core.getInput("pvcSize"); +if (pvcSize) + log(`pvcSize: ${pvcSize}`); log(`config: ${JSON.stringify(config)}`); // Ensure mandatory parameters are present @@ -201,6 +204,22 @@ if (imagePullSecretsName) { deployment.spec.template.spec.imagePullSecrets = [{ name: imagePullSecretsName }]; log(`deployment.spec.template.spec.imagePullSecrets: ${JSON.stringify(deployment.spec.template.spec.imagePullSecrets)}`); } +// PersistentVolumeClaim +const pvc = { + apiVersion: "v1", + kind: "PersistentVolumeClaim", + metadata: { ...baseMetadata, name: `${packageJson.name}-pvc` }, + spec: { + accessModes: ["ReadWriteOnce"], + resources: { + requests: { + storage: pvcSize + } + } + } +}; +if (pvcSize) + log(`pvc: ${JSON.stringify(pvc)}`); // HorizontalPodAutoscaler const autoscaler = { @@ -233,7 +252,9 @@ if (envExist) yamlContents.push(yaml.dump(service, yamlOptions)); yamlContents.push(yaml.dump(deployment, yamlOptions)); yamlContents.push(yaml.dump(autoscaler, yamlOptions)); - +if (pvcSize) { + yamlContents.push(yaml.dump(pvc, yamlOptions)); +} const allYaml = yamlContents.join("\n---\n"); log(`allYaml: ${allYaml}`);