@@ -18,7 +18,7 @@ func ResourceNetwork() *schema.Resource {
18
18
return & schema.Resource {
19
19
Description : "Provides a Civo network resource. This can be used to create, modify, and delete networks." ,
20
20
Schema : map [string ]* schema.Schema {
21
- "label " : {
21
+ "name " : {
22
22
Type : schema .TypeString ,
23
23
Required : true ,
24
24
Description : "Name for the network" ,
@@ -43,12 +43,6 @@ func ResourceNetwork() *schema.Resource {
43
43
},
44
44
Description : "List of nameservers for the network" ,
45
45
},
46
- // Computed resource
47
- "name" : {
48
- Type : schema .TypeString ,
49
- Computed : true ,
50
- Description : "The name of the network" ,
51
- },
52
46
"default" : {
53
47
Type : schema .TypeBool ,
54
48
Computed : true ,
@@ -105,7 +99,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
105
99
apiClient .Region = region .(string )
106
100
}
107
101
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 ))
109
103
vlanConfig := civogo.VLANConnectConfig {
110
104
VlanID : d .Get ("vlan_id" ).(int ),
111
105
PhysicalInterface : d .Get ("vlan_physical_interface" ).(string ),
@@ -116,7 +110,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
116
110
}
117
111
118
112
configs := civogo.NetworkConfig {
119
- Label : d .Get ("label " ).(string ),
113
+ Label : d .Get ("name " ).(string ),
120
114
CIDRv4 : d .Get ("cidr_v4" ).(string ),
121
115
Region : apiClient .Region ,
122
116
NameserversV4 : expandStringList (d .Get ("nameservers_v4" )),
@@ -128,7 +122,7 @@ func resourceNetworkCreate(ctx context.Context, d *schema.ResourceData, m interf
128
122
129
123
// Retry the network creation using the utility function
130
124
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 ))
132
126
network , err := apiClient .CreateNetwork (configs )
133
127
if err != nil {
134
128
return err
@@ -172,9 +166,8 @@ func resourceNetworkRead(_ context.Context, d *schema.ResourceData, m interface{
172
166
}
173
167
}
174
168
175
- d .Set ("name" , CurrentNetwork .Name )
176
169
d .Set ("region" , apiClient .Region )
177
- d .Set ("label " , CurrentNetwork .Label )
170
+ d .Set ("name " , CurrentNetwork .Label )
178
171
d .Set ("default" , CurrentNetwork .Default )
179
172
d .Set ("cidr_v4" , CurrentNetwork .CIDR )
180
173
d .Set ("nameservers_v4" , CurrentNetwork .NameserversV4 )
@@ -191,9 +184,9 @@ func resourceNetworkUpdate(ctx context.Context, d *schema.ResourceData, m interf
191
184
apiClient .Region = region .(string )
192
185
}
193
186
194
- if d .HasChange ("label " ) {
187
+ if d .HasChange ("name " ) {
195
188
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 ())
197
190
if err != nil {
198
191
return diag .Errorf ("[ERR] An error occurred while rename the network %s" , d .Id ())
199
192
}
0 commit comments