From b24e713eaafbc1469f2c6e7c13acfc389ddcc8d0 Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:23:57 +0530 Subject: [PATCH] change label to name --- civo/network/resource_network.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/civo/network/resource_network.go b/civo/network/resource_network.go index e1f88bcf..f6240135 100644 --- a/civo/network/resource_network.go +++ b/civo/network/resource_network.go @@ -18,7 +18,7 @@ func ResourceNetwork() *schema.Resource { return &schema.Resource{ Description: "Provides a Civo network resource. This can be used to create, modify, and delete networks.", Schema: map[string]*schema.Schema{ - "label": { + "name": { Type: schema.TypeString, Required: true, Description: "Name for the network", @@ -43,12 +43,6 @@ func ResourceNetwork() *schema.Resource { }, Description: "List of nameservers for the network", }, - // Computed resource - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the network", - }, "default": { Type: schema.TypeBool, Computed: true, @@ -105,7 +99,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf apiClient.Region = region.(string) } - log.Printf("[INFO] creating the new network %s", d.Get("label").(string)) + log.Printf("[INFO] creating the new network %s", d.Get("name").(string)) vlanConfig := civogo.VLANConnectConfig{ VlanID: d.Get("vlan_id").(int), PhysicalInterface: d.Get("vlan_physical_interface").(string), @@ -116,7 +110,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf } configs := civogo.NetworkConfig{ - Label: d.Get("label").(string), + Label: d.Get("name").(string), CIDRv4: d.Get("cidr_v4").(string), Region: apiClient.Region, NameserversV4: expandStringList(d.Get("nameservers_v4")), @@ -128,7 +122,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf // Retry the network creation using the utility function err := utils.RetryUntilSuccessOrTimeout(func() error { - log.Printf("[INFO] Attempting to create the network %s", d.Get("label").(string)) + log.Printf("[INFO] Attempting to create the network %s", d.Get("name").(string)) network, err := apiClient.CreateNetwork(configs) if err != nil { return err @@ -172,9 +166,8 @@ func resourceNetworkRead(_ context.Context, d *schema.ResourceData, m interface{ } } - d.Set("name", CurrentNetwork.Name) d.Set("region", apiClient.Region) - d.Set("label", CurrentNetwork.Label) + d.Set("name", CurrentNetwork.Label) d.Set("default", CurrentNetwork.Default) d.Set("cidr_v4", CurrentNetwork.CIDR) d.Set("nameservers_v4", CurrentNetwork.NameserversV4) @@ -191,9 +184,9 @@ func resourceNetworkUpdate(ctx context.Context, d *schema.ResourceData, m interf apiClient.Region = region.(string) } - if d.HasChange("label") { + if d.HasChange("name") { log.Printf("[INFO] updating the network %s", d.Id()) - _, err := apiClient.RenameNetwork(d.Get("label").(string), d.Id()) + _, err := apiClient.RenameNetwork(d.Get("name").(string), d.Id()) if err != nil { return diag.Errorf("[ERR] An error occurred while rename the network %s", d.Id()) }