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

@ -120,6 +120,8 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
credentialId := model.CredentialId.ValueString()
@ -145,6 +147,9 @@ func (r *credentialDataSource) Read(ctx context.Context, req datasource.ReadRequ
resp.State.RemoveResource(ctx)
return
}
ctx = core.LogResponse(ctx)
if credentialsGroupResp == nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Reading credentials", fmt.Sprintf("Response is nil: %v", err))
return

View file

@ -248,6 +248,9 @@ func (r *credentialResource) Create(ctx context.Context, req resource.CreateRequ
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
region := model.Region.ValueString()
@ -275,6 +278,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 credentialResp.KeyId == nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating credential", "Got empty credential id")
return
@ -326,6 +332,8 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
credentialId := model.CredentialId.ValueString()
@ -341,6 +349,9 @@ func (r *credentialResource) Read(ctx context.Context, req resource.ReadRequest,
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credential", fmt.Sprintf("Finding credential: %v", err))
return
}
ctx = core.LogResponse(ctx)
if !found {
resp.State.RemoveResource(ctx)
return
@ -399,6 +410,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
credentialId := model.CredentialId.ValueString()
@ -415,6 +428,8 @@ func (r *credentialResource) Delete(ctx context.Context, req resource.DeleteRequ
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credential", fmt.Sprintf("Calling API: %v", err))
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "ObjectStorage credential deleted")
}