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 98fc5b7 commit c68ae28
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/example-projects/using-garden-in-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ name: ci-demo-project
environments:
...
- name: preview
defaultNamespace: ${project.name}-${local.env.CIRCLE_BRANCH || local.username}
defaultNamespace: preview-${local.env.CIRCLE_BRANCH || local.username}
providers:
- name: kubernetes
environments: [preview]
Expand Down
2 changes: 1 addition & 1 deletion examples/build-dependencies/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: build-dependencies
environments:
- name: local
- name: remote
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/deployment-strategies/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ environments:
- name: local-default
- name: local-blue-green
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
# Default deployment strategy
- name: local-kubernetes
Expand Down
2 changes: 1 addition & 1 deletion examples/disabled-configs/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ environments:
providers:
- name: local-kubernetes
environments: [local]
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
- name: kubernetes
environments: [remote]
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
# Replace these values as appropriate
context: gke_garden-dev-200012_europe-west1-b_garden-dev-1
defaultHostname: ${local.username}-disabled-configs.dev-1.sys.garden
Expand Down
2 changes: 1 addition & 1 deletion examples/hadolint/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: demo-project
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: hadolint
- name: local-kubernetes
Expand Down
2 changes: 1 addition & 1 deletion examples/hot-reload-post-sync-command/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: hot-reload-post-sync-command
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/hot-reload/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: hot-reload
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/kaniko/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: kaniko
environments:
- name: local
- name: remote
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/kubernetes-secrets/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: kubernetes-secrets
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/openfaas/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: openfaas
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/project-variables/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environments:
# We only want one replica of each service when developing locally
service-replicas: 1
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/remote-sources/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sources:
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/tasks/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tasks
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/vote-helm/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: vote-helm
environments:
- name: local
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
2 changes: 1 addition & 1 deletion examples/vote/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ environments:
- name: local
- name: remote
- name: testing
defaultNamespace: ${project.name}-testing-${local.env.CIRCLE_BUILD_NUM || local.username}
defaultNamespace: testing-${local.env.CIRCLE_BUILD_NUM || local.username}
providers:
- name: local-kubernetes
environments: [local]
Expand Down
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 Expand Up @@ -161,7 +161,7 @@ describe("kubernetes container module handlers", () => {
args: [],
interactive: false,
module,
namespace: garden.projectName,
namespace: provider.config.namespace!,
podName,
runtimeContext: { envVars: {}, dependencies: [] },
image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ describe("kubernetes container deployment handlers", () => {

it("should create a basic Deployment resource", async () => {
const service = graph.getService("simple-service")
const namespace = provider.config.namespace!

const resource = await createWorkloadManifest({
api,
provider,
service,
runtimeContext: emptyRuntimeContext,
namespace: garden.projectName,
namespace,
enableHotReload: false,
log: garden.log,
production: false,
Expand All @@ -71,7 +72,7 @@ describe("kubernetes container deployment handlers", () => {
metadata: {
name: "simple-service-" + version,
annotations: { "garden.io/configured.replicas": "1" },
namespace: "container",
namespace,
labels: { "module": "simple-service", "service": "simple-service", "garden.io/version": version },
},
spec: {
Expand Down Expand Up @@ -131,7 +132,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 +170,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 +192,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 +213,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
2 changes: 1 addition & 1 deletion garden-service/test/integ/src/plugins/kubernetes/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe("util", () => {
provider,
service,
runtimeContext: emptyRuntimeContext,
namespace: "container",
namespace: provider.config.namespace!,
enableHotReload: false,
log: garden.log,
production: false,
Expand Down

0 comments on commit c68ae28

Please sign in to comment.