Skip to content

Commit

Permalink
fix: test errors (TBS)
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jun 24, 2020
1 parent 8697b9b commit 3e47924
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions garden-service/src/plugins/kubernetes/kubectl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,19 @@ class Kubectl extends PluginTool {
}

async stdout(params: KubectlParams) {
this.prepareArgs(params)
return super.stdout(params)
}

async exec(params: KubectlParams) {
this.prepareArgs(params)
return super.exec(params)
return super.exec(this.prepareArgs(params))
}

async spawn(params: KubectlParams) {
this.prepareArgs(params)
return super.spawn(params)
return super.spawn(this.prepareArgs(params))
}

async spawnAndWait(params: KubectlSpawnParams) {
this.prepareArgs(params)
return super.spawnAndWait(params)
return super.spawnAndWait(this.prepareArgs(params))
}

async json(params: KubectlParams): Promise<any> {
Expand All @@ -168,7 +164,11 @@ class Kubectl extends PluginTool {
private prepareArgs(params: KubectlParams) {
const { namespace, configPath, args } = params

const opts: string[] = [`--context=${this.provider.config.context}`]
const opts: string[] = []

if (this.provider.config.context) {
opts.push(`--context=${this.provider.config.context}`)
}

if (this.provider.config.kubeconfig) {
opts.push(`--kubeconfig=${this.provider.config.kubeconfig}`)
Expand All @@ -182,7 +182,7 @@ class Kubectl extends PluginTool {
opts.push(`--kubeconfig=${configPath}`)
}

params.args = opts.concat(args)
return { ...params, args: opts.concat(args) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function runAndCopy({
podName: runner.podName,
containerNames: [mainContainerName],
})
return containerLogs[0].log
return containerLogs[0]?.log || ""
}

const timedOutResult = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("kubernetes container module handlers", () => {
before(async () => {
garden = await makeTestGarden(root)
provider = <KubernetesProvider>await garden.resolveProvider(garden.log, "local-kubernetes")
namespace = garden.projectName
namespace = provider.config.namespace!
})

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe("kubernetes container deployment handlers", () => {
}
await api.upsert({ kind: "Secret", namespace: "default", obj: authSecret, log: garden.log })

const namespace = garden.projectName
const namespace = provider.config.namespace!
const _provider = cloneDeep(provider)
_provider.config.imagePullSecrets = [{ name: secretName, namespace: "default" }]

Expand Down Expand Up @@ -169,7 +169,7 @@ describe("kubernetes container deployment handlers", () => {
}
await api.upsert({ kind: "Secret", namespace: "default", obj: authSecret, log: garden.log })

const namespace = garden.projectName
const namespace = provider.config.namespace!
const _provider = cloneDeep(provider)
_provider.config.imagePullSecrets = [{ name: secretName, namespace: "default" }]

Expand All @@ -191,7 +191,7 @@ describe("kubernetes container deployment handlers", () => {

it("should correctly mount a referenced PVC module", async () => {
const service = graph.getService("volume-reference")
const namespace = garden.projectName
const namespace = provider.config.namespace!

const resource = await createWorkloadManifest({
api,
Expand All @@ -212,7 +212,7 @@ describe("kubernetes container deployment handlers", () => {

it("should throw if incompatible module is specified as a volume module", async () => {
const service = graph.getService("volume-reference")
const namespace = garden.projectName
const namespace = provider.config.namespace!

service.spec.volumes = [{ name: "test", module: "simple-service" }]

Expand Down

0 comments on commit 3e47924

Please sign in to comment.