@Override
public void start(Future<Void> startPromise) throws Exception {
SchemaApi schemaApi = KubeSchemaApi.create(client, client.getNamespace(), true);
CachingSchemaProvider schemaProvider = new CachingSchemaProvider();
schemaApi.watchSchema(schemaProvider, options.getResyncInterval());
ensureRouteExists(client, options);
ensureCredentialsExist(client, options);
AddressSpaceApi addressSpaceApi = new ConfigMapAddressSpaceApi(client);
AuthApi authApi = new KubeAuthApi(client, client.getConfiguration().getOauthToken());
UserApi userApi = createUserApi(options);
ConsoleProxy consoleProxy = addressSpace -> {
Route route = client.routes().withName(options.getConsoleProxyRouteName()).get();
if (route == null) {
return null;
}
return String.format("https://%s/console/%s", route.getSpec().getHost(), addressSpace.getMetadata().getName());
};
vertx.deployVerticle(new HTTPServer(addressSpaceApi, schemaProvider, authApi, options.getCertDir(), options.getEnableRbac(), userApi, options.getListenPort(), consoleProxy),
result -> {
if (result.succeeded()) {
log.info("EnMasse Service Broker started");
startPromise.complete();
} else {
startPromise.fail(result.cause());
}
});
}