Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/app/piped/cloudprovider/terraform/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type FileMapping struct {
type ModuleMapping struct {
Name string `hcl:"name,label"`
Source string `hcl:"source"`
Version string `hcl:"version"`
Version string `hcl:"version,optional"`
Remain hcl.Body `hcl:",remain"`
}

Expand Down
29 changes: 29 additions & 0 deletions pkg/app/piped/cloudprovider/terraform/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ func TestLoadTerraformFiles(t *testing.T) {
},
expectedErr: false,
},
{
name: "single module with optional argument",
moduleDir: "./testdata/single_module_optional",
expected: []File{
{
Modules: []*Module{
{
Name: "helloworld",
Source: "helloworld",
Version: "",
},
},
},
},
expectedErr: false,
},
{
name: "multi modules",
moduleDir: "./testdata/multi_modules",
Expand Down Expand Up @@ -120,6 +136,19 @@ func TestFindArticatVersions(t *testing.T) {
},
expectedErr: false,
},
{
name: "single module with optional field",
moduleDir: "./testdata/single_module_optional",
expected: []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_TERRAFORM_MODULE,
Name: "helloworld",
Url: "helloworld",
Version: "",
},
},
expectedErr: false,
},
{
name: "multi modules",
moduleDir: "./testdata/multi_modules",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "docker_container" "helloworld" {
name = "gcr.io/pipecd/helloworld:${var.image_version}"
ports {
internal = 9376
external = "${var.external_port}"
}
}

variable "external_port" {
default = 80
}

variable "image_version" {
default = "latest"
}

output "container" {
value = docker_image.helloworld
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
provider "docker" {
}

module "helloworld" {
source = "helloworld"
image_version = "v1.0.0"
external_port = 8080
}