Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdfa7472

Browse files
chore: tflog trace -> info (#74)
1 parent1a38271 commitdfa7472

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

‎internal/provider/group_resource.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest,
158158

159159
orgID:=data.OrganizationID.ValueUUID()
160160

161-
tflog.Trace(ctx,"creating group")
161+
tflog.Info(ctx,"creating group")
162162
group,err:=client.CreateGroup(ctx,orgID, codersdk.CreateGroupRequest{
163163
Name:data.Name.ValueString(),
164164
DisplayName:data.DisplayName.ValueString(),
@@ -169,13 +169,13 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest,
169169
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to create group, got error: %s",err))
170170
return
171171
}
172-
tflog.Trace(ctx,"successfully created group",map[string]any{
172+
tflog.Info(ctx,"successfully created group",map[string]any{
173173
"id":group.ID.String(),
174174
})
175175
data.ID=UUIDValue(group.ID)
176176
data.DisplayName=types.StringValue(group.DisplayName)
177177

178-
tflog.Trace(ctx,"setting group members")
178+
tflog.Info(ctx,"setting group members")
179179
varmembers []string
180180
resp.Diagnostics.Append(
181181
data.Members.ElementsAs(ctx,&members,false)...,
@@ -190,7 +190,7 @@ func (r *GroupResource) Create(ctx context.Context, req resource.CreateRequest,
190190
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to add members to group, got error: %s",err))
191191
return
192192
}
193-
tflog.Trace(ctx,"successfully set group members")
193+
tflog.Info(ctx,"successfully set group members")
194194

195195
// Save data into Terraform state
196196
resp.Diagnostics.Append(resp.State.Set(ctx,&data)...)
@@ -270,7 +270,7 @@ func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest,
270270
}
271271
add,remove=memberDiff(curMembers,plannedMembers)
272272
}
273-
tflog.Trace(ctx,"updating group",map[string]any{
273+
tflog.Info(ctx,"updating group",map[string]any{
274274
"id":groupID,
275275
"new_members":add,
276276
"removed_members":remove,
@@ -293,7 +293,7 @@ func (r *GroupResource) Update(ctx context.Context, req resource.UpdateRequest,
293293
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to update group, got error: %s",err))
294294
return
295295
}
296-
tflog.Trace(ctx,"successfully updated group")
296+
tflog.Info(ctx,"successfully updated group")
297297

298298
// Save updated data into Terraform state
299299
resp.Diagnostics.Append(resp.State.Set(ctx,&data)...)
@@ -312,15 +312,15 @@ func (r *GroupResource) Delete(ctx context.Context, req resource.DeleteRequest,
312312
client:=r.data.Client
313313
groupID:=data.ID.ValueUUID()
314314

315-
tflog.Trace(ctx,"deleting group",map[string]any{
315+
tflog.Info(ctx,"deleting group",map[string]any{
316316
"id":groupID,
317317
})
318318
err:=client.DeleteGroup(ctx,groupID)
319319
iferr!=nil {
320320
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to delete group, got error: %s",err))
321321
return
322322
}
323-
tflog.Trace(ctx,"successfully deleted group")
323+
tflog.Info(ctx,"successfully deleted group")
324324
}
325325

326326
func (r*GroupResource)ImportState(ctx context.Context,req resource.ImportStateRequest,resp*resource.ImportStateResponse) {

‎internal/provider/template_resource.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
492492
return
493493
}
494494
ifidx==0 {
495-
tflog.Trace(ctx,"creating template")
495+
tflog.Info(ctx,"creating template")
496496
createReq:=data.toCreateRequest(ctx,resp,versionResp.ID)
497497
ifresp.Diagnostics.HasError() {
498498
return
@@ -502,7 +502,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
502502
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Failed to create template: %s",err))
503503
return
504504
}
505-
tflog.Trace(ctx,"successfully created template",map[string]any{
505+
tflog.Info(ctx,"successfully created template",map[string]any{
506506
"id":templateResp.ID,
507507
})
508508

@@ -514,7 +514,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
514514
}
515515

516516
if!data.ACL.IsNull() {
517-
tflog.Trace(ctx,"updating template ACL")
517+
tflog.Info(ctx,"updating template ACL")
518518
varaclACL
519519
resp.Diagnostics.Append(
520520
data.ACL.As(ctx,&acl, basetypes.ObjectAsOptions{})...,
@@ -527,7 +527,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
527527
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Failed to create template ACL: %s",err))
528528
return
529529
}
530-
tflog.Trace(ctx,"successfully updated template ACL")
530+
tflog.Info(ctx,"successfully updated template ACL")
531531
}
532532
}
533533
ifversion.Active.ValueBool() {
@@ -578,7 +578,7 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r
578578
}
579579

580580
if!data.ACL.IsNull() {
581-
tflog.Trace(ctx,"reading template ACL")
581+
tflog.Info(ctx,"reading template ACL")
582582
acl,err:=client.TemplateACL(ctx,templateID)
583583
iferr!=nil {
584584
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
591591
return
592592
}
593593
data.ACL=aclObj
594-
tflog.Trace(ctx,"read template ACL")
594+
tflog.Info(ctx,"read template ACL")
595595
}
596596

597597
foridx,version:=rangedata.Versions {
@@ -653,7 +653,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
653653
templateMetadataChanged:=!newState.EqualTemplateMetadata(&curState)
654654
// This is required, as the API will reject no-diff updates.
655655
iftemplateMetadataChanged {
656-
tflog.Trace(ctx,"change in template metadata detected, updating.")
656+
tflog.Info(ctx,"change in template metadata detected, updating.")
657657
updateReq:=newState.toUpdateRequest(ctx,resp)
658658
ifresp.Diagnostics.HasError() {
659659
return
@@ -664,7 +664,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
664664
return
665665
}
666666

667-
tflog.Trace(ctx,"successfully updated template metadata")
667+
tflog.Info(ctx,"successfully updated template metadata")
668668
}
669669

670670
// 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
680680
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Failed to update template ACL: %s",err))
681681
return
682682
}
683-
tflog.Trace(ctx,"successfully updated template ACL")
683+
tflog.Info(ctx,"successfully updated template ACL")
684684
}
685685

686686
foridx:=rangenewState.Versions {
687687
ifnewState.Versions[idx].ID.IsUnknown() {
688-
tflog.Trace(ctx,"discovered a new or modified template version")
688+
tflog.Info(ctx,"discovered a new or modified template version")
689689
uploadResp,err:=newVersion(ctx,client,newVersionRequest{
690690
Version:&newState.Versions[idx],
691691
OrganizationID:orgID,
@@ -761,7 +761,7 @@ func (r *TemplateResource) Delete(ctx context.Context, req resource.DeleteReques
761761

762762
templateID:=data.ID.ValueUUID()
763763

764-
tflog.Trace(ctx,"deleting template")
764+
tflog.Info(ctx,"deleting template")
765765
err:=client.DeleteTemplate(ctx,templateID)
766766
iferr!=nil {
767767
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.
927927
if!ok {
928928
break
929929
}
930-
tflog.Trace(ctx,logs.Output,map[string]interface{}{
930+
tflog.Info(ctx,logs.Output,map[string]interface{}{
931931
"job_id":logs.ID,
932932
"job_stage":logs.Stage,
933933
"log_source":logs.Source,
@@ -959,13 +959,13 @@ type newVersionRequest struct {
959959

960960
funcnewVersion(ctx context.Context,client*codersdk.Client,reqnewVersionRequest) (*codersdk.TemplateVersion,error) {
961961
directory:=req.Version.Directory.ValueString()
962-
tflog.Trace(ctx,"uploading directory")
962+
tflog.Info(ctx,"uploading directory")
963963
uploadResp,err:=uploadDirectory(ctx,client,slog.Make(newTFLogSink(ctx)),directory)
964964
iferr!=nil {
965965
returnnil,fmt.Errorf("failed to upload directory: %s",err)
966966
}
967-
tflog.Trace(ctx,"successfully uploaded directory")
968-
tflog.Trace(ctx,"discovering and parsing vars files")
967+
tflog.Info(ctx,"successfully uploaded directory")
968+
tflog.Info(ctx,"discovering and parsing vars files")
969969
varFiles,err:=codersdk.DiscoverVarsFiles(directory)
970970
iferr!=nil {
971971
returnnil,fmt.Errorf("failed to discover vars files: %s",err)
@@ -974,7 +974,7 @@ func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequ
974974
iferr!=nil {
975975
returnnil,fmt.Errorf("failed to parse user variable values: %s",err)
976976
}
977-
tflog.Trace(ctx,"discovered and parsed vars files",map[string]any{
977+
tflog.Info(ctx,"discovered and parsed vars files",map[string]any{
978978
"vars":vars,
979979
})
980980
for_,variable:=rangereq.Version.TerraformVariables {
@@ -994,22 +994,22 @@ func newVersion(ctx context.Context, client *codersdk.Client, req newVersionRequ
994994
ifreq.TemplateID!=nil {
995995
tmplVerReq.TemplateID=*req.TemplateID
996996
}
997-
tflog.Trace(ctx,"creating template version")
997+
tflog.Info(ctx,"creating template version")
998998
versionResp,err:=client.CreateTemplateVersion(ctx,req.OrganizationID,tmplVerReq)
999999
iferr!=nil {
10001000
returnnil,fmt.Errorf("failed to create template version: %s",err)
10011001
}
1002-
tflog.Trace(ctx,"waiting for template version import job.")
1002+
tflog.Info(ctx,"waiting for template version import job.")
10031003
err=waitForJob(ctx,client,&versionResp)
10041004
iferr!=nil {
10051005
returnnil,fmt.Errorf("failed to wait for job: %s",err)
10061006
}
1007-
tflog.Trace(ctx,"successfully created template version")
1007+
tflog.Info(ctx,"successfully created template version")
10081008
return&versionResp,nil
10091009
}
10101010

10111011
funcmarkActive(ctx context.Context,client*codersdk.Client,templateID uuid.UUID,versionID uuid.UUID)error {
1012-
tflog.Trace(ctx,"marking template version as active",map[string]any{
1012+
tflog.Info(ctx,"marking template version as active",map[string]any{
10131013
"version_id":versionID.String(),
10141014
"template_id":templateID.String(),
10151015
})
@@ -1019,7 +1019,7 @@ func markActive(ctx context.Context, client *codersdk.Client, templateID uuid.UU
10191019
iferr!=nil {
10201020
returnfmt.Errorf("Failed to update active template version: %s",err)
10211021
}
1022-
tflog.Trace(ctx,"marked template version as active")
1022+
tflog.Info(ctx,"marked template version as active")
10231023
returnnil
10241024
}
10251025

‎internal/provider/user_resource.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r
159159
return
160160
}
161161

162-
tflog.Trace(ctx,"creating user")
162+
tflog.Info(ctx,"creating user")
163163
loginType:=codersdk.LoginType(data.LoginType.ValueString())
164164
ifloginType==codersdk.LoginTypePassword&&data.Password.IsNull() {
165165
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
180180
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to create user, got error: %s",err))
181181
return
182182
}
183-
tflog.Trace(ctx,"successfully created user",map[string]any{
183+
tflog.Info(ctx,"successfully created user",map[string]any{
184184
"id":user.ID.String(),
185185
})
186186
data.ID=UUIDValue(user.ID)
187187

188-
tflog.Trace(ctx,"updating user profile")
188+
tflog.Info(ctx,"updating user profile")
189189
name:=data.Username
190190
ifdata.Name.ValueString()!="" {
191191
name=data.Name
@@ -198,14 +198,14 @@ func (r *UserResource) Create(ctx context.Context, req resource.CreateRequest, r
198198
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to update newly created user profile, got error: %s",err))
199199
return
200200
}
201-
tflog.Trace(ctx,"successfully updated user profile")
201+
tflog.Info(ctx,"successfully updated user profile")
202202
data.Name=types.StringValue(user.Name)
203203

204204
varroles []string
205205
resp.Diagnostics.Append(
206206
data.Roles.ElementsAs(ctx,&roles,false)...,
207207
)
208-
tflog.Trace(ctx,"updating user roles",map[string]any{
208+
tflog.Info(ctx,"updating user roles",map[string]any{
209209
"new_roles":roles,
210210
})
211211
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
215215
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to update newly created user roles, got error: %s",err))
216216
return
217217
}
218-
tflog.Trace(ctx,"successfully updated user roles")
218+
tflog.Info(ctx,"successfully updated user roles")
219219

220220
ifdata.Suspended.ValueBool() {
221221
_,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
291291
ifdata.Name.ValueString()!="" {
292292
name=data.Name
293293
}
294-
tflog.Trace(ctx,"updating user",map[string]any{
294+
tflog.Info(ctx,"updating user",map[string]any{
295295
"new_username":data.Username.ValueString(),
296296
"new_name":name.ValueString(),
297297
})
@@ -304,13 +304,13 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r
304304
return
305305
}
306306
data.Name=name
307-
tflog.Trace(ctx,"successfully updated user profile")
307+
tflog.Info(ctx,"successfully updated user profile")
308308

309309
varroles []string
310310
resp.Diagnostics.Append(
311311
data.Roles.ElementsAs(ctx,&roles,false)...,
312312
)
313-
tflog.Trace(ctx,"updating user roles",map[string]any{
313+
tflog.Info(ctx,"updating user roles",map[string]any{
314314
"new_roles":roles,
315315
})
316316
_,err=client.UpdateUserRoles(ctx,user.ID.String(), codersdk.UpdateRoles{
@@ -320,18 +320,18 @@ func (r *UserResource) Update(ctx context.Context, req resource.UpdateRequest, r
320320
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to update user roles, got error: %s",err))
321321
return
322322
}
323-
tflog.Trace(ctx,"successfully updated user roles")
323+
tflog.Info(ctx,"successfully updated user roles")
324324

325325
ifdata.LoginType.ValueString()==string(codersdk.LoginTypePassword)&&!data.Password.IsNull() {
326-
tflog.Trace(ctx,"updating password")
326+
tflog.Info(ctx,"updating password")
327327
err=client.UpdateUserPassword(ctx,user.ID.String(), codersdk.UpdateUserPasswordRequest{
328328
Password:data.Password.ValueString(),
329329
})
330330
iferr!=nil&&!strings.Contains(err.Error(),"New password cannot match old password.") {
331331
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to update password, got error: %s",err))
332332
return
333333
}
334-
tflog.Trace(ctx,"successfully updated password")
334+
tflog.Info(ctx,"successfully updated password")
335335
}
336336

337337
varstatusErrerror
@@ -362,13 +362,13 @@ func (r *UserResource) Delete(ctx context.Context, req resource.DeleteRequest, r
362362

363363
client:=r.data.Client
364364

365-
tflog.Trace(ctx,"deleting user")
365+
tflog.Info(ctx,"deleting user")
366366
err:=client.DeleteUser(ctx,data.ID.ValueUUID())
367367
iferr!=nil {
368368
resp.Diagnostics.AddError("Client Error",fmt.Sprintf("Unable to delete user, got error: %s",err))
369369
return
370370
}
371-
tflog.Trace(ctx,"successfully deleted user")
371+
tflog.Info(ctx,"successfully deleted user")
372372
}
373373

374374
func (r*UserResource)ImportState(ctx context.Context,req resource.ImportStateRequest,resp*resource.ImportStateResponse) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp