Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: terraform module validation #4509

Merged
merged 5 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion plugins/terraform/test/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test-project/**/*.lock.hcl
**/.terraform.lock.hcl