Last active
March 15, 2019 21:59
-
-
Save jbrisbin/8a04cacc5a4593edfb1750a9a1154823 to your computer and use it in GitHub Desktop.
Sketch of Fabric8 Quarkus extension pattern
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
@ApplicationScoped | |
@CustomResourceController(MyCustomResource.class) | |
public class MyCustomResourceController { | |
@Inject | |
NamespacedKubernetesClient client; | |
@Inject | |
CustomResourceDefinition crd; | |
@Inject | |
CustomResourceClient<MyCustomResource> myCustomResources; | |
@POST | |
@Path("/my/customresource") | |
public JsonNode getCurrentState() { | |
MyCustomResource r = myCustomResources.create(new MyCustomResourceBuilder() | |
.withName("world") | |
.build()); | |
return JsonNodeFactory.instance.objectNode().put("hello", r.getName()); | |
} | |
void reconcile(@Observes ResourceReconcileEvent<MyCustomResource> ev) { | |
ev.reconcile((prev, next) -> { | |
return next; | |
}); | |
} | |
void added(@Observes ResourceAddedEvent<MyCustomResource> added) { | |
added.source().getMetadata().getOwnerReferences(); | |
added.source().getMetadata().getCreationTimestamp(); | |
added.source().getName(); | |
} | |
void deleted(@Observes ResourceDeletedEvent<MyCustomResource> deleted) { | |
deleted.source().getMetadata().getDeletionTimestamp(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment