generated from quarkiverse/quarkiverse-template
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: make things "compile" with independent-config JOSDK branch
Signed-off-by: Chris Laprun <[email protected]>
- Loading branch information
Showing
2 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...main/java/io/quarkiverse/operatorsdk/runtime/InformerConfigurationObjectSubstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.quarkiverse.operatorsdk.runtime; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.config.informer.InformerConfiguration; | ||
import io.quarkus.runtime.ObjectSubstitution; | ||
|
||
@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
public class InformerConfigurationObjectSubstitution | ||
implements ObjectSubstitution<InformerConfiguration, InformerConfigurationProxy> { | ||
private static final Logger log = Logger.getLogger(InformerConfigurationObjectSubstitution.class); | ||
|
||
@Override | ||
public InformerConfigurationProxy serialize(InformerConfiguration obj) { | ||
log.info("Serializing InformerConfiguration: " + obj); | ||
return _serialize(obj); | ||
} | ||
|
||
private static <R extends HasMetadata> InformerConfigurationProxy<R> _serialize(InformerConfiguration<R> obj) { | ||
return new InformerConfigurationProxy<>(obj.name(), obj.getLabelSelector(), obj.getResourceClass(), | ||
obj.getGroupVersionKind().orElse(null), | ||
new InformerConfigurationProxy.PrimaryToSecondaryMapperProxy<>(obj.getPrimaryToSecondaryMapper()), | ||
new InformerConfigurationProxy.SecondaryToPrimaryMapperProxy<>(obj.getSecondaryToPrimaryMapper()), | ||
obj.getNamespaces(), obj.followControllerNamespaceChanges(), | ||
obj.onAddFilter().orElse(null), obj.onUpdateFilter().orElse(null), obj.onDeleteFilter().orElse(null), | ||
obj.genericFilter().orElse(null), obj.getItemStore().orElse(null), obj.getInformerListLimit().orElse(null)); | ||
} | ||
|
||
@Override | ||
public InformerConfiguration deserialize(InformerConfigurationProxy obj) { | ||
log.info("Deserializing InformerConfiguration: " + obj); | ||
return obj; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
.../runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/InformerConfigurationProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.quarkiverse.operatorsdk.runtime; | ||
|
||
import java.util.Set; | ||
|
||
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.fabric8.kubernetes.client.informers.cache.ItemStore; | ||
import io.javaoperatorsdk.operator.api.config.informer.InformerConfiguration; | ||
import io.javaoperatorsdk.operator.processing.GroupVersionKind; | ||
import io.javaoperatorsdk.operator.processing.event.ResourceID; | ||
import io.javaoperatorsdk.operator.processing.event.source.PrimaryToSecondaryMapper; | ||
import io.javaoperatorsdk.operator.processing.event.source.SecondaryToPrimaryMapper; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.GenericFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.OnAddFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.OnDeleteFilter; | ||
import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter; | ||
|
||
public class InformerConfigurationProxy<R extends HasMetadata> extends InformerConfiguration.DefaultInformerConfiguration<R> { | ||
public InformerConfigurationProxy(String name, String labelSelector, Class<R> resourceClass, | ||
GroupVersionKind groupVersionKind, PrimaryToSecondaryMapper<?> primaryToSecondaryMapper, | ||
SecondaryToPrimaryMapper<R> secondaryToPrimaryMapper, Set<String> namespaces, | ||
boolean followControllerNamespaceChanges, OnAddFilter<? super R> onAddFilter, | ||
OnUpdateFilter<? super R> onUpdateFilter, OnDeleteFilter<? super R> onDeleteFilter, | ||
GenericFilter<? super R> genericFilter, ItemStore<R> itemStore, Long informerListLimit) { | ||
super(name, labelSelector, resourceClass, groupVersionKind, | ||
primaryToSecondaryMapper, secondaryToPrimaryMapper, | ||
namespaces, followControllerNamespaceChanges, onAddFilter, onUpdateFilter, onDeleteFilter, genericFilter, | ||
itemStore, informerListLimit); | ||
} | ||
|
||
public OnAddFilter<? super R> getOnAddFilter() { | ||
return onAddFilter().orElse(null); | ||
} | ||
|
||
public OnDeleteFilter<? super R> getOnDeleteFilter() { | ||
return onDeleteFilter().orElse(null); | ||
} | ||
|
||
public OnUpdateFilter<? super R> getOnUpdateFilter() { | ||
return onUpdateFilter().orElse(null); | ||
} | ||
|
||
public GenericFilter<? super R> getGenericFilter() { | ||
return genericFilter().orElse(null); | ||
} | ||
|
||
public String getName() { | ||
return name(); | ||
} | ||
|
||
public boolean isFollowControllerNamespaceChanges() { | ||
return followControllerNamespaceChanges(); | ||
} | ||
|
||
public static class PrimaryToSecondaryMapperProxy<P extends HasMetadata> implements PrimaryToSecondaryMapper<P> { | ||
private final PrimaryToSecondaryMapper<P> mapper; | ||
|
||
public PrimaryToSecondaryMapperProxy(PrimaryToSecondaryMapper<P> mapper) { | ||
this.mapper = mapper; | ||
} | ||
|
||
public PrimaryToSecondaryMapper<P> getMapper() { | ||
return mapper; | ||
} | ||
|
||
@Override | ||
public Set<ResourceID> toSecondaryResourceIDs(P p) { | ||
return mapper.toSecondaryResourceIDs(p); | ||
} | ||
} | ||
|
||
public static class SecondaryToPrimaryMapperProxy<P extends HasMetadata> implements SecondaryToPrimaryMapper<P> { | ||
private final SecondaryToPrimaryMapper<P> mapper; | ||
|
||
public SecondaryToPrimaryMapperProxy(SecondaryToPrimaryMapper<P> mapper) { | ||
this.mapper = mapper; | ||
} | ||
|
||
public SecondaryToPrimaryMapper<P> getMapper() { | ||
return mapper; | ||
} | ||
|
||
@Override | ||
public Set<ResourceID> toPrimaryResourceIDs(P p) { | ||
return mapper.toPrimaryResourceIDs(p); | ||
} | ||
} | ||
} |