@@ -51,7 +51,7 @@ func (*userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *r
5151 Description : "Manages a Managed User." ,
5252 Attributes : map [string ]schema.Attribute {
5353 "id" : schema.StringAttribute {
54- Description : "User's username ." ,
54+ Description : "Username of the User ." ,
5555 Computed : true ,
5656 PlanModifiers : []planmodifier.String {
5757 stringplanmodifier .UseStateForUnknown (),
@@ -88,7 +88,7 @@ func (*userResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *r
8888 Computed : true ,
8989 },
9090 "password" : schema.StringAttribute {
91- Description : "Updated password to set for the user ." ,
91+ Description : "Updated password to set for the User ." ,
9292 Sensitive : true ,
9393 Computed : true ,
9494 Optional : true ,
@@ -200,13 +200,6 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
200200 )
201201 return
202202 }
203- if user == nil {
204- resp .Diagnostics .AddError (
205- "Unable to locate managed user" ,
206- "Could not find managed user with username: " + username ,
207- )
208- return
209- }
210203 newState := userResourceModel {
211204 ID : types .StringValue (user .Username ),
212205 Username : types .StringValue (user .Username ),
@@ -219,14 +212,14 @@ func (r *userResource) Read(ctx context.Context, req resource.ReadRequest, resp
219212 }
220213
221214 // Update state.
222- diags = resp .State .Set (ctx , & newState )
215+ diags = resp .State .Set (ctx , newState )
223216 resp .Diagnostics .Append (diags ... )
224217 if resp .Diagnostics .HasError () {
225218 return
226219 }
227220 tflog .Debug (ctx , "Read Managed User" , map [string ]any {
228221 "id" : state .ID .ValueString (),
229- "username" : state .ID .ValueString (),
222+ "username" : state .Username .ValueString (),
230223 "fullname" : state .Fullname .ValueString (),
231224 "email" : state .Email .ValueString (),
232225 "password" : state .Password .ValueString (),
@@ -322,7 +315,14 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
322315
323316 // Execute.
324317 tflog .Debug (ctx , "Deleting Managed User" , map [string ]any {
325- "id" : user .Username ,
318+ "id" : user .Username ,
319+ "username" : state .Username .ValueString (),
320+ "fullname" : state .Fullname .ValueString (),
321+ "email" : state .Email .ValueString (),
322+ "password" : state .Password .ValueString (),
323+ "suspended" : state .Suspended .ValueBool (),
324+ "force_password_change" : state .ForcePasswordChange .ValueBool (),
325+ "password_expires" : state .PasswordExpires .ValueBool (),
326326 })
327327 err := r .client .User .DeleteManaged (ctx , user )
328328 if err != nil {
@@ -333,7 +333,14 @@ func (r *userResource) Delete(ctx context.Context, req resource.DeleteRequest, r
333333 return
334334 }
335335 tflog .Debug (ctx , "Deleted Managed User" , map [string ]any {
336- "id" : state .ID .ValueString (),
336+ "id" : state .ID .ValueString (),
337+ "username" : state .Username .ValueString (),
338+ "fullname" : state .Fullname .ValueString (),
339+ "email" : state .Email .ValueString (),
340+ "password" : state .Password .ValueString (),
341+ "suspended" : state .Suspended .ValueBool (),
342+ "force_password_change" : state .ForcePasswordChange .ValueBool (),
343+ "password_expires" : state .PasswordExpires .ValueBool (),
337344 })
338345}
339346
0 commit comments