use of io.fabric8.kubernetes.client.dsl.Namespaceable in project watchdog by isdream.
the class KubernetesListener method start.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void start(Object client, Configure config) throws Exception {
// System.out.println(config.getApiVersion());
if (ObjectUtils.isNull(client) && ObjectUtils.isNull(config)) {
throw new Exception("Invalid paremeters");
}
// it may throw Exception if wrong PROPERTY_KIND values
Object model = getModelParamtersGenerator().getKindModel(client, config.getKind());
if (model instanceof Namespaceable || model instanceof AnyNamespaceable) {
String namespace = config.getProperties().getOrDefault(PROPERTY_NAMESPACE, ALL_NAMESPACE);
if (ALL_NAMESPACE.equals(namespace)) {
model = ((AnyNamespaceable) model).inAnyNamespace();
} else {
model = ((Namespaceable) model).inNamespace(namespace);
}
}
List<String> handlers = config.getHandlers();
if (handlers.isEmpty()) {
throw new Exception("No handlers");
}
Handler handler = (Handler) Class.forName(handlers.remove(0)).newInstance();
Handler thisHandler = handler;
for (String name : handlers) {
Handler nextHandler = (Handler) Class.forName(name).newInstance();
thisHandler.setNextHandler(nextHandler);
thisHandler = nextHandler;
}
System.out.println(model.getClass());
((Watchable) model).watch(new KubernetesWatcher(handler));
}
Aggregations