diff --git a/src/main/java/org/trustify/operator/Config.java b/src/main/java/org/trustify/operator/Config.java index dee8172..850b53f 100644 --- a/src/main/java/org/trustify/operator/Config.java +++ b/src/main/java/org/trustify/operator/Config.java @@ -6,8 +6,8 @@ @ConfigMapping(prefix = "related.image") public interface Config { - @WithName("api") - String apiImage(); + @WithName("server") + String serverImage(); @WithName("db") String dbImage(); diff --git a/src/main/java/org/trustify/operator/Constants.java b/src/main/java/org/trustify/operator/Constants.java index 337ab34..ca5b217 100644 --- a/src/main/java/org/trustify/operator/Constants.java +++ b/src/main/java/org/trustify/operator/Constants.java @@ -10,15 +10,15 @@ public class Constants { // public static final String TRUSTI_NAME = "trustify"; - public static final String TRUSTI_API_NAME = "trustify-api"; + public static final String TRUSTI_SERVER_NAME = "trustify-server"; public static final String TRUSTI_DB_NAME = "trustify-db"; // public static final Map DB_SELECTOR_LABELS = Map.of( "trustify-operator/group", "db" ); - public static final Map API_SELECTOR_LABELS = Map.of( - "trustify-operator/group", "api" + public static final Map SERVER_SELECTOR_LABELS = Map.of( + "trustify-operator/group", "server" ); // @@ -32,12 +32,12 @@ public class Constants { public static final String DB_DEPLOYMENT_SUFFIX = "-" + TRUSTI_DB_NAME + "-deployment"; public static final String DB_SERVICE_SUFFIX = "-" + TRUSTI_DB_NAME + "-service"; - public static final String API_DEPLOYMENT_SUFFIX = "-" + TRUSTI_API_NAME + "-deployment"; - public static final String API_SERVICE_SUFFIX = "-" + TRUSTI_API_NAME + "-service"; + public static final String SERVER_DEPLOYMENT_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-deployment"; + public static final String SERVER_SERVICE_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-service"; - public static final String INGRESS_SUFFIX = "-" + TRUSTI_API_NAME + "-ingress"; - public static final String INGRESS_SECURE_SUFFIX = "-" + TRUSTI_API_NAME + "-secure-ingress"; + public static final String INGRESS_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-ingress"; + public static final String INGRESS_SECURE_SUFFIX = "-" + TRUSTI_SERVER_NAME + "-secure-ingress"; // public static final String DB_SECRET_USERNAME = "username"; 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 c50fbd0..3f79023 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifySpec.java @@ -22,9 +22,9 @@ public record TrustifySpec( @JsonPropertyDescription("In this section you can configure features related to HTTP and HTTPS") HttpSpec httpSpec, - @JsonProperty("apiResourceLimits") - @JsonPropertyDescription("In this section you can configure resource limits settings for the API.") - ResourcesLimitSpec apiResourceLimitSpec + @JsonProperty("serverResourceLimits") + @JsonPropertyDescription("In this section you can configure resource limits settings for the Server.") + ResourcesLimitSpec serverResourceLimitSpec ) { public TrustifySpec() { diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatus.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatus.java index 9436c7c..ad7752d 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatus.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatus.java @@ -34,7 +34,7 @@ public void setCondition(TrustifyStatusCondition condition) { @JsonIgnore public boolean isAvailable() { return this.conditions.stream() - .anyMatch(item -> item.getType().equals(TrustifyStatusCondition.Successful) && Objects.equals(item.getStatus(), true)); + .anyMatch(item -> item.getType().equals(TrustifyStatusCondition.SUCCESSFUL) && Objects.equals(item.getStatus(), true)); } @Override diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatusCondition.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatusCondition.java index d457495..b6f4899 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatusCondition.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/TrustifyStatusCondition.java @@ -7,7 +7,7 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class TrustifyStatusCondition { - public static final String Successful = "Successful"; + public static final String SUCCESSFUL = "Successful"; public static final String PROCESSING = "Processing"; public static final String DEGRADED = "Degraded"; diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeployment.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java similarity index 93% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeployment.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java index 6304066..fd7ee9d 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeployment.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeployment.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.*; import io.fabric8.kubernetes.api.model.apps.*; @@ -23,17 +23,17 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -@KubernetesDependent(labelSelector = ApiDeployment.LABEL_SELECTOR, resourceDiscriminator = ApiDeploymentDiscriminator.class) +@KubernetesDependent(labelSelector = ServerDeployment.LABEL_SELECTOR, resourceDiscriminator = ServerDeploymentDiscriminator.class) @ApplicationScoped -public class ApiDeployment extends CRUDKubernetesDependentResource +public class ServerDeployment extends CRUDKubernetesDependentResource implements Matcher, Condition { - public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=api"; + public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server"; @Inject Config config; - public ApiDeployment() { + public ServerDeployment() { super(Deployment.class); } @@ -58,7 +58,7 @@ public Result match(Deployment actual, Trustify cr, Context dependentResource, Trustify primary, Context context) { - return context.getSecondaryResource(Deployment.class, new ApiDeploymentDiscriminator()) + return context.getSecondaryResource(Deployment.class, new ServerDeploymentDiscriminator()) .map(deployment -> { final var status = deployment.getStatus(); if (status != null) { @@ -80,7 +80,7 @@ private Deployment newDeployment(Trustify cr, Context context, Trustif .withName(getDeploymentName(cr)) .withNamespace(cr.getMetadata().getNamespace()) .withLabels(contextLabels) - .addToLabels("component", "api") + .addToLabels("component", "server") .withAnnotations(Map.of("app.openshift.io/connects-to", """ [{"apiVersion": "apps/v1", "kind":"Deployment", "name": "%s"}] """.formatted(DBDeployment.getDeploymentName(cr)) @@ -96,15 +96,15 @@ private DeploymentSpec getDeploymentSpec(Trustify cr, Context context, final var contextLabels = (Map) context.managedDependentResourceContext() .getMandatory(Constants.CONTEXT_LABELS_KEY, Map.class); - Map selectorLabels = Constants.API_SELECTOR_LABELS; - String image = config.apiImage(); + Map selectorLabels = Constants.SERVER_SELECTOR_LABELS; + String image = config.serverImage(); String imagePullPolicy = config.imagePullPolicy(); List envVars = distConfigurator.getAllEnvVars(); List volumes = distConfigurator.getAllVolumes(); List volumeMounts = distConfigurator.getAllVolumeMounts(); - TrustifySpec.ResourcesLimitSpec resourcesLimitSpec = CRDUtils.getValueFromSubSpec(cr.getSpec(), TrustifySpec::apiResourceLimitSpec) + TrustifySpec.ResourcesLimitSpec resourcesLimitSpec = CRDUtils.getValueFromSubSpec(cr.getSpec(), TrustifySpec::serverResourceLimitSpec) .orElse(null); return new DeploymentSpecBuilder() @@ -130,11 +130,11 @@ private DeploymentSpec getDeploymentSpec(Trustify cr, Context context, .withImagePullSecrets(cr.getSpec().imagePullSecrets()) // .withServiceAccountName(Constants.TRUSTI_NAME) .withContainers(new ContainerBuilder() - .withName(Constants.TRUSTI_API_NAME) + .withName(Constants.TRUSTI_SERVER_NAME) .withImage(image) .withImagePullPolicy(imagePullPolicy) .withEnv(envVars) - .withCommand("/usr/local/bin/trustd", "api", "--devmode") + .withCommand("/usr/local/bin/trustd", "server", "--devmode") .withPorts( new ContainerPortBuilder() .withName("http") @@ -212,6 +212,6 @@ private DeploymentSpec getDeploymentSpec(Trustify cr, Context context, } public static String getDeploymentName(Trustify cr) { - return cr.getMetadata().getName() + Constants.API_DEPLOYMENT_SUFFIX; + return cr.getMetadata().getName() + Constants.SERVER_DEPLOYMENT_SUFFIX; } } diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeploymentDiscriminator.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeploymentDiscriminator.java similarity index 79% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeploymentDiscriminator.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeploymentDiscriminator.java index a26bac2..7c84012 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiDeploymentDiscriminator.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerDeploymentDiscriminator.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.apps.Deployment; import io.javaoperatorsdk.operator.api.reconciler.Context; @@ -9,10 +9,10 @@ import java.util.Optional; -public class ApiDeploymentDiscriminator implements ResourceDiscriminator { +public class ServerDeploymentDiscriminator implements ResourceDiscriminator { @Override public Optional distinguish(Class resource, Trustify cr, Context context) { - String deploymentName = ApiDeployment.getDeploymentName(cr); + String deploymentName = ServerDeployment.getDeploymentName(cr); ResourceID resourceID = new ResourceID(deploymentName, cr.getMetadata().getNamespace()); var informerEventSource = (InformerEventSource) context.eventSourceRetriever().getResourceEventSourceFor(Deployment.class); return informerEventSource.get(resourceID); diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngress.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngress.java similarity index 86% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngress.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngress.java index 69cd9f5..228eb6e 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngress.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngress.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.fabric8.kubernetes.api.model.networking.v1.IngressTLS; @@ -13,11 +13,11 @@ import java.util.Map; -@KubernetesDependent(labelSelector = ApiIngress.LABEL_SELECTOR, resourceDiscriminator = ApiIngressDiscriminator.class) +@KubernetesDependent(labelSelector = ServerIngress.LABEL_SELECTOR, resourceDiscriminator = ServerIngressDiscriminator.class) @ApplicationScoped -public class ApiIngress extends ApiIngressBase { +public class ServerIngress extends ServerIngressBase { - public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=api,component-variant=http"; + public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server,component-variant=http"; @Override @SuppressWarnings("unchecked") @@ -27,7 +27,7 @@ protected Ingress desired(Trustify cr, Context context) { context, getIngressName(cr), Map.of( - "component", "api", + "component", "server", "component-variant", "http" ), Map.of( @@ -38,7 +38,7 @@ protected Ingress desired(Trustify cr, Context context) { @Override public boolean isMet(DependentResource dependentResource, Trustify cr, Context context) { - return context.getSecondaryResource(Ingress.class, new ApiIngressDiscriminator()) + return context.getSecondaryResource(Ingress.class, new ServerIngressDiscriminator()) .map(in -> { final var status = in.getStatus(); if (status != null) { diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressBase.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressBase.java similarity index 92% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressBase.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressBase.java index b1987c4..4f67f50 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressBase.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressBase.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.GenericKubernetesResource; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; @@ -21,12 +21,12 @@ import java.util.Map; import java.util.Optional; -public abstract class ApiIngressBase extends CRUDKubernetesDependentResource implements Condition { +public abstract class ServerIngressBase extends CRUDKubernetesDependentResource implements Condition { @Inject KubernetesClient k8sClient; - public ApiIngressBase() { + public ServerIngressBase() { super(Ingress.class); } @@ -38,7 +38,7 @@ protected Ingress newIngress(Trustify cr, Context context, String ingr final var labels = (Map) context.managedDependentResourceContext() .getMandatory(Constants.CONTEXT_LABELS_KEY, Map.class); - var port = ApiService.getServicePort(cr); + var port = ServerService.getServicePort(cr); String hostname = getHostname(cr); IngressTLS ingressTLS = getIngressTLS(cr); @@ -62,7 +62,7 @@ protected Ingress newIngress(Trustify cr, Context context, String ingr .withPathType("Prefix") .withNewBackend() .withNewService() - .withName(ApiService.getServiceName(cr)) + .withName(ServerService.getServiceName(cr)) .withNewPort() .withNumber(port) .endPort() diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressDiscriminator.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressDiscriminator.java similarity index 80% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressDiscriminator.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressDiscriminator.java index b640eb5..326b8ac 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressDiscriminator.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressDiscriminator.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.javaoperatorsdk.operator.api.reconciler.Context; @@ -9,10 +9,10 @@ import java.util.Optional; -public class ApiIngressDiscriminator implements ResourceDiscriminator { +public class ServerIngressDiscriminator implements ResourceDiscriminator { @Override public Optional distinguish(Class resource, Trustify cr, Context context) { - String ingressName = ApiIngress.getIngressName(cr); + String ingressName = ServerIngress.getIngressName(cr); ResourceID resourceID = new ResourceID(ingressName, cr.getMetadata().getNamespace()); var informerEventSource = (InformerEventSource) context.eventSourceRetriever().getResourceEventSourceFor(Ingress.class); return informerEventSource.get(resourceID); diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecure.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecure.java similarity index 87% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecure.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecure.java index d7c682c..a882ff5 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecure.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecure.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.fabric8.kubernetes.api.model.networking.v1.IngressTLS; @@ -15,11 +15,11 @@ import java.util.Collections; import java.util.Map; -@KubernetesDependent(labelSelector = ApiIngressSecure.LABEL_SELECTOR, resourceDiscriminator = ApiIngressSecureDiscriminator.class) +@KubernetesDependent(labelSelector = ServerIngressSecure.LABEL_SELECTOR, resourceDiscriminator = ServerIngressSecureDiscriminator.class) @ApplicationScoped -public class ApiIngressSecure extends ApiIngressBase { +public class ServerIngressSecure extends ServerIngressBase { - public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=api,component-variant=https"; + public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server,component-variant=https"; @Override @SuppressWarnings("unchecked") @@ -29,7 +29,7 @@ protected Ingress desired(Trustify cr, Context context) { context, getIngressName(cr), Map.of( - "component", "api", + "component", "server", "component-variant", "https" ), Collections.emptyMap() @@ -38,7 +38,7 @@ protected Ingress desired(Trustify cr, Context context) { @Override public boolean isMet(DependentResource dependentResource, Trustify primary, Context context) { - return context.getSecondaryResource(Ingress.class, new ApiIngressSecureDiscriminator()) + return context.getSecondaryResource(Ingress.class, new ServerIngressSecureDiscriminator()) .map(in -> { final var status = in.getStatus(); if (status != null) { diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecureDiscriminator.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecureDiscriminator.java similarity index 79% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecureDiscriminator.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecureDiscriminator.java index 454f455..04ede41 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiIngressSecureDiscriminator.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerIngressSecureDiscriminator.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.networking.v1.Ingress; import io.javaoperatorsdk.operator.api.reconciler.Context; @@ -9,10 +9,10 @@ import java.util.Optional; -public class ApiIngressSecureDiscriminator implements ResourceDiscriminator { +public class ServerIngressSecureDiscriminator implements ResourceDiscriminator { @Override public Optional distinguish(Class resource, Trustify cr, Context context) { - String ingressName = ApiIngressSecure.getIngressName(cr); + String ingressName = ServerIngressSecure.getIngressName(cr); ResourceID resourceID = new ResourceID(ingressName, cr.getMetadata().getNamespace()); var informerEventSource = (InformerEventSource) context.eventSourceRetriever().getResourceEventSourceFor(Ingress.class); return informerEventSource.get(resourceID); diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiService.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerService.java similarity index 81% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiService.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerService.java index c206da7..2b9937b 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiService.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerService.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.Service; import io.fabric8.kubernetes.api.model.ServiceBuilder; @@ -15,13 +15,13 @@ import java.util.Map; -@KubernetesDependent(labelSelector = ApiService.LABEL_SELECTOR, resourceDiscriminator = ApiServiceDiscriminator.class) +@KubernetesDependent(labelSelector = ServerService.LABEL_SELECTOR, resourceDiscriminator = ServerServiceDiscriminator.class) @ApplicationScoped -public class ApiService extends CRUDKubernetesDependentResource { +public class ServerService extends CRUDKubernetesDependentResource { - public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=api"; + public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server"; - public ApiService() { + public ServerService() { super(Service.class); } @@ -40,7 +40,7 @@ private Service newService(Trustify cr, Context context) { .withName(getServiceName(cr)) .withNamespace(cr.getMetadata().getNamespace()) .withLabels(labels) - .addToLabels("component", "api") + .addToLabels("component", "server") .withOwnerReferences(CRDUtils.getOwnerReference(cr)) .endMetadata() .withSpec(getServiceSpec(cr)) @@ -53,7 +53,7 @@ private ServiceSpec getServiceSpec(Trustify cr) { .withPort(getServicePort(cr)) .withProtocol(Constants.SERVICE_PROTOCOL) .endPort() - .withSelector(Constants.API_SELECTOR_LABELS) + .withSelector(Constants.SERVER_SELECTOR_LABELS) .withType("ClusterIP") .build(); } @@ -63,7 +63,7 @@ public static int getServicePort(Trustify cr) { } public static String getServiceName(Trustify cr) { - return cr.getMetadata().getName() + Constants.API_SERVICE_SUFFIX; + return cr.getMetadata().getName() + Constants.SERVER_SERVICE_SUFFIX; } public static boolean isTlsConfigured(Trustify cr) { diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiServiceDiscriminator.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerServiceDiscriminator.java similarity index 80% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiServiceDiscriminator.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerServiceDiscriminator.java index c131446..97e66c0 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiServiceDiscriminator.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerServiceDiscriminator.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.Service; import io.javaoperatorsdk.operator.api.reconciler.Context; @@ -9,10 +9,10 @@ import java.util.Optional; -public class ApiServiceDiscriminator implements ResourceDiscriminator { +public class ServerServiceDiscriminator implements ResourceDiscriminator { @Override public Optional distinguish(Class resource, Trustify cr, Context context) { - String serviceName = ApiService.getServiceName(cr); + String serviceName = ServerService.getServiceName(cr); ResourceID resourceID = new ResourceID(serviceName, cr.getMetadata().getNamespace()); var informerEventSource = (InformerEventSource) context.eventSourceRetriever().getResourceEventSourceFor(Service.class); return informerEventSource.get(resourceID); diff --git a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiStoragePersistentVolumeClaim.java b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerStoragePersistentVolumeClaim.java similarity index 84% rename from src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiStoragePersistentVolumeClaim.java rename to src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerStoragePersistentVolumeClaim.java index ad4fa71..f6f5975 100644 --- a/src/main/java/org/trustify/operator/cdrs/v2alpha1/api/ApiStoragePersistentVolumeClaim.java +++ b/src/main/java/org/trustify/operator/cdrs/v2alpha1/server/ServerStoragePersistentVolumeClaim.java @@ -1,4 +1,4 @@ -package org.trustify.operator.cdrs.v2alpha1.api; +package org.trustify.operator.cdrs.v2alpha1.server; import io.fabric8.kubernetes.api.model.*; import io.javaoperatorsdk.operator.api.reconciler.Context; @@ -12,14 +12,14 @@ import java.util.Map; -@KubernetesDependent(labelSelector = ApiStoragePersistentVolumeClaim.LABEL_SELECTOR, resourceDiscriminator = ApiStoragePersistentVolumeClaimDiscriminator.class) +@KubernetesDependent(labelSelector = ServerStoragePersistentVolumeClaim.LABEL_SELECTOR, resourceDiscriminator = ServerStoragePersistentVolumeClaimDiscriminator.class) @ApplicationScoped -public class ApiStoragePersistentVolumeClaim extends CRUDKubernetesDependentResource +public class ServerStoragePersistentVolumeClaim extends CRUDKubernetesDependentResource implements Creator { - public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=api"; + public static final String LABEL_SELECTOR = "app.kubernetes.io/managed-by=trustify-operator,component=server"; - public ApiStoragePersistentVolumeClaim() { + public ServerStoragePersistentVolumeClaim() { super(PersistentVolumeClaim.class); } @@ -40,7 +40,7 @@ private PersistentVolumeClaim newPersistentVolumeClaim(Trustify cr, Context { +public class ServerStoragePersistentVolumeClaimDiscriminator implements ResourceDiscriminator { @Override public Optional distinguish(Class resource, Trustify cr, Context context) { - String persistentVolumeClaimName = ApiStoragePersistentVolumeClaim.getPersistentVolumeClaimName(cr); + String persistentVolumeClaimName = ServerStoragePersistentVolumeClaim.getPersistentVolumeClaimName(cr); ResourceID resourceID = new ResourceID(persistentVolumeClaimName, cr.getMetadata().getNamespace()); var informerEventSource = (InformerEventSource) context.eventSourceRetriever().getResourceEventSourceFor(PersistentVolumeClaim.class); return informerEventSource.get(resourceID); diff --git a/src/main/java/org/trustify/operator/controllers/TrustifyDistConfigurator.java b/src/main/java/org/trustify/operator/controllers/TrustifyDistConfigurator.java index d20256c..83453ec 100644 --- a/src/main/java/org/trustify/operator/controllers/TrustifyDistConfigurator.java +++ b/src/main/java/org/trustify/operator/controllers/TrustifyDistConfigurator.java @@ -5,8 +5,8 @@ import org.trustify.operator.Constants; import org.trustify.operator.cdrs.v2alpha1.Trustify; import org.trustify.operator.cdrs.v2alpha1.TrustifySpec; -import org.trustify.operator.cdrs.v2alpha1.api.ApiService; -import org.trustify.operator.cdrs.v2alpha1.api.ApiStoragePersistentVolumeClaim; +import org.trustify.operator.cdrs.v2alpha1.server.ServerService; +import org.trustify.operator.cdrs.v2alpha1.server.ServerStoragePersistentVolumeClaim; import org.trustify.operator.cdrs.v2alpha1.db.DBSecret; import org.trustify.operator.cdrs.v2alpha1.db.DBService; @@ -68,7 +68,7 @@ private void configureTLS(OptionMapper optionMapper) { final String certFileOptionName = "HTTP_SERVER_TLS_CERTIFICATE_FILE"; final String keyFileOptionName = "HTTP_SERVER_TLS_KEY_FILE"; - if (!ApiService.isTlsConfigured(cr)) { + if (!ServerService.isTlsConfigured(cr)) { // for mapping and triggering warning in status if someone uses the fields directly optionMapper.mapOption(certFileOptionName); optionMapper.mapOption(keyFileOptionName); @@ -118,7 +118,7 @@ private void configureStorage() { var volume = new VolumeBuilder() .withName("trustify-pvol") .withPersistentVolumeClaim(new PersistentVolumeClaimVolumeSourceBuilder() - .withClaimName(ApiStoragePersistentVolumeClaim.getPersistentVolumeClaimName(cr)) + .withClaimName(ServerStoragePersistentVolumeClaim.getPersistentVolumeClaimName(cr)) .build() ) .build(); diff --git a/src/main/java/org/trustify/operator/controllers/TrustifyReconciler.java b/src/main/java/org/trustify/operator/controllers/TrustifyReconciler.java index 11082c8..b47d622 100644 --- a/src/main/java/org/trustify/operator/controllers/TrustifyReconciler.java +++ b/src/main/java/org/trustify/operator/controllers/TrustifyReconciler.java @@ -12,10 +12,10 @@ import org.jboss.logging.Logger; import org.trustify.operator.cdrs.v2alpha1.Trustify; import org.trustify.operator.cdrs.v2alpha1.TrustifyStatusCondition; -import org.trustify.operator.cdrs.v2alpha1.api.ApiDeployment; -import org.trustify.operator.cdrs.v2alpha1.api.ApiIngress; -import org.trustify.operator.cdrs.v2alpha1.api.ApiIngressSecure; -import org.trustify.operator.cdrs.v2alpha1.api.ApiService; +import org.trustify.operator.cdrs.v2alpha1.server.ServerDeployment; +import org.trustify.operator.cdrs.v2alpha1.server.ServerIngress; +import org.trustify.operator.cdrs.v2alpha1.server.ServerIngressSecure; +import org.trustify.operator.cdrs.v2alpha1.server.ServerService; import org.trustify.operator.cdrs.v2alpha1.db.DBDeployment; import org.trustify.operator.cdrs.v2alpha1.db.DBPersistentVolumeClaim; import org.trustify.operator.cdrs.v2alpha1.db.DBSecret; @@ -35,11 +35,11 @@ @Dependent(name = "db-deployment", type = DBDeployment.class, dependsOn = {"db-pvc", "db-secret"}, readyPostcondition = DBDeployment.class, useEventSourceWithName = TrustifyReconciler.DEPLOYMENT_EVENT_SOURCE), @Dependent(name = "db-service", type = DBService.class, dependsOn = {"db-deployment"}, useEventSourceWithName = TrustifyReconciler.SERVICE_EVENT_SOURCE), - @Dependent(name = "api-deployment", type = ApiDeployment.class, dependsOn = {"db-service"}, readyPostcondition = ApiDeployment.class, useEventSourceWithName = TrustifyReconciler.DEPLOYMENT_EVENT_SOURCE), - @Dependent(name = "api-service", type = ApiService.class, dependsOn = {"db-service"}, useEventSourceWithName = TrustifyReconciler.SERVICE_EVENT_SOURCE), + @Dependent(name = "server-deployment", type = ServerDeployment.class, dependsOn = {"db-service"}, readyPostcondition = ServerDeployment.class, useEventSourceWithName = TrustifyReconciler.DEPLOYMENT_EVENT_SOURCE), + @Dependent(name = "server-service", type = ServerService.class, dependsOn = {"db-service"}, useEventSourceWithName = TrustifyReconciler.SERVICE_EVENT_SOURCE), - @Dependent(name = "ingress", type = ApiIngress.class, dependsOn = {"db-service"}, readyPostcondition = ApiIngress.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE), - @Dependent(name = "ingress-secure", type = ApiIngressSecure.class, dependsOn = {"db-service"}, readyPostcondition = ApiIngressSecure.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE) + @Dependent(name = "ingress", type = ServerIngress.class, dependsOn = {"db-service"}, readyPostcondition = ServerIngress.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE), + @Dependent(name = "ingress-secure", type = ServerIngressSecure.class, dependsOn = {"db-service"}, readyPostcondition = ServerIngressSecure.class, useEventSourceWithName = TrustifyReconciler.INGRESS_EVENT_SOURCE) } ) public class TrustifyReconciler implements Reconciler, ContextInitializer, @@ -74,7 +74,7 @@ public UpdateControl reconcile(Trustify cr, Context context) { } TrustifyStatusCondition status = new TrustifyStatusCondition(); - status.setType(TrustifyStatusCondition.Successful); + status.setType(TrustifyStatusCondition.SUCCESSFUL); status.setStatus(true); cr.getStatus().setCondition(status); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c5b5756..5b672a5 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,15 +5,15 @@ quarkus.container-image.tag=v${quarkus.application.version} quarkus.operator-sdk.crd.apply=true # Operator config -related.image.api=ghcr.io/trustification/trustd:0.1.0-alpha.11 +related.image.server=${RELATED_IMAGE_SERVER:ghcr.io/trustification/trustd:0.1.0-alpha.11} related.image.db=quay.io/sclorg/postgresql-15-c9s:latest related.image.pull-policy=Always # https://quarkus.io/guides/deploying-to-kubernetes#environment-variables-from-keyvalue-pairs -quarkus.kubernetes.env.vars.related-image-trustify-api=${related.image.api} +quarkus.kubernetes.env.vars.related-image-trustify-server=${related.image.server} quarkus.kubernetes.env.vars.related-image-db=${related.image.db} quarkus.kubernetes.env.vars.related-image-importer=${related.image.importer} -quarkus.openshift.env.vars.related-image-trustify-api=${related.image.api} +quarkus.openshift.env.vars.related-image-trustify-server=${related.image.server} quarkus.openshift.env.vars.related-image-db=${related.image.db} quarkus.openshift.env.vars.related-image-importer=${related.image.importer} diff --git a/src/test/java/org/trustify/operator/controllers/TrustifyReconcilerTest.java b/src/test/java/org/trustify/operator/controllers/TrustifyReconcilerTest.java index be78352..254d61a 100644 --- a/src/test/java/org/trustify/operator/controllers/TrustifyReconcilerTest.java +++ b/src/test/java/org/trustify/operator/controllers/TrustifyReconcilerTest.java @@ -13,9 +13,9 @@ import org.junit.jupiter.api.*; import org.trustify.operator.Constants; import org.trustify.operator.cdrs.v2alpha1.*; -import org.trustify.operator.cdrs.v2alpha1.api.ApiDeployment; -import org.trustify.operator.cdrs.v2alpha1.api.ApiIngress; -import org.trustify.operator.cdrs.v2alpha1.api.ApiService; +import org.trustify.operator.cdrs.v2alpha1.server.ServerDeployment; +import org.trustify.operator.cdrs.v2alpha1.server.ServerIngress; +import org.trustify.operator.cdrs.v2alpha1.server.ServerService; import org.trustify.operator.cdrs.v2alpha1.db.DBDeployment; import org.trustify.operator.cdrs.v2alpha1.db.DBService; import org.trustify.operator.controllers.setup.K3sResource; @@ -32,8 +32,8 @@ public class TrustifyReconcilerTest { @ConfigProperty(name = "related.image.db") String dbImage; - @ConfigProperty(name = "related.image.api") - String apiImage; + @ConfigProperty(name = "related.image.server") + String serverImage; @Inject KubernetesClient client; @@ -123,43 +123,43 @@ public void reconcileShouldWork() throws InterruptedException { MatcherAssert.assertThat("DB service port not valid", dbPort, Matchers.is(5432)); - // Api Deployment - final var apiDeployment = client.apps() + // Server Deployment + final var serverDeployment = client.apps() .deployments() .inNamespace(metadata.getNamespace()) - .withName(ApiDeployment.getDeploymentName(app)) + .withName(ServerDeployment.getDeploymentName(app)) .get(); - final var webContainer = apiDeployment.getSpec() + final var webContainer = serverDeployment.getSpec() .getTemplate() .getSpec() .getContainers() .stream() .findFirst(); - MatcherAssert.assertThat("Api container not found", webContainer.isPresent(), Matchers.is(true)); - MatcherAssert.assertThat("Api container image not valid", webContainer.get().getImage(), Matchers.is(apiImage)); + MatcherAssert.assertThat("Server container not found", webContainer.isPresent(), Matchers.is(true)); + MatcherAssert.assertThat("Server container image not valid", webContainer.get().getImage(), Matchers.is(serverImage)); List webContainerPorts = webContainer.get().getPorts().stream() .map(ContainerPort::getContainerPort) .toList(); - Assertions.assertTrue(webContainerPorts.contains(8080), "Api container port 8080 not found"); + Assertions.assertTrue(webContainerPorts.contains(8080), "Server container port 8080 not found"); - Assertions.assertEquals(1, apiDeployment.getStatus().getReadyReplicas(), "Expected Api deployment number of replicas doesn't match"); + Assertions.assertEquals(1, serverDeployment.getStatus().getReadyReplicas(), "Expected Server deployment number of replicas doesn't match"); - // Api service - final var apiService = client.services() + // Server service + final var serverService = client.services() .inNamespace(metadata.getNamespace()) - .withName(ApiService.getServiceName(app)) + .withName(ServerService.getServiceName(app)) .get(); - final var apiServicePorts = apiService.getSpec() + final var serverServicePorts = serverService.getSpec() .getPorts() .stream() .map(ServicePort::getPort) .toList(); - Assertions.assertTrue(apiServicePorts.contains(8080), "Api service port not valid"); + Assertions.assertTrue(serverServicePorts.contains(8080), "Server service port not valid"); // Ingress final var ingress = client.network().v1().ingresses() .inNamespace(metadata.getNamespace()) - .withName(ApiIngress.getIngressName(app)) + .withName(ServerIngress.getIngressName(app)) .get(); final var rules = ingress.getSpec().getRules(); @@ -171,7 +171,7 @@ public void reconcileShouldWork() throws InterruptedException { final var path = paths.get(0); final var serviceBackend = path.getBackend().getService(); - MatcherAssert.assertThat(serviceBackend.getName(), Matchers.is(ApiService.getServiceName(app))); + MatcherAssert.assertThat(serviceBackend.getName(), Matchers.is(ServerService.getServiceName(app))); MatcherAssert.assertThat(serviceBackend.getPort().getNumber(), Matchers.is(8080)); }); }