diff --git a/src/plugins/kubernetes/actions.ts b/src/plugins/kubernetes/actions.ts index 187e38f4a5..16111fcf48 100644 --- a/src/plugins/kubernetes/actions.ts +++ b/src/plugins/kubernetes/actions.ts @@ -90,7 +90,7 @@ export async function getEnvironmentStatus({ ctx, provider }: GetEnvironmentStat } const metadataNamespace = getMetadataNamespace(ctx, provider) - const namespacesStatus = await coreApi(context).namespaces().get() + const namespacesStatus = await coreApi(context).namespaces.get() const namespace = await getAppNamespace(ctx, provider) for (const n of namespacesStatus.items) { @@ -174,7 +174,7 @@ export async function execInService( } // get a running pod - let res = await coreApi(context, namespace).namespaces.pods.get({ + let res = await coreApi(context).namespaces(namespace).pods.get({ qs: { labelSelector: `service=${service.name}`, }, @@ -281,7 +281,7 @@ export async function testModule( }, } - await apiPostOrPut(coreApi(context, ns).namespaces.configmaps, resultKey, body) + await apiPostOrPut(coreApi(context).namespaces(ns).configmaps, resultKey, body) return testResult } @@ -292,7 +292,7 @@ export async function getTestResult( const context = provider.config.context const ns = getMetadataNamespace(ctx, provider) const resultKey = getTestResultKey(module, testName, version) - const res = await apiGetOrNull(coreApi(context, ns).namespaces.configmaps, resultKey) + const res = await apiGetOrNull(coreApi(context).namespaces(ns).configmaps, resultKey) return res && deserializeKeys(res.data) } @@ -336,7 +336,7 @@ export async function getServiceLogs( export async function getConfig({ ctx, provider, key }: GetConfigParams) { const context = provider.config.context const ns = getMetadataNamespace(ctx, provider) - const res = await apiGetOrNull(coreApi(context, ns).namespaces.secrets, key.join(".")) + const res = await apiGetOrNull(coreApi(context).namespaces(ns).secrets, key.join(".")) return res && Buffer.from(res.data.value, "base64").toString() } @@ -359,14 +359,14 @@ export async function setConfig({ ctx, provider, key, value }: SetConfigParams) }, } - await apiPostOrPut(coreApi(context, ns).namespaces.secrets, key.join("."), body) + await apiPostOrPut(coreApi(context).namespaces(ns).secrets, key.join("."), body) } export async function deleteConfig({ ctx, provider, key }: DeleteConfigParams) { const context = provider.config.context const ns = getMetadataNamespace(ctx, provider) try { - await coreApi(context, ns).namespaces.secrets(key.join(".")).delete() + await coreApi(context).namespaces(ns).secrets(key.join(".")).delete() } catch (err) { if (err.code === 404) { return { found: false } diff --git a/src/plugins/kubernetes/status.ts b/src/plugins/kubernetes/status.ts index fe2ee6dfc6..27b8fa24ce 100644 --- a/src/plugins/kubernetes/status.ts +++ b/src/plugins/kubernetes/status.ts @@ -11,6 +11,7 @@ import { LogEntry } from "../../logger" import { LogSymbolType } from "../../logger/types" import { PluginContext } from "../../plugin-context" import { Environment } from "../../types/common" +import { Provider } from "../../types/plugin" import { ServiceProtocol, ServiceStatus, @@ -31,9 +32,9 @@ import { localIngressPort } from "./system" export async function checkDeploymentStatus( { ctx, provider, service, resourceVersion }: - { ctx: PluginContext, provider: any, service: ContainerService, resourceVersion?: number }, + { ctx: PluginContext, provider: Provider, service: ContainerService, resourceVersion?: number }, ): Promise { - const context = provider.context + const context = provider.config.context const type = service.config.daemon ? "daemonsets" : "deployments" const hostname = getServiceHostname(ctx, provider, service) const namespace = await getAppNamespace(ctx, provider) @@ -61,7 +62,7 @@ export async function checkDeploymentStatus( let status try { - statusRes = await extensionsApi(context, namespace).namespaces[type](service.name).get() + statusRes = await extensionsApi(context).namespaces(namespace)[type](service.name).get() } catch (err) { if (err.code === 404) { // service is not running @@ -81,7 +82,7 @@ export async function checkDeploymentStatus( // TODO: try to come up with something more efficient. may need to wait for newer k8s version. // note: the resourceVersion parameter does not appear to work... - const eventsRes = await coreApi(context, namespace).namespaces.events.get() + const eventsRes = await coreApi(context).namespaces(namespace).events.get() // const eventsRes = await this.kubeApi( // "GET",