@@ -160,8 +160,8 @@ func (r *resourceExtensionServiceNow) Update(ctx context.Context, req resource.U
160
160
model , err = r .requestGetExtensionServiceNow (ctx , requestGetExtensionServiceNowOptions {
161
161
ID : plan .ID ,
162
162
RetryNotFound : true ,
163
- SnowPassword : extractString (ctx , req .State , "snow_password" , & resp .Diagnostics ),
164
- EndpointURL : extractString (ctx , req .State , "endpoint_url" , & resp .Diagnostics ),
163
+ SnowPassword : extractString (ctx , req .Plan , "snow_password" , & resp .Diagnostics ),
164
+ EndpointURL : extractString (ctx , req .Plan , "endpoint_url" , & resp .Diagnostics ),
165
165
Diagnostics : & resp .Diagnostics ,
166
166
})
167
167
if err != nil {
@@ -199,8 +199,6 @@ func (r *resourceExtensionServiceNow) Configure(ctx context.Context, req resourc
199
199
}
200
200
201
201
func (r * resourceExtensionServiceNow ) ImportState (ctx context.Context , req resource.ImportStateRequest , resp * resource.ImportStateResponse ) {
202
- // resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
203
-
204
202
model , err := r .requestGetExtensionServiceNow (ctx , requestGetExtensionServiceNowOptions {
205
203
ID : req .ID ,
206
204
RetryNotFound : false ,
@@ -212,10 +210,6 @@ func (r *resourceExtensionServiceNow) ImportState(ctx context.Context, req resou
212
210
}
213
211
return
214
212
}
215
-
216
- // model.EndpointURL
217
- // model.ExtensionObjects = []string{extension.ExtensionObjects[0].ID}
218
- // model.ExtensionSchema
219
213
resp .Diagnostics .Append (resp .State .Set (ctx , & model )... )
220
214
}
221
215
@@ -313,22 +307,25 @@ func flattenExtensionServiceNow(src *pagerduty.Extension, snowPassword *string,
313
307
model := resourceExtensionServiceNowModel {
314
308
ID : types .StringValue (src .ID ),
315
309
Name : types .StringValue (src .Name ),
316
- EndpointURL : types .StringValue (src .EndpointURL ),
317
310
HTMLURL : types .StringValue (src .HTMLURL ),
318
311
ExtensionSchema : types .StringValue (src .ExtensionSchema .ID ),
319
312
ExtensionObjects : flattenExtensionServiceNowObjects (src .ExtensionObjects ),
320
313
}
321
314
322
315
b , _ := json .Marshal (src .Config )
323
316
var config PagerDutyExtensionServiceNowConfig
324
- json .Unmarshal (b , & config )
317
+ _ = json .Unmarshal (b , & config )
325
318
326
319
model .SnowUser = types .StringValue (config .User )
327
320
if snowPassword != nil {
328
321
model .SnowPassword = types .StringValue (* snowPassword )
322
+ } else if config .Password != "" {
323
+ model .SnowPassword = types .StringValue (config .Password )
329
324
}
330
325
if endpointURL != nil {
331
- model .SnowPassword = types .StringValue (* endpointURL )
326
+ model .EndpointURL = types .StringValue (* endpointURL )
327
+ } else if src .EndpointURL != "" {
328
+ model .EndpointURL = types .StringValue (src .EndpointURL )
332
329
}
333
330
model .SyncOptions = types .StringValue (config .SyncOptions )
334
331
model .Target = types .StringValue (config .Target )
0 commit comments