8000 Fix #33 - Do not fail the retrieval if the config map store is used o… · soujava/vertx-config@4824def · GitHub
[go: up one dir, main page]

Skip to content

Commit 4824def

Browse files
committed
Fix vert-x3#33 - Do not fail the retrieval if the config map store is used outside of kubernetes (and marked as optional)
1 parent 7629314 commit 4824def

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

vertx-config-kubernetes-configmap/src/main/java/io/vertx/config/kubernetes/ConfigMapStore.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ private Future<String> getToken() {
140140
// Read from file
141141
vertx.fileSystem().readFile(KubernetesUtils.OPENSHIFT_KUBERNETES_TOKEN_FILE, ar -> {
142142
if (ar.failed()) {
143-
result.tryFail(ar.cause());
143+
if (optional) {
144+
this.token = "";
145+
result.tryComplete(token);
146+
} else {
147+
result.tryFail(ar.cause());
148+
}
144149
} else {
145150
this.token = ar.result().toString();
146151
result.tryComplete(ar.result().toString());
@@ -165,14 +170,19 @@ private synchronized void getOnContext(Handler<AsyncResult<Buffer>> completionHa
165170

166171
retrieveToken
167172
.compose(token -> {
173+
Future<Buffer> future = Future.future();
174+
if (token.isEmpty()) {
175+
future.complete(Buffer.buffer("{}"));
176+
return future;
177+
}
178+
168179
String path = "/api/v1/namespaces/" + namespace;
169180
if (secret) {
170181
path += "/secrets/" + name;
171182
} else {
172183
path += "/configmaps/" + name;
173184
}
174185

175-
Future<Buffer> future = Future.future();
176186
client.get(path)
177187
.putHeader("Authorization", "Bearer " + token)
178188
.send(ar -> {

0 commit comments

Comments
 (0)
0