diff --git a/internal/provider/group_resource.go b/internal/provider/group_resource.go index ab58c68..6c71b5b 100644 --- a/internal/provider/group_resource.go +++ b/internal/provider/group_resource.go @@ -158,7 +158,7 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, orgID := data.OrganizationID.ValueUUID() - tflog.Trace(ctx, "creating group") + tflog.Info(ctx, "creating group") group, err := client.CreateGroup(ctx, orgID, codersdk.CreateGroupRequest{ Name: data.Name.ValueString(), DisplayName: data.DisplayName.ValueString(), @@ -169,13 +169,13 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to create group, got error: %s", err)) return } - tflog.Trace(ctx, "successfully created group", map[string]any{ + tflog.Info(ctx, "successfully created group", map[string]any{ "id": group.ID.String(), }) data.ID = UUIDValue(group.ID) data.DisplayName = types.StringValue(group.DisplayName) - tflog.Trace(ctx, "setting group members") + tflog.Info(ctx, "setting group members") var members []string resp.Diagnostics.Append( data.Members.ElementsAs(ctx, &members, false)..., @@ -190,7 +190,7 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest, resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to add members to group, got error: %s", err)) return } - tflog.Trace(ctx, "successfully set group members") + tflog.Info(ctx, "successfully set group members") // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -270,7 +270,7 @@ func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest, } add, remove = memberDiff(curMembers, plannedMembers) } - tflog.Trace(ctx, "updating group", map[string]any{ + tflog.Info(ctx, "updating group", map[string]any{ "id": groupID, "new_members": add, "removed_members": remove, @@ -293,7 +293,7 @@ func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest, resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update group, got error: %s", err)) return } - tflog.Trace(ctx, "successfully updated group") + tflog.Info(ctx, "successfully updated group") // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) @@ -312,7 +312,7 @@ func (r *GroupResource) Delete(ctx context.Context, req resource.DeleteRequest, client := r.data.Client groupID := data.ID.ValueUUID() - tflog.Trace(ctx, "deleting group", map[string]any{ + tflog.Info(ctx, "deleting group", map[string]any{ "id": groupID, }) err := client.DeleteGroup(ctx, groupID) @@ -320,7 +320,7 @@ func (r *GroupResource) Delete(ctx context.Context, req resource.DeleteRequest, resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete group, got error: %s", err)) return } - tflog.Trace(ctx, "successfully deleted group") + tflog.Info(ctx, "successfully deleted group") } func (r *GroupResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { diff --git a/internal/provider/template_resource.go b/internal/provider/template_resource.go index 15c4932..8ef046f 100644 --- a/internal/provider/template_resource.go +++ b/internal/provider/template_resource.go @@ -492,7 +492,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques return } if idx == 0 { - tflog.Trace(ctx, "creating template") + tflog.Info(ctx, "creating template") createReq := data.toCreateRequest(ctx, resp, versionResp.ID) if resp.Diagnostics.HasError() { return @@ -502,7 +502,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to create template: %s", err)) return } - tflog.Trace(ctx, "successfully created template", map[string]any{ + tflog.Info(ctx, "successfully created template", map[string]any{ "id": templateResp.ID, }) @@ -514,7 +514,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques } if !data.ACL.IsNull() { - tflog.Trace(ctx, "updating template ACL") + tflog.Info(ctx, "updating template ACL") var acl ACL resp.Diagnostics.Append( data.ACL.As(ctx, &acl, basetypes.ObjectAsOptions{})..., @@ -527,7 +527,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to create template ACL: %s", err)) return } - tflog.Trace(ctx, "successfully updated template ACL") + tflog.Info(ctx, "successfully updated template ACL") } } if version.Active.ValueBool() { @@ -578,7 +578,7 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r } if !data.ACL.IsNull() { - tflog.Trace(ctx, "reading template ACL") + tflog.Info(ctx, "reading template ACL") acl, err := client.TemplateACL(ctx, templateID) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to get template ACL: %s", err)) @@ -591,7 +591,7 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r return } data.ACL = aclObj - tflog.Trace(ctx, "read template ACL") + tflog.Info(ctx, "read template ACL") } for idx, version := range data.Versions { @@ -653,7 +653,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques templateMetadataChanged := !newState.EqualTemplateMetadata(&curState) // This is required, as the API will reject no-diff updates. if templateMetadataChanged { - tflog.Trace(ctx, "change in template metadata detected, updating.") + tflog.Info(ctx, "change in template metadata detected, updating.") updateReq := newState.toUpdateRequest(ctx, resp) if resp.Diagnostics.HasError() { return @@ -664,7 +664,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques return } - tflog.Trace(ctx, "successfully updated template metadata") + tflog.Info(ctx, "successfully updated template metadata") } // Since the everyone group always gets deleted by `DisableEveryoneGroupAccess`, we need to run this even if there @@ -680,12 +680,12 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to update template ACL: %s", err)) return } - tflog.Trace(ctx, "successfully updated template ACL") + tflog.Info(ctx, "successfully updated template ACL") } for idx := range newState.Versions { if newState.Versions[idx].ID.IsUnknown() { - tflog.Trace(ctx, "discovered a new or modified template version") + tflog.Info(ctx, "discovered a new or modified template version") uploadResp, err := newVersion(ctx, client, newVersionRequest{ Version: &newState.Versions[idx], OrganizationID: orgID, @@ -761,7 +761,7 @@ func (r *TemplateResource) Delete(ctx context.Context, req resource.DeleteReques templateID := data.ID.ValueUUID() - tflog.Trace(ctx, "deleting template") + tflog.Info(ctx, "deleting template") err := client.DeleteTemplate(ctx, templateID) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to delete template: %s", err)) @@ -927,7 +927,7 @@ func waitForJob(ctx context.Context, client *codersdk.Client, version *codersdk. if !ok { break } - tflog.Trace(ctx, logs.Output, map[string]interface{}{ + tflog.Info(ctx, logs.Output, map[string]interface{}{ "job_id": logs.ID, "job_stage": logs.Stage, "log_source": logs.Source, @@ -959,13 +959,13 @@ type newVersionRequest struct { func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequest) (*codersdk.TemplateVersion, error) { directory := req.Version.Directory.ValueString() - tflog.Trace(ctx, "uploading directory") + tflog.Info(ctx, "uploading directory") uploadResp, err := uploadDirectory(ctx, client, slog.Make(newTFLogSink(ctx)), directory) if err != nil { return nil, fmt.Errorf("failed to upload directory: %s", err) } - tflog.Trace(ctx, "successfully uploaded directory") - tflog.Trace(ctx, "discovering and parsing vars files") + tflog.Info(ctx, "successfully uploaded directory") + tflog.Info(ctx, "discovering and parsing vars files") varFiles, err := codersdk.DiscoverVarsFiles(directory) if err != nil { return nil, fmt.Errorf("failed to discover vars files: %s", err) @@ -974,7 +974,7 @@ func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequ if err != nil { return nil, fmt.Errorf("failed to parse user variable values: %s", err) } - tflog.Trace(ctx, "discovered and parsed vars files", map[string]any{ + tflog.Info(ctx, "discovered and parsed vars files", map[string]any{ "vars": vars, }) for _, variable := range req.Version.TerraformVariables { @@ -994,22 +994,22 @@ func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequ if req.TemplateID != nil { tmplVerReq.TemplateID = *req.TemplateID } - tflog.Trace(ctx, "creating template version") + tflog.Info(ctx, "creating template version") versionResp, err := client.CreateTemplateVersion(ctx, req.OrganizationID, tmplVerReq) if err != nil { return nil, fmt.Errorf("failed to create template version: %s", err) } - tflog.Trace(ctx, "waiting for template version import job.") + tflog.Info(ctx, "waiting for template version import job.") err = waitForJob(ctx, client, &versionResp) if err != nil { return nil, fmt.Errorf("failed to wait for job: %s", err) } - tflog.Trace(ctx, "successfully created template version") + tflog.Info(ctx, "successfully created template version") return &versionResp, nil } func markActive(ctx context.Context, client *codersdk.Client, templateID uuid.UUID, versionID uuid.UUID) error { - tflog.Trace(ctx, "marking template version as active", map[string]any{ + tflog.Info(ctx, "marking template version as active", map[string]any{ "version_id": versionID.String(), "template_id": templateID.String(), }) @@ -1019,7 +1019,7 @@ func markActive(ctx context.Context, client *codersdk.Client, templateID uuid.UU if err != nil { return fmt.Errorf("Failed to update active template version: %s", err) } - tflog.Trace(ctx, "marked template version as active") + tflog.Info(ctx, "marked template version as active") return nil } diff --git a/internal/provider/user_resource.go b/internal/provider/user_resource.go index e92e2c4..3eee654 100644 --- a/internal/provider/user_resource.go +++ b/internal/provider/user_resource.go @@ -159,7 +159,7 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r return } - tflog.Trace(ctx, "creating user") + tflog.Info(ctx, "creating user") loginType := codersdk.LoginType(data.LoginType.ValueString()) if loginType == codersdk.LoginTypePassword && data.Password.IsNull() { resp.Diagnostics.AddError("Data Error", "Password is required when login_type is 'password'") @@ -180,12 +180,12 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to create user, got error: %s", err)) return } - tflog.Trace(ctx, "successfully created user", map[string]any{ + tflog.Info(ctx, "successfully created user", map[string]any{ "id": user.ID.String(), }) data.ID = UUIDValue(user.ID) - tflog.Trace(ctx, "updating user profile") + tflog.Info(ctx, "updating user profile") name := data.Username if data.Name.ValueString() != "" { name = data.Name @@ -198,14 +198,14 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update newly created user profile, got error: %s", err)) return } - tflog.Trace(ctx, "successfully updated user profile") + tflog.Info(ctx, "successfully updated user profile") data.Name = types.StringValue(user.Name) var roles []string resp.Diagnostics.Append( data.Roles.ElementsAs(ctx, &roles, false)..., ) - tflog.Trace(ctx, "updating user roles", map[string]any{ + tflog.Info(ctx, "updating user roles", map[string]any{ "new_roles": roles, }) user, err = client.UpdateUserRoles(ctx, user.ID.String(), codersdk.UpdateRoles{ @@ -215,7 +215,7 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update newly created user roles, got error: %s", err)) return } - tflog.Trace(ctx, "successfully updated user roles") + tflog.Info(ctx, "successfully updated user roles") if data.Suspended.ValueBool() { _, err = client.UpdateUserStatus(ctx, data.ID.ValueString(), codersdk.UserStatus("suspended")) @@ -291,7 +291,7 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r if data.Name.ValueString() != "" { name = data.Name } - tflog.Trace(ctx, "updating user", map[string]any{ + tflog.Info(ctx, "updating user", map[string]any{ "new_username": data.Username.ValueString(), "new_name": name.ValueString(), }) @@ -304,13 +304,13 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r return } data.Name = name - tflog.Trace(ctx, "successfully updated user profile") + tflog.Info(ctx, "successfully updated user profile") var roles []string resp.Diagnostics.Append( data.Roles.ElementsAs(ctx, &roles, false)..., ) - tflog.Trace(ctx, "updating user roles", map[string]any{ + tflog.Info(ctx, "updating user roles", map[string]any{ "new_roles": roles, }) _, err = client.UpdateUserRoles(ctx, user.ID.String(), codersdk.UpdateRoles{ @@ -320,10 +320,10 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update user roles, got error: %s", err)) return } - tflog.Trace(ctx, "successfully updated user roles") + tflog.Info(ctx, "successfully updated user roles") if data.LoginType.ValueString() == string(codersdk.LoginTypePassword) && !data.Password.IsNull() { - tflog.Trace(ctx, "updating password") + tflog.Info(ctx, "updating password") err = client.UpdateUserPassword(ctx, user.ID.String(), codersdk.UpdateUserPasswordRequest{ Password: data.Password.ValueString(), }) @@ -331,7 +331,7 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to update password, got error: %s", err)) return } - tflog.Trace(ctx, "successfully updated password") + tflog.Info(ctx, "successfully updated password") } var statusErr error @@ -362,13 +362,13 @@ func (r *UserResource) Delete(ctx context.Context, req resource.DeleteRequest, r client := r.data.Client - tflog.Trace(ctx, "deleting user") + tflog.Info(ctx, "deleting user") err := client.DeleteUser(ctx, data.ID.ValueUUID()) if err != nil { resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete user, got error: %s", err)) return } - tflog.Trace(ctx, "successfully deleted user") + tflog.Info(ctx, "successfully deleted user") } func (r *UserResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {