Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
chore: add terraform provider test for slug validity
  • Loading branch information
deansheather committed Oct 21, 2022
commit fecef1e42a593b9992b9169816602be4b9d744b9
6 changes: 6 additions & 0 deletions provisioner/terraform/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
}

// Associate Apps with agents.
appSlugs := make(map[string]struct{})
for _, resource := range tfResourceByLabel {
if resource.Type != "coder_app" {
continue
Expand Down Expand Up @@ -248,6 +249,11 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
return nil, xerrors.Errorf("invalid app slug %q, please update your coder/coder provider to the latest version and specify the slug property on each coder_app", attrs.Slug)
}

if _, exists := appSlugs[attrs.Slug]; exists {
return nil, xerrors.Errorf("duplicate app slug, they must be unique per template: %q", attrs.Slug)
}
appSlugs[attrs.Slug] = struct{}{}

var healthcheck *proto.Healthcheck
if len(attrs.Healthcheck) != 0 {
healthcheck = &proto.Healthcheck{
Expand Down
Loading