Skip to content

Commit

Permalink
feat: rename server persistent volume claim
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 committed Nov 12, 2024
1 parent f6f7805 commit 0b5a5e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.javaoperatorsdk.operator.processing.event.ResourceID;
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
import org.trustify.operator.cdrs.v2alpha1.Trustify;
import org.trustify.operator.controllers.TrustifyReconciler;

import java.util.Optional;

Expand All @@ -14,7 +15,7 @@ public class DBPersistentVolumeClaimDiscriminator implements ResourceDiscriminat
public Optional<PersistentVolumeClaim> distinguish(Class<PersistentVolumeClaim> resource, Trustify cr, Context<Trustify> context) {
String persistentVolumeClaimName = DBPersistentVolumeClaim.getPersistentVolumeClaimName(cr);
ResourceID resourceID = new ResourceID(persistentVolumeClaimName, cr.getMetadata().getNamespace());
var informerEventSource = (InformerEventSource<PersistentVolumeClaim, Trustify>) context.eventSourceRetriever().getResourceEventSourceFor(PersistentVolumeClaim.class);
var informerEventSource = (InformerEventSource<PersistentVolumeClaim, Trustify>) context.eventSourceRetriever().getResourceEventSourceFor(PersistentVolumeClaim.class, TrustifyReconciler.PVC_EVENT_SOURCE);
return informerEventSource.get(resourceID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ private DeploymentSpec getDeploymentSpec(Trustify cr, Context<Trustify> context,
.withCommand(
"/usr/local/bin/trustd",
"api",
"--sample-data",
"--infrastructure-enabled",
"--infrastructure-bind=0.0.0.0:" + Constants.HTTP_INFRAESTRUCTURE_PORT
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.javaoperatorsdk.operator.processing.event.ResourceID;
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
import org.trustify.operator.cdrs.v2alpha1.Trustify;
import org.trustify.operator.controllers.TrustifyReconciler;

import java.util.Optional;

Expand All @@ -14,7 +15,7 @@ public class ServerStoragePersistentVolumeClaimDiscriminator implements Resource
public Optional<PersistentVolumeClaim> distinguish(Class<PersistentVolumeClaim> resource, Trustify cr, Context<Trustify> context) {
String persistentVolumeClaimName = ServerStoragePersistentVolumeClaim.getPersistentVolumeClaimName(cr);
ResourceID resourceID = new ResourceID(persistentVolumeClaimName, cr.getMetadata().getNamespace());
var informerEventSource = (InformerEventSource<PersistentVolumeClaim, Trustify>) context.eventSourceRetriever().getResourceEventSourceFor(PersistentVolumeClaim.class);
var informerEventSource = (InformerEventSource<PersistentVolumeClaim, Trustify>) context.eventSourceRetriever().getResourceEventSourceFor(PersistentVolumeClaim.class, TrustifyReconciler.PVC_EVENT_SOURCE);
return informerEventSource.get(resourceID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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.server.ServerStoragePersistentVolumeClaim;

import java.time.Duration;
import java.util.Map;
Expand Down Expand Up @@ -49,6 +50,10 @@
activationCondition = DBServiceActivationCondition.class
),

@Dependent(
name = "server-pvc",
type = ServerStoragePersistentVolumeClaim.class
),
@Dependent(
name = "server-deployment",
type = ServerDeployment.class,
Expand All @@ -75,6 +80,7 @@ public class TrustifyReconciler implements Reconciler<Trustify>, ContextInitiali

private static final Logger logger = Logger.getLogger(TrustifyReconciler.class);

public static final String PVC_EVENT_SOURCE = "pcvSource";
public static final String DEPLOYMENT_EVENT_SOURCE = "deploymentSource";
public static final String SERVICE_EVENT_SOURCE = "serviceSource";

Expand Down Expand Up @@ -122,13 +128,16 @@ public UpdateControl<Trustify> reconcile(Trustify cr, Context context) {

@Override
public Map<String, EventSource> prepareEventSources(EventSourceContext<Trustify> context) {
var pcvInformerConfiguration = InformerConfiguration.from(PersistentVolumeClaim.class, context).build();
var deploymentInformerConfiguration = InformerConfiguration.from(Deployment.class, context).build();
var serviceInformerConfiguration = InformerConfiguration.from(Service.class, context).build();

var pcvInformerEventSource = new InformerEventSource<>(pcvInformerConfiguration, context);
var deploymentInformerEventSource = new InformerEventSource<>(deploymentInformerConfiguration, context);
var serviceInformerEventSource = new InformerEventSource<>(serviceInformerConfiguration, context);

return Map.of(
PVC_EVENT_SOURCE, pcvInformerEventSource,
DEPLOYMENT_EVENT_SOURCE, deploymentInformerEventSource,
SERVICE_EVENT_SOURCE, serviceInformerEventSource
);
Expand Down

0 comments on commit 0b5a5e7

Please sign in to comment.