From 766a0563a70926fe5df70436daaa4e3386bb70ec Mon Sep 17 00:00:00 2001 From: Carlos Feria Date: Thu, 1 Aug 2024 11:42:44 -0500 Subject: [PATCH] feat: add customizable server image through spec (#12) --- .../org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java | 8 ++++++++ .../operator/cdrs/v2alpha1/server/ServerDeployment.java | 5 +++-- src/main/resources/application.properties | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java index 3f79023..933af05 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java @@ -7,6 +7,12 @@ import java.util.List; public record TrustifySpec( + @JsonPropertyDescription("Custom Trustify Server image to be used. For internal use only") + String serverImage, + + @JsonPropertyDescription("Custom Image Pull Policy for images managed by the Operator") + String imagePullPolicy, + @JsonPropertyDescription("Secret(s) that might be used when pulling an image from a private container image registry or repository.") List imagePullSecrets, @@ -33,6 +39,8 @@ public TrustifySpec() { null, null, null, + null, + null, null ); } diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java index fd7ee9d..448a8e3 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -97,8 +98,8 @@ private DeploymentSpec getDeploymentSpec(Trustify cr, Context context, .getMandatory(Constants.CONTEXT_LABELS_KEY, Map.class); Map selectorLabels = Constants.SERVER_SELECTOR_LABELS; - String image = config.serverImage(); - String imagePullPolicy = config.imagePullPolicy(); + String image = Optional.ofNullable(cr.getSpec().serverImage()).orElse(config.serverImage()); + String imagePullPolicy = Optional.ofNullable(cr.getSpec().imagePullPolicy()).orElse(config.imagePullPolicy()); List envVars = distConfigurator.getAllEnvVars(); List volumes = distConfigurator.getAllVolumes(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 5b672a5..e739e58 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ quarkus.container-image.tag=v${quarkus.application.version} quarkus.operator-sdk.crd.apply=true # Operator config -related.image.server=${RELATED_IMAGE_SERVER:ghcr.io/trustification/trustd:0.1.0-alpha.11} +related.image.server=${RELATED_IMAGE_SERVER:ghcr.io/trustification/trustd:0.1.0-alpha.12} related.image.db=quay.io/sclorg/postgresql-15-c9s:latest related.image.pull-policy=Always