@@ -38,9 +38,9 @@ func TestAccResourceContainer(t *testing.T) {
3838 accTestContainerIDClone := 100000 + rand .Intn (99999 )
3939
4040 te .AddTemplateVars (map [string ]interface {}{
41- "ImageFileName" : imageFileName ,
42- "TestContainerID" : accTestContainerID ,
43- "TestContainerIDClone" : accTestContainerIDClone ,
41+ "ImageFileName" : imageFileName ,
42+ "TestContainerID" : accTestContainerID ,
43+ "TestContainerIDClone" : accTestContainerIDClone ,
4444 })
4545
4646 err := te .NodeStorageClient ().DownloadFileByURL (context .Background (), & storage.DownloadURLPostRequestBody {
@@ -512,6 +512,225 @@ func TestAccResourceContainer(t *testing.T) {
512512 ),
513513 },
514514 }},
515+ {"empty dns block on update" , []resource.TestStep {
516+ {
517+ Config : te .RenderConfig (`
518+ resource "proxmox_virtual_environment_container" "test_container" {
519+ node_name = "{{.NodeName}}"
520+ unprivileged = true
521+ disk {
522+ datastore_id = "local-lvm"
523+ size = 4
524+ }
525+ initialization {
526+ hostname = "test-dns-issue"
527+ ip_config {
528+ ipv4 {
529+ address = "dhcp"
530+ }
531+ }
532+ }
533+ network_interface {
534+ name = "vmbr0"
535+ }
536+ operating_system {
537+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
538+ type = "ubuntu"
539+ }
540+ }` , WithRootUser ()),
541+ Check : resource .ComposeTestCheckFunc (
542+ ResourceAttributes (accTestContainerName , map [string ]string {
543+ "initialization.0.hostname" : "test-dns-issue" ,
544+ "initialization.0.dns.#" : "0" ,
545+ }),
546+ ),
547+ },
548+ {
549+ Config : te .RenderConfig (`
550+ resource "proxmox_virtual_environment_container" "test_container" {
551+ node_name = "{{.NodeName}}"
552+ unprivileged = true
553+ disk {
554+ datastore_id = "local-lvm"
555+ size = 4
556+ }
557+ initialization {
558+ hostname = "test-dns-issue"
559+ dns {}
560+ ip_config {
561+ ipv4 {
562+ address = "dhcp"
563+ }
564+ }
565+ }
566+ network_interface {
567+ name = "vmbr0"
568+ }
569+ operating_system {
570+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
571+ type = "ubuntu"
572+ }
573+ }` , WithRootUser ()),
574+ Check : resource .ComposeTestCheckFunc (
575+ ResourceAttributes (accTestContainerName , map [string ]string {
576+ "initialization.0.hostname" : "test-dns-issue" ,
577+ "initialization.0.dns.#" : "0" ,
578+ }),
579+ ),
580+ },
581+ }},
582+ {"empty dns block on create" , []resource.TestStep {
583+ {
584+ Config : te .RenderConfig (`
585+ resource "proxmox_virtual_environment_container" "test_container" {
586+ node_name = "{{.NodeName}}"
587+ unprivileged = true
588+ disk {
589+ datastore_id = "local-lvm"
590+ size = 4
591+ }
592+ initialization {
593+ hostname = "test-dns-create"
594+ dns {}
595+ ip_config {
596+ ipv4 {
597+ address = "dhcp"
598+ }
599+ }
600+ }
601+ network_interface {
602+ name = "vmbr0"
603+ }
604+ operating_system {
605+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
606+ type = "ubuntu"
607+ }
608+ }` , WithRootUser ()),
609+ Check : resource .ComposeTestCheckFunc (
610+ ResourceAttributes (accTestContainerName , map [string ]string {
611+ "initialization.0.hostname" : "test-dns-create" ,
612+ "initialization.0.dns.#" : "0" ,
613+ }),
614+ ),
615+ },
616+ }},
617+ {"dns block with null values on create" , []resource.TestStep {
618+ {
619+ Config : te .RenderConfig (`
620+ resource "proxmox_virtual_environment_container" "test_container" {
621+ node_name = "{{.NodeName}}"
622+ unprivileged = true
623+ disk {
624+ datastore_id = "local-lvm"
625+ size = 4
626+ }
627+ initialization {
628+ hostname = "test-dns-create"
629+ dns {
630+ domain = null
631+ server = ""
632+ servers = null
633+ }
634+ ip_config {
635+ ipv4 {
636+ address = "dhcp"
637+ }
638+ }
639+ }
640+ network_interface {
641+ name = "vmbr0"
642+ }
643+ operating_system {
644+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
645+ type = "ubuntu"
646+ }
647+ }` , WithRootUser ()),
648+ Check : resource .ComposeTestCheckFunc (
649+ ResourceAttributes (accTestContainerName , map [string ]string {
650+ "initialization.0.hostname" : "test-dns-create" ,
651+ "initialization.0.dns.#" : "0" ,
652+ }),
653+ ),
654+ },
655+ }},
656+ {"dns block with null values on update" , []resource.TestStep {
657+ {
658+ Config : te .RenderConfig (`
659+ resource "proxmox_virtual_environment_container" "test_container" {
660+ node_name = "{{.NodeName}}"
661+ unprivileged = true
662+ disk {
663+ datastore_id = "local-lvm"
664+ size = 4
665+ }
666+ initialization {
667+ hostname = "test-dns-update"
668+ dns {
669+ domain = "example.com"
670+ servers = ["8.8.8.8", "8.8.4.4"]
671+ }
672+ ip_config {
673+ ipv4 {
674+ address = "dhcp"
675+ }
676+ }
677+ }
678+ network_interface {
679+ name = "vmbr0"
680+ }
681+ operating_system {
682+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
683+ type = "ubuntu"
684+ }
685+ }` , WithRootUser ()),
686+ Check : resource .ComposeTestCheckFunc (
687+ ResourceAttributes (accTestContainerName , map [string ]string {
688+ "initialization.0.hostname" : "test-dns-update" ,
689+ "initialization.0.dns.#" : "1" ,
690+ "initialization.0.dns.0.domain" : "example.com" ,
691+ "initialization.0.dns.0.servers.#" : "2" ,
692+ "initialization.0.dns.0.servers.0" : "8.8.8.8" ,
693+ "initialization.0.dns.0.servers.1" : "8.8.4.4" ,
694+ }),
695+ ),
696+ },
697+ {
698+ Config : te .RenderConfig (`
699+ resource "proxmox_virtual_environment_container" "test_container" {
700+ node_name = "{{.NodeName}}"
701+ unprivileged = true
702+ disk {
703+ datastore_id = "local-lvm"
704+ size = 4
705+ }
706+ initialization {
707+ hostname = "test-dns-update"
708+ dns {
709+ domain = ""
710+ servers = null
711+ }
712+ ip_config {
713+ ipv4 {
714+ address = "dhcp"
715+ }
716+ }
717+ }
718+ network_interface {
719+ name = "vmbr0"
720+ }
721+ operating_system {
722+ template_file_id = "local:vztmpl/{{.ImageFileName}}"
723+ type = "ubuntu"
724+ }
725+ }` , WithRootUser ()),
726+ Check : resource .ComposeTestCheckFunc (
727+ ResourceAttributes (accTestContainerName , map [string ]string {
728+ "initialization.0.hostname" : "test-dns-update" ,
729+ "initialization.0.dns.#" : "0" ,
730+ }),
731+ ),
732+ },
733+ }},
515734 }
516735
517736 for _ , tt := range tests {
0 commit comments