@@ -602,7 +602,7 @@ func TestTemplatePush(t *testing.T) {
602
602
templateVersion = coderdtest .AwaitTemplateVersionJobCompleted (t , client , templateVersion .ID )
603
603
template := coderdtest .CreateTemplate (t , client , owner .OrganizationID , templateVersion .ID )
604
604
605
- // Push new template version without provisioner tags. CLI should reuse tags from the previous version .
605
+ // Push new template version with different provisioner tags.
606
606
source := clitest .CreateTemplateVersionSource (t , & echo.Responses {
607
607
Parse : echo .ParseComplete ,
608
608
ProvisionApply : echo .ApplyComplete ,
@@ -639,6 +639,75 @@ func TestTemplatePush(t *testing.T) {
639
639
require .EqualValues (t , map [string ]string {"foobar" : "foobaz" , "owner" : "" , "scope" : "organization" }, templateVersion .Job .Tags )
640
640
})
641
641
642
+ t .Run ("DeleteTags" , func (t * testing.T ) {
643
+ t .Parallel ()
644
+
645
+ ctx := testutil .Context (t , testutil .WaitLong )
646
+
647
+ // Start the first provisioner with no tags.
648
+ client , provisionerDocker , api := coderdtest .NewWithAPI (t , & coderdtest.Options {
649
+ IncludeProvisionerDaemon : true ,
650
+ ProvisionerDaemonTags : map [string ]string {},
651
+ })
652
+ defer provisionerDocker .Close ()
653
+
654
+ // Start the second provisioner with a tag set.
655
+ provisionerFoobar := coderdtest .NewTaggedProvisionerDaemon (t , api , "provisioner-foobar" , map [string ]string {
656
+ "foobar" : "foobaz" ,
657
+ })
658
+ defer provisionerFoobar .Close ()
659
+
660
+ owner := coderdtest .CreateFirstUser (t , client )
661
+ templateAdmin , _ := coderdtest .CreateAnotherUser (t , client , owner .OrganizationID , rbac .RoleTemplateAdmin ())
662
+
663
+ // Create the template with initial tagged template version.
664
+ templateVersion := coderdtest .CreateTemplateVersion (t , client , owner .OrganizationID , nil , func (ctvr * codersdk.CreateTemplateVersionRequest ) {
665
+ ctvr .ProvisionerTags = map [string ]string {
666
+ "foobar" : "foobaz" ,
667
+ }
668
+ })
669
+ templateVersion = coderdtest .AwaitTemplateVersionJobCompleted (t , client , templateVersion .ID )
670
+ template := coderdtest .CreateTemplate (t , client , owner .OrganizationID , templateVersion .ID )
671
+
672
+ // Stop the tagged provisioner daemon.
673
+ provisionerFoobar .Close ()
674
+
675
+ // Push new template version with no provisioner tags.
676
+ source := clitest .CreateTemplateVersionSource (t , & echo.Responses {
677
+ Parse : echo .ParseComplete ,
678
+ ProvisionApply : echo .ApplyComplete ,
679
+ })
680
+ inv , root := clitest .New (t , "templates" , "push" , template .Name , "--directory" , source , "--test.provisioner" , string (database .ProvisionerTypeEcho ), "--name" , template .Name , "--provisioner-tag=\" -\" " )
681
+ clitest .SetupConfig (t , templateAdmin , root )
682
+ pty := ptytest .New (t ).Attach (inv )
683
+
684
+ execDone := make (chan error )
685
+ go func () {
686
+ execDone <- inv .WithContext (ctx ).Run ()
687
+ }()
688
+
689
+ matches := []struct {
690
+ match string
691
+ write string
692
+ }{
693
+ {match : "Upload" , write : "yes" },
694
+ }
695
+ for _ , m := range matches {
696
+ pty .ExpectMatch (m .match )
697
+ pty .WriteLine (m .write )
698
+ }
699
+
700
+ require .NoError (t , <- execDone )
701
+
702
+ // Verify template version tags
703
+ template , err := client .Template (ctx , template .ID )
704
+ require .NoError (t , err )
705
+
706
+ templateVersion , err = client .TemplateVersion (ctx , template .ActiveVersionID )
707
+ require .NoError (t , err )
708
+ require .EqualValues (t , map [string ]string {"owner" : "" , "scope" : "organization" }, templateVersion .Job .Tags )
709
+ })
710
+
642
711
t .Run ("DoNotChangeTags" , func (t * testing.T ) {
643
712
t .Parallel ()
644
713
0 commit comments