File tree 2 files changed +7
-5
lines changed
src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ open class AllContexts(
143
143
this .client.get()
144
144
)
145
145
this .current?.close()
146
+ newClient.config.save().join()
146
147
all.clear() // causes reload of all contexts when accessed afterwards
147
148
val newCurrent = this .current // gets new current from all
148
149
if (toWatch != null ) {
@@ -197,7 +198,6 @@ open class AllContexts(
197
198
private fun replaceClient (new : ClientAdapter <out KubernetesClient >, old : ClientAdapter <out KubernetesClient >? )
198
199
: ClientAdapter <out KubernetesClient > {
199
200
old?.close()
200
- new.config.save()
201
201
this .client.set(new)
202
202
return new
203
203
}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import io.fabric8.kubernetes.api.model.NamedContext
17
17
import io.fabric8.kubernetes.client.Client
18
18
import io.fabric8.kubernetes.client.Config
19
19
import io.fabric8.kubernetes.client.internal.KubeConfigUtils
20
+ import java.util.concurrent.CompletableFuture
20
21
21
22
/* *
22
23
* An adapter to access [io.fabric8.kubernetes.client.Config].
@@ -45,12 +46,12 @@ open class ClientConfig(private val client: Client) {
45
46
KubeConfigAdapter ()
46
47
}
47
48
48
- fun save () {
49
- runAsync {
49
+ fun save (): CompletableFuture < Boolean > {
50
+ return CompletableFuture .supplyAsync {
50
51
if (! kubeConfig.exists()) {
51
- return @runAsync
52
+ return @supplyAsync false
52
53
}
53
- val fromFile = kubeConfig.load() ? : return @runAsync
54
+ val fromFile = kubeConfig.load() ? : return @supplyAsync false
54
55
val currentContextInFile = KubeConfigUtils .getCurrentContext(fromFile)
55
56
if (setCurrentContext(
56
57
currentContext,
@@ -64,6 +65,7 @@ open class ClientConfig(private val client: Client) {
64
65
) {
65
66
kubeConfig.save(fromFile)
66
67
}
68
+ return @supplyAsync true
67
69
}
68
70
}
69
71
You can’t perform that action at this time.
0 commit comments