-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: forward parent lifecycles to child stages defined on the module
In scenarios where lifecycles are defined on the module level, there was an issue preventing the same lifecycle phases from being applied to the child modules. This was very inconvenient when reusing multiple modules and the caller may have custom lifecycle phases, but the module's are not owned by the caller to make changes
- Loading branch information
1 parent
aa2632a
commit 9fd8308
Showing
6 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
togomak { | ||
version = 2 | ||
} | ||
|
||
variable "a" { | ||
type = number | ||
description = "first variable" | ||
} | ||
variable "b" { | ||
type = number | ||
description = "second variable" | ||
} | ||
|
||
variable "operation" { | ||
type = string | ||
description = "Operation to perform, any of: [add, subtract, multiply, divide]" | ||
} | ||
|
||
stage "add" { | ||
if = var.operation == "add" | ||
script = "echo ${var.a} + ${var.b} is ${var.a + var.b}" | ||
} | ||
|
||
stage "paths" { | ||
script = <<-EOT | ||
echo path.module: ${path.module} | ||
echo path.cwd: ${path.cwd} | ||
echo path.root: ${path.root} | ||
EOT | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
togomak { | ||
version = 2 | ||
} | ||
|
||
locals { | ||
a = 99 | ||
b = 1 | ||
} | ||
|
||
stage "paths" { | ||
script = <<-EOT | ||
echo path.module: ${path.module} | ||
echo path.cwd: ${path.cwd} | ||
echo path.root: ${path.root} | ||
EOT | ||
} | ||
|
||
module "add" { | ||
source = "./calculator" | ||
a = local.a | ||
b = local.b | ||
operation = "add" | ||
|
||
lifecycle { | ||
phase = ["add"] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters