Skip to content

Commit

Permalink
fix: issues with kubernetes-client after upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed May 14, 2018
1 parent ceca5c4 commit f4096a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/plugins/kubernetes/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`,
},
Expand Down Expand Up @@ -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
}
Expand All @@ -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 && <TestResult>deserializeKeys(res.data)
}

Expand Down Expand Up @@ -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()
}

Expand All @@ -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 }
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/kubernetes/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<ServiceStatus> {
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)
Expand Down Expand Up @@ -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
Expand All @@ -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",
Expand Down

0 comments on commit f4096a2

Please sign in to comment.