@@ -82,6 +82,11 @@ func resourceScalewayContainerNamespaceCreate(ctx context.Context, d *schema.Res
82
82
83
83
d .SetId (newRegionalIDString (region , ns .ID ))
84
84
85
+ _ , err = waitForContainerNamespace (ctx , api , region , ns .ID , d .Timeout (schema .TimeoutCreate ))
86
+ if err != nil {
87
+ return diag .FromErr (err )
88
+ }
89
+
85
90
return resourceScalewayContainerNamespaceRead (ctx , d , meta )
86
91
}
87
92
@@ -91,12 +96,7 @@ func resourceScalewayContainerNamespaceRead(ctx context.Context, d *schema.Resou
91
96
return diag .FromErr (err )
92
97
}
93
98
94
- ns , err := api .WaitForNamespace (& container.WaitForNamespaceRequest {
95
- Region : region ,
96
- NamespaceID : id ,
97
- RetryInterval : DefaultWaitRetryInterval ,
98
- }, scw .WithContext (ctx ))
99
-
99
+ ns , err := waitForContainerNamespace (ctx , api , region , id , d .Timeout (schema .TimeoutRead ))
100
100
if err != nil {
101
101
if is404Error (err ) {
102
102
d .SetId ("" )
@@ -123,17 +123,13 @@ func resourceScalewayContainerNamespaceUpdate(ctx context.Context, d *schema.Res
123
123
return diag .FromErr (err )
124
124
}
125
125
126
- ns , err := api .WaitForNamespace (& container.WaitForNamespaceRequest {
127
- Region : region ,
128
- NamespaceID : id ,
129
- RetryInterval : DefaultWaitRetryInterval ,
130
- }, scw .WithContext (ctx ))
126
+ ns , err := waitForContainerNamespace (ctx , api , region , id , d .Timeout (schema .TimeoutUpdate ))
131
127
if err != nil {
132
128
return diag .FromErr (err )
133
129
}
134
130
135
131
req := & container.UpdateNamespaceRequest {
136
- Region : region ,
132
+ Region : ns . Region ,
137
133
NamespaceID : ns .ID ,
138
134
}
139
135
@@ -159,11 +155,7 @@ func resourceScalewayContainerNamespaceDelete(ctx context.Context, d *schema.Res
159
155
return diag .FromErr (err )
160
156
}
161
157
162
- _ , err = api .WaitForNamespace (& container.WaitForNamespaceRequest {
163
- Region : region ,
164
- NamespaceID : id ,
165
- RetryInterval : DefaultWaitRetryInterval ,
166
- }, scw .WithContext (ctx ))
158
+ _ , err = waitForContainerNamespace (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
167
159
if err != nil {
168
160
if is404Error (err ) {
169
161
d .SetId ("" )
@@ -176,21 +168,18 @@ func resourceScalewayContainerNamespaceDelete(ctx context.Context, d *schema.Res
176
168
Region : region ,
177
169
NamespaceID : id ,
178
170
}, scw .WithContext (ctx ))
179
-
180
171
if err != nil && ! is404Error (err ) {
181
172
return diag .FromErr (err )
182
173
}
183
174
184
- _ , err = api .WaitForNamespace (& container.WaitForNamespaceRequest {
185
- Region : region ,
186
- NamespaceID : id ,
187
- }, scw .WithContext (ctx ))
175
+ _ , err = waitForContainerNamespace (ctx , api , region , id , d .Timeout (schema .TimeoutDelete ))
188
176
if err != nil {
189
177
if is404Error (err ) {
190
178
d .SetId ("" )
191
179
return nil
192
180
}
193
181
return diag .FromErr (err )
194
182
}
183
+
195
184
return nil
196
185
}
0 commit comments