@@ -275,6 +275,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
275
275
files map [string ]string
276
276
reqTags map [string ]string
277
277
wantTags map [string ]string
278
+ variables []codersdk.VariableValue
278
279
expectError string
279
280
}{
280
281
{
@@ -290,6 +291,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
290
291
default = "1"
291
292
}
292
293
data "coder_parameter" "b" {
294
+ name = "b"
293
295
type = string
294
296
default = "2"
295
297
}
@@ -311,6 +313,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
311
313
default = "1"
312
314
}
313
315
data "coder_parameter" "b" {
316
+ name = "b"
314
317
type = string
315
318
default = "2"
316
319
}
@@ -335,6 +338,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
335
338
default = "1"
336
339
}
337
340
data "coder_parameter" "b" {
341
+ name = "b"
338
342
type = string
339
343
default = "2"
340
344
}
@@ -365,6 +369,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
365
369
default = "1"
366
370
}
367
371
data "coder_parameter" "b" {
372
+ name = "b"
368
373
type = string
369
374
default = "2"
370
375
}
@@ -395,6 +400,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
395
400
default = "1"
396
401
}
397
402
data "coder_parameter" "b" {
403
+ name = "b"
398
404
type = string
399
405
default = "2"
400
406
}
@@ -429,18 +435,20 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
429
435
}
430
436
}` ,
431
437
},
432
- reqTags : map [string ]string {"a" : "b" },
433
- wantTags : map [string ]string {"owner" : "" , "scope" : "organization" , "a" : "b" },
438
+ reqTags : map [string ]string {"a" : "b" },
439
+ wantTags : map [string ]string {"owner" : "" , "scope" : "organization" , "a" : "b" },
440
+ variables : []codersdk.VariableValue {{Name : "a" , Value : "b" }},
434
441
},
435
442
{
436
- name : "main.tf with disallowed workspace tag value " ,
443
+ name : "main.tf with resource reference " ,
437
444
files : map [string ]string {
438
445
`main.tf` : `
439
446
variable "a" {
440
447
type = string
441
448
default = "1"
442
449
}
443
450
data "coder_parameter" "b" {
451
+ name = "b"
444
452
type = string
445
453
default = "2"
446
454
}
@@ -461,38 +469,8 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
461
469
}
462
470
}` ,
463
471
},
464
- expectError : `Unknown variable; There is no variable named "null_resource".` ,
465
- },
466
- {
467
- name : "main.tf with disallowed function in tag value" ,
468
- files : map [string ]string {
469
- `main.tf` : `
470
- variable "a" {
471
- type = string
472
- default = "1"
473
- }
474
- data "coder_parameter" "b" {
475
- type = string
476
- default = "2"
477
- }
478
- data "coder_parameter" "unrelated" {
479
- name = "unrelated"
480
- type = "list(string)"
481
- default = jsonencode(["a", "b"])
482
- }
483
- resource "null_resource" "test" {
484
- name = "foo"
485
- }
486
- data "coder_workspace_tags" "tags" {
487
- tags = {
488
- "foo": "bar",
489
- "a": var.a,
490
- "b": data.coder_parameter.b.value,
491
- "test": pathexpand("~/file.txt"),
492
- }
493
- }` ,
494
- },
495
- expectError : `function "pathexpand" may not be used here` ,
472
+ reqTags : map [string ]string {"foo" : "bar" , "a" : "1" , "b" : "2" , "test" : "foo" },
473
+ wantTags : map [string ]string {"owner" : "" , "scope" : "organization" , "foo" : "bar" , "a" : "1" , "b" : "2" , "test" : "foo" },
496
474
},
497
475
// We will allow coder_workspace_tags to set the scope on a template version import job
498
476
// BUT the user ID will be ultimately determined by the API key in the scope.
@@ -618,11 +596,12 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
618
596
// Create a template version from the archive
619
597
tvName := testutil .GetRandomNameHyphenated (t )
620
598
tv , err := templateAdmin .CreateTemplateVersion (ctx , owner .OrganizationID , codersdk.CreateTemplateVersionRequest {
621
- Name : tvName ,
622
- StorageMethod : codersdk .ProvisionerStorageMethodFile ,
623
- Provisioner : codersdk .ProvisionerTypeTerraform ,
624
- FileID : fi .ID ,
625
- ProvisionerTags : tt .reqTags ,
599
+ Name : tvName ,
600
+ StorageMethod : codersdk .ProvisionerStorageMethodFile ,
601
+ Provisioner : codersdk .ProvisionerTypeTerraform ,
602
+ FileID : fi .ID ,
603
+ ProvisionerTags : tt .reqTags ,
604
+ UserVariableValues : tt .variables ,
626
605
})
627
606
628
607
if tt .expectError == "" {
0 commit comments