From 30aabdcc44568d15250b914751b93304287d34c3 Mon Sep 17 00:00:00 2001 From: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:24:03 +0100 Subject: [PATCH] Enhance PVC for filesystem storage Signed-off-by: carlosthe19916 <2582866+carlosthe19916@users.noreply.github.com> --- .gitignore | 2 +- .../java/io/github/project/openubl/operator/Constants.java | 2 ++ .../operator/cdrs/v2alpha1/UblhubFileStoragePVC.java | 7 ++++++- {jreleaser => src/jreleaser}/templates/article/release.md | 0 4 files changed, 9 insertions(+), 2 deletions(-) rename {jreleaser => src/jreleaser}/templates/article/release.md (100%) diff --git a/.gitignore b/.gitignore index 18d88e28..60f07e40 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ nb-configuration.xml !application/src/main/distribution/* application/workspace/* -jreleaser/templates/article/openapi.* +src/jreleaser/templates/article/openapi.* diff --git a/operator/src/main/java/io/github/project/openubl/operator/Constants.java b/operator/src/main/java/io/github/project/openubl/operator/Constants.java index 77d532a6..6a8001f6 100644 --- a/operator/src/main/java/io/github/project/openubl/operator/Constants.java +++ b/operator/src/main/java/io/github/project/openubl/operator/Constants.java @@ -61,6 +61,8 @@ public class Constants { public static final String CERTIFICATES_FOLDER = "/mnt/certificates"; public static final String STORAGE_FOLDER = "/mnt/ublhub-storage"; + public static final String STORAGE_MIN_SIZE = "100Mi"; + public static final UblhubSpec.XBuilderSpec defaultXBuilderConfig = UblhubSpec.XBuilderSpec.builder() .moneda("PEN") .igvTasa("0.18") diff --git a/operator/src/main/java/io/github/project/openubl/operator/cdrs/v2alpha1/UblhubFileStoragePVC.java b/operator/src/main/java/io/github/project/openubl/operator/cdrs/v2alpha1/UblhubFileStoragePVC.java index f03bca6e..3b3bae96 100644 --- a/operator/src/main/java/io/github/project/openubl/operator/cdrs/v2alpha1/UblhubFileStoragePVC.java +++ b/operator/src/main/java/io/github/project/openubl/operator/cdrs/v2alpha1/UblhubFileStoragePVC.java @@ -57,10 +57,15 @@ private PersistentVolumeClaim newPersistentVolumeClaim(Ublhub cr, Context contex } private PersistentVolumeClaimSpec getPersistentVolumeClaimSpec(Ublhub cr) { + boolean isFileSystemStorage = cr.getSpec().getStorageSpec() != null && cr.getSpec().getStorageSpec().getType().equals(UblhubSpec.StorageSpec.Type.filesystem); + Quantity storageSize = isFileSystemStorage ? + new Quantity(cr.getSpec().getStorageSpec().getFilesystemSpec().getSize()) : + new Quantity(Constants.STORAGE_MIN_SIZE); + return new PersistentVolumeClaimSpecBuilder() .withAccessModes("ReadWriteOnce") .withResources(new ResourceRequirementsBuilder() - .addToRequests("storage", new Quantity(cr.getSpec().getStorageSpec().getFilesystemSpec().getSize())) + .addToRequests("storage", storageSize) .build() ) .build(); diff --git a/jreleaser/templates/article/release.md b/src/jreleaser/templates/article/release.md similarity index 100% rename from jreleaser/templates/article/release.md rename to src/jreleaser/templates/article/release.md