Skip to content

Commit fecef1e

Browse files
committed
chore: add terraform provider test for slug validity
1 parent 4efc389 commit fecef1e

21 files changed

+294
-568
lines changed

provisioner/terraform/resources.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
220220
}
221221

222222
// Associate Apps with agents.
223+
appSlugs := make(map[string]struct{})
223224
for _, resource := range tfResourceByLabel {
224225
if resource.Type != "coder_app" {
225226
continue
@@ -248,6 +249,11 @@ func ConvertResources(module *tfjson.StateModule, rawGraph string) ([]*proto.Res
248249
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)
249250
}
250251

252+
if _, exists := appSlugs[attrs.Slug]; exists {
253+
return nil, xerrors.Errorf("duplicate app slug, they must be unique per template: %q", attrs.Slug)
254+
}
255+
appSlugs[attrs.Slug] = struct{}{}
256+
251257
var healthcheck *proto.Healthcheck
252258
if len(attrs.Healthcheck) != 0 {
253259
healthcheck = &proto.Healthcheck{

0 commit comments

Comments
 (0)