@@ -15,6 +15,7 @@ import com.redhat.devtools.intellij.kubernetes.model.IResourceModelObservable
15
15
import com.redhat.devtools.intellij.kubernetes.model.client.ClientAdapter
16
16
import com.redhat.devtools.intellij.kubernetes.model.client.KubeClientAdapter
17
17
import com.redhat.devtools.intellij.kubernetes.model.client.OSClientAdapter
18
+ import com.redhat.devtools.intellij.kubernetes.model.resource.IResourceOperator
18
19
import com.redhat.devtools.intellij.kubernetes.model.resource.ResourceKind
19
20
import com.redhat.devtools.intellij.kubernetes.model.resource.kubernetes.KubernetesReplicas.Replicator
20
21
import io.fabric8.kubernetes.api.model.GenericKubernetesResource
@@ -23,30 +24,29 @@ import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition
23
24
import io.fabric8.kubernetes.client.KubernetesClient
24
25
import io.fabric8.kubernetes.client.Watch
25
26
import io.fabric8.kubernetes.client.Watcher
27
+ import io.fabric8.openshift.api.model.Project
28
+ import io.fabric8.openshift.client.OpenShiftClient
26
29
import java.net.URL
27
30
28
31
interface IActiveContext <N : HasMetadata , C : KubernetesClient >: IContext {
29
32
30
33
companion object Factory {
31
- fun create (
34
+ fun createLazyOpenShift (
32
35
client : ClientAdapter <out KubernetesClient >,
33
- observable : IResourceModelObservable
36
+ modelChange : IResourceModelObservable
34
37
): IActiveContext <out HasMetadata , out KubernetesClient >? {
35
38
val currentContext = client.config.currentContext ? : return null
36
- return if (client.isOpenShift()) {
37
- OpenShiftContext (
38
- currentContext,
39
- observable,
40
- client as OSClientAdapter
41
- )
42
- } else {
43
- KubernetesContext (
44
- currentContext,
45
- observable,
46
- client as KubeClientAdapter
47
- )
48
- }
39
+ return LazyOpenShiftContext (currentContext, modelChange, client as KubeClientAdapter )
49
40
}
41
+
42
+ fun createOpenShift (
43
+ client : OSClientAdapter ,
44
+ modelChange : IResourceModelObservable
45
+ ): IActiveContext <Project , OpenShiftClient >? {
46
+ val currentContext = client.config.currentContext ? : return null
47
+ return OpenShiftContext (currentContext, modelChange, client)
48
+ }
49
+
50
50
}
51
51
52
52
/* *
@@ -65,6 +65,8 @@ interface IActiveContext<N: HasMetadata, C: KubernetesClient>: IContext {
65
65
}
66
66
}
67
67
68
+ val namespaceKind : ResourceKind <out HasMetadata >
69
+
68
70
/* *
69
71
* The master url for this context. This is the url of the cluster for this context.
70
72
*/
@@ -75,6 +77,16 @@ interface IActiveContext<N: HasMetadata, C: KubernetesClient>: IContext {
75
77
*/
76
78
val version: ClusterInfo
77
79
80
+ /* *
81
+ * Returns the list of internal [IResourceOperator]s that are available in this context.
82
+ * [IResourceOperator]s that are contributed by registrations to the extension point are not included.
83
+ *
84
+ * @return the list of [IResourceOperator]s that are available in this context.
85
+ * @see IResourceOperator
86
+ * @see com.redhat.devtools.intellij.kubernetes.model.context.ActiveContext.getExtensionResourceOperators
87
+ */
88
+ fun getInternalResourceOperators (): List <IResourceOperator <out HasMetadata >>
89
+
78
90
/* *
79
91
* Returns {@code true} if this context is an OpenShift context. This is true for context with an OpenShift cluster.
80
92
*/
@@ -129,7 +141,7 @@ interface IActiveContext<N: HasMetadata, C: KubernetesClient>: IContext {
129
141
fun getAllResources (definition : CustomResourceDefinition ): Collection <GenericKubernetesResource >
130
142
131
143
/* *
132
- * Returns the latest version of the given resource from cluster. Returns `null` if none was found.
144
+ * Returns the latest version of the given resource from the cluster. Returns `null` if none was found.
133
145
*
134
146
* @param resource which is to be requested from cluster
135
147
*
@@ -265,7 +277,7 @@ interface IActiveContext<N: HasMetadata, C: KubernetesClient>: IContext {
265
277
/* *
266
278
* Notifies the context that the given resource was replaced in the cluster.
267
279
* Replaces the resource with the given new version if it exists.
268
- * Does nothing otherwiese .
280
+ * Does nothing otherwise .
269
281
*
270
282
*
271
283
* @param resource the new (version) of the resource
@@ -279,7 +291,7 @@ interface IActiveContext<N: HasMetadata, C: KubernetesClient>: IContext {
279
291
*
280
292
* @return the url of the Dashboard for this context
281
293
*/
282
- fun getDashboardUrl (): String
294
+ fun getDashboardUrl (): String?
283
295
284
296
/* *
285
297
* Closes and disposes this context.
0 commit comments