@Test public void testWithUnknownMapWithOptional(TestContext tc) { Async async = tc.async(); store = new ConfigMapStore(vertx, config() .put("optional", true) .put("name", "my-unknown-map")); store.get().onComplete(ar -> { if (ar.failed()) { ar.cause().printStackTrace(); } tc.assertTrue(ar.succeeded()); tc.assertEquals(ar.result().toString(), "{}"); async.complete(); }); }
@Override public Future<Buffer> get() { Future<String> retrieveToken; if (token == null) { retrieveToken = getToken(); } else { retrieveToken = vertx.getOrCreateContext().succeededFuture(token); } return retrieveToken.flatMap(token -> { if (token.isEmpty()) { return Future.succeededFuture(Buffer.buffer("{}")); } String path = "/api/v1/namespaces/" + namespace; if (secret) { path += "/secrets/" + name; } else { path += "/configmaps/" + name; } return client.get(path) .putHeader("Authorization", "Bearer " + token) .send() .flatMap(response -> { if (response.statusCode() == 404) { return handle404(); } if (response.statusCode() == 403) { return handle403(); } if (response.statusCode() != 200) { return handleOtherErrors(response); } return handle200(response); }); }); }
ConfigMapStore implements ConfigStore { @Override public Future<Buffer> get() { Future<String> retrieveToken; if (token == null) { retrieveToken = getToken(); } else { retrieveToken = vertx.getOrCreateContext().succeededFuture(token); } return retrieveToken.flatMap(token -> { if (token.isEmpty()) { return Future.succeededFuture(Buffer.buffer("{}")); } String path = "/api/v1/namespaces/" + namespace; if (secret) { path += "/secrets/" + name; } else { path += "/configmaps/" + name; } return client.get(path) .putHeader("Authorization", "Bearer " + token) .send() .flatMap(response -> { if (response.statusCode() == 404) { return handle404(); } if (response.statusCode() == 403) { return handle403(); } if (response.statusCode() != 200) { return handleOtherErrors(response); } return handle200(response); }); }); } }
ConfigMapStore implements ConfigStore { @Override public Future<Buffer> get() { Future<String> retrieveToken; if (token == null) { retrieveToken = getToken(); } else { retrieveToken = vertx.getOrCreateContext().succeededFuture(token); } return retrieveToken.flatMap(token -> { if (token.isEmpty()) { return Future.succeededFuture(Buffer.buffer("{}")); } String path = "/api/v1/namespaces/" + namespace; if (secret) { path += "/secrets/" + name; } else { path += "/configmaps/" + name; } return client.get(path) .putHeader("Authorization", "Bearer " + token) .send() .flatMap(response -> { if (response.statusCode() == 404) { return handle404(); } if (response.statusCode() == 403) { return handle403(); } if (response.statusCode() != 200) { return handleOtherErrors(response); } return handle200(response); }); }); } ConfigMapStore(Vertx vertx, JsonObject configuration); }
ConfigMapStore implements ConfigStore { @Override public Future<Buffer> get() { Future<String> retrieveToken; if (token == null) { retrieveToken = getToken(); } else { retrieveToken = vertx.getOrCreateContext().succeededFuture(token); } return retrieveToken.flatMap(token -> { if (token.isEmpty()) { return Future.succeededFuture(Buffer.buffer("{}")); } String path = "/api/v1/namespaces/" + namespace; if (secret) { path += "/secrets/" + name; } else { path += "/configmaps/" + name; } return client.get(path) .putHeader("Authorization", "Bearer " + token) .send() .flatMap(response -> { if (response.statusCode() == 404) { return handle404(); } if (response.statusCode() == 403) { return handle403(); } if (response.statusCode() != 200) { return handleOtherErrors(response); } return handle200(response); }); }); } ConfigMapStore(Vertx vertx, JsonObject configuration); @Override Future<Void> close(); @Override Future<Buffer> get(); }
ConfigMapStore implements ConfigStore { @Override public Future<Buffer> get() { Future<String> retrieveToken; if (token == null) { retrieveToken = getToken(); } else { retrieveToken = vertx.getOrCreateContext().succeededFuture(token); } return retrieveToken.flatMap(token -> { if (token.isEmpty()) { return Future.succeededFuture(Buffer.buffer("{}")); } String path = "/api/v1/namespaces/" + namespace; if (secret) { path += "/secrets/" + name; } else { path += "/configmaps/" + name; } return client.get(path) .putHeader("Authorization", "Bearer " + token) .send() .flatMap(response -> { if (response.statusCode() == 404) { return handle404(); } if (response.statusCode() == 403) { return handle403(); } if (response.statusCode() != 200) { return handleOtherErrors(response); } return handle200(response); }); }); } ConfigMapStore(Vertx vertx, JsonObject configuration); @Override Future<Void> close(); @Override Future<Buffer> get();  }