Skip to content

Commit b24e713

Browse files
committed
change label to name
1 parent b13b827 commit b24e713

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

civo/network/resource_network.go

+7-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func ResourceNetwork() *schema.Resource {
1818
return &schema.Resource{
1919
Description: "Provides a Civo network resource. This can be used to create, modify, and delete networks.",
2020
Schema: map[string]*schema.Schema{
21-
"label": {
21+
"name": {
2222
Type: schema.TypeString,
2323
Required: true,
2424
Description: "Name for the network",
@@ -43,12 +43,6 @@ func ResourceNetwork() *schema.Resource {
4343
},
4444
Description: "List of nameservers for the network",
4545
},
46-
// Computed resource
47-
"name": {
48-
Type: schema.TypeString,
49-
Computed: true,
50-
Description: "The name of the network",
51-
},
5246
"default": {
5347
Type: schema.TypeBool,
5448
Computed: true,
@@ -105,7 +99,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
10599
apiClient.Region = region.(string)
106100
}
107101

108-
log.Printf("[INFO] creating the new network %s", d.Get("label").(string))
102+
log.Printf("[INFO] creating the new network %s", d.Get("name").(string))
109103
vlanConfig := civogo.VLANConnectConfig{
110104
VlanID: d.Get("vlan_id").(int),
111105
PhysicalInterface: d.Get("vlan_physical_interface").(string),
@@ -116,7 +110,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
116110
}
117111

118112
configs := civogo.NetworkConfig{
119-
Label: d.Get("label").(string),
113+
Label: d.Get("name").(string),
120114
CIDRv4: d.Get("cidr_v4").(string),
121115
Region: apiClient.Region,
122116
NameserversV4: expandStringList(d.Get("nameservers_v4")),
@@ -128,7 +122,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
128122

129123
// Retry the network creation using the utility function
130124
err := utils.RetryUntilSuccessOrTimeout(func() error {
131-
log.Printf("[INFO] Attempting to create the network %s", d.Get("label").(string))
125+
log.Printf("[INFO] Attempting to create the network %s", d.Get("name").(string))
132126
network, err := apiClient.CreateNetwork(configs)
133127
if err != nil {
134128
return err
@@ -172,9 +166,8 @@ func resourceNetworkRead(_ context.Context, d *schema.ResourceData, m interface{
172166
}
173167
}
174168

175-
d.Set("name", CurrentNetwork.Name)
176169
d.Set("region", apiClient.Region)
177-
d.Set("label", CurrentNetwork.Label)
170+
d.Set("name", CurrentNetwork.Label)
178171
d.Set("default", CurrentNetwork.Default)
179172
d.Set("cidr_v4", CurrentNetwork.CIDR)
180173
d.Set("nameservers_v4", CurrentNetwork.NameserversV4)
@@ -191,9 +184,9 @@ func resourceNetworkUpdate(ctx context.Context, d *schema.ResourceData, m interf
191184
apiClient.Region = region.(string)
192185
}
193186

194-
if d.HasChange("label") {
187+
if d.HasChange("name") {
195188
log.Printf("[INFO] updating the network %s", d.Id())
196-
_, err := apiClient.RenameNetwork(d.Get("label").(string), d.Id())
189+
_, err := apiClient.RenameNetwork(d.Get("name").(string), d.Id())
197190
if err != nil {
198191
return diag.Errorf("[ERR] An error occurred while rename the network %s", d.Id())
199192
}

0 commit comments

Comments
 (0)