Repository navigation
universe: Add Terraform package - #2192
Conversation
Signed-off-by: Ezequiel Foncubierta <[email protected]>
Signed-off-by: Ezequiel Foncubierta <[email protected]>
…to terraform_package
There was a problem hiding this comment.
Thanks!
You should comment all your public fields so it gets picked up by the CLI:
https://docs.dagger.io/1226/coding-style
Also, please squash your commits and run linter locally:
https://docs.dagger.io/1227/contributing
TomChv
left a comment
There was a problem hiding this comment.
Thank for your contribution, it's an amazing work!
I really like your implementation, it's a good one.
I left some comments to make it even more awesome 🚀
I will take pleasure to follow up your work on that PR :D
There was a problem hiding this comment.
Nit: You could use exports from docker.#Run instead of an intermediate steps to retrieve directory
Since packages are experimental, it's okay to have duplication. |
|
I amended most of the requested changes, but using mount instead of I am getting the following error when running Re squashing commit. I was able to do it only on commits after the rebase from |
TomChv
left a comment
There was a problem hiding this comment.
It looks really good!
I'll play with your package to understand why you can't simplify the exports.
However, it's already mergeable, we can improve package's internal later ;)
There was a problem hiding this comment.
You could directly use docker.#Run outside docker.#Build, I'll try your package and show you ;)
There was a problem hiding this comment.
For completeness, this is what I tried and didn't work
#Run: {
...
_image: #Image
// Run command within a container
_run: docker.#Run & {
input: *_image.output | docker.#Image
workdir: "/src"
command: {
name: cmd
args: _thisCmdArgs
}
mounts: src: {
dest: "/src"
contents: source
}
env: _thisEnv
}
...
}
There was a problem hiding this comment.
Oh you are right, you are updating /src and outputting it for further operation so yes, you did great!
|
@TomChv @efoncubierta Really looking forward to merge this. What's missing? Anything we can help with? |
Fixing lint and another approval from me after a manual test of the package, I'll do it tomorrow |
|
Thanks @TomChv! |
|
I manually tested the package! It's really good 🚀 We can merge that package just after lint error are fixed. @efoncubierta You can just run |
|
@efoncubierta I fixed your linter error, just squash all your commits (do not forget to pull, I've fix your lint error) and we will merge that one! |
Signed-off-by: Ezequiel Foncubierta <[email protected]> chore(universe/terraform): fix linter Signed-off-by: Vasek - Tom C <[email protected]>
|
@TomChv I squashed the commits. I can't squash the two commits before the merge from the main branch. |
|
@aluzzardi Ready for merge! |
Signed-off-by: Ezequiel Foncubierta [email protected]
I know there is another contribution for a Terraform package (#2110), but this one we are currently using and implementing at work, and supports a lot more features. The approach is similar to Nico's implementation, so feel free to merge it into his package, or the other way around, if necessary.
Implementation details
There is a
terraform.#Runaction to wrap the Terraform command and run it within the official Terraform container image, from Hashicorp. You can set the Terraform command you want to run (i.e. plan, apply), the arguments (i.e. -var-file, -var), and environment variables. For common environment variables or arguments, there is a field interraform.#Runyou can use. For example, theworkspacefields will become aTF_WORKSPACEenvironment variable.For each particular Terraform command (i.e. plan, apply) there is an action (i.e.
terraform.#Plan) that extendsterraform.#Run. These actions override the command field and define additional fields when necessary. For example, aplanFilefield.For things that are not "yet supported", you can always fall back to the
terraform.#Runaction.The
terraform.#Runactions have two outputs:output: Adagger.#FSwith the modified Terraform workspace.outputImage: Thedocker.#Imagethat was used to run the command.Not yet supported
terraform.#Runthough):terraform.#Runso you can chain multiple commands within the same container?