Skip to content

Commit

Permalink
fix: adapt to EventSource changes
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed May 3, 2024
1 parent 09b69ac commit 661f591
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ControllerInfo(Controller<P> controller) {
.map(spec -> new DependentInfo(spec))
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
eventSources = controller.getEventSourceManager().getNamedEventSourcesStream()
eventSources = controller.getEventSourceManager().getEventSourcesStream()
.map(EventSourceInfo::new)
.sorted()
.collect(Collectors.toCollection(LinkedHashSet::new));
Expand Down Expand Up @@ -66,7 +66,7 @@ public Set<DependentInfo> getDependents() {

@SuppressWarnings("unused")
public List<P> getKnownResources() {
return controller.getEventSourceManager().getControllerResourceEventSource().list()
return controller.getEventSourceManager().getControllerEventSource().list()
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package io.quarkiverse.operatorsdk.runtime.devconsole;

import io.javaoperatorsdk.operator.processing.event.EventSourceMetadata;
import java.util.Optional;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.processing.event.source.Configurable;
import io.javaoperatorsdk.operator.processing.event.source.EventSource;

public class EventSourceInfo implements Comparable<EventSourceInfo> {
private final EventSourceMetadata metadata;
private final EventSource<?, ? extends HasMetadata> metadata;

public EventSourceInfo(EventSourceMetadata metadata) {
public EventSourceInfo(EventSource<?, ? extends HasMetadata> metadata) {
this.metadata = metadata;
}

Expand All @@ -15,11 +19,16 @@ public String getName() {

@SuppressWarnings("unused")
public String getResourceClass() {
return metadata.resourceType().map(Class::getName).orElse(null);
return metadata.resourceType().getName();
}

public String getType() {
return metadata.type().getName();
return metadata.getClass().getName();
}

public Optional<?> getConfiguration() {
return metadata instanceof Configurable<?> ? Optional.of(((Configurable<?>) metadata).configuration())
: Optional.empty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.sql.Connection;
import java.sql.SQLException;
import java.time.Duration;
import java.util.Base64;
import java.util.Collections;
import java.util.Optional;
Expand All @@ -19,7 +20,6 @@
import io.fabric8.kubernetes.api.model.Secret;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.api.reconciler.dependent.Deleter;
import io.javaoperatorsdk.operator.api.reconciler.dependent.EventSourceProvider;
import io.javaoperatorsdk.operator.api.reconciler.dependent.managed.DependentResourceConfigurator;
import io.javaoperatorsdk.operator.processing.dependent.Creator;
import io.javaoperatorsdk.operator.processing.dependent.external.PerResourcePollingDependentResource;
Expand All @@ -30,7 +30,7 @@
@ApplicationScoped
public class SchemaDependentResource
extends PerResourcePollingDependentResource<Schema, MySQLSchema>
implements EventSourceProvider<MySQLSchema>,
implements
DependentResourceConfigurator<ResourcePollerConfig>,
Creator<Schema, MySQLSchema>,
Deleter<MySQLSchema> {
Expand All @@ -47,13 +47,13 @@ public SchemaDependentResource() {
@Override
public void configureWith(ResourcePollerConfig config) {
if (config != null) {
setPollingPeriod(config.getPollPeriod());
setPollingPeriod(Duration.ofSeconds(config.getPollPeriod()));
}
}

@Override
public Optional<ResourcePollerConfig> configuration() {
return Optional.of(new ResourcePollerConfig((int) getPollingPeriod()));
return Optional.of(new ResourcePollerConfig((int) getPollingPeriod().toSeconds()));
}

@Override
Expand Down

0 comments on commit 661f591

Please sign in to comment.