feat: add logging for trace id (#1061)

relates to STACKITTPR-290
This commit is contained in:
Marcel Jacek 2025-11-27 11:06:18 +01:00 committed by GitHub
parent d1e12fcf64
commit 24b7387db9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 1597 additions and 7 deletions

View file

@ -160,6 +160,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
@ -171,6 +174,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
if credentialsResp.Id == nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
return
@ -206,6 +212,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
credentialId := model.CredentialId.ValueString()
@ -224,6 +233,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(recordSetResp, &model)
if err != nil {
@ -255,6 +266,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
credentialId := model.CredentialId.ValueString()
@ -267,6 +280,9 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
}
ctx = core.LogResponse(ctx)
_, err = wait.DeleteCredentialsWaitHandler(ctx, r.client, projectId, instanceId, credentialId).WaitWithContext(ctx)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Instance deletion waiting: %v", err))