Skip to content

Commit

Permalink
fix: terraform module validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Walther committed Jun 1, 2023
1 parent 509f162 commit 9aa76ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 0 additions & 1 deletion plugins/terraform/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const variablesSchema = () => joiStringMap(joi.any())
export interface TerraformBaseSpec {
allowDestroy: boolean
autoApply: boolean
dependencies: string[]
variables: PrimitiveMap
version: string | null
workspace?: string
Expand Down
14 changes: 11 additions & 3 deletions plugins/terraform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { join } from "path"
import { omit } from "lodash"
import { pathExists } from "fs-extra"
import { createGardenPlugin } from "@garden-io/sdk"
import { cleanupEnvironment, getEnvironmentStatus, prepareEnvironment } from "./init"
Expand Down Expand Up @@ -191,7 +192,7 @@ export const gardenPlugin = () =>
actions.push(dummyBuild)
}

actions.push({
const deployAction: TerraformDeployConfig = {
kind: "Deploy",
type: "terraform",
name: module.name,
Expand All @@ -202,9 +203,16 @@ export const gardenPlugin = () =>

timeout: defaultTerraformTimeoutSec,
spec: {
...module.spec,
allowDestroy: module.spec.allowDestroy || true,
autoApply: module.spec.autoApply || true,
root: module.spec.root || ".",
variables: module.spec.variables || {},
version: module.spec.version || defaultTerraformVersion,
...omit(module.spec, ["build", "dependencies"]),
},
})
}

actions.push(deployAction)

return {
group: {
Expand Down
1 change: 1 addition & 0 deletions plugins/terraform/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { terraformDeploySchemaKeys } from "./action"

export interface TerraformModuleSpec extends TerraformBaseSpec {
root: string
dependencies: string[]
}

export interface TerraformModule extends GardenModule<TerraformModuleSpec> {}
Expand Down

0 comments on commit 9aa76ff

Please sign in to comment.