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

@ -111,6 +111,9 @@ func (r *credentialsGroupDataSource) Read(ctx context.Context, req datasource.Re
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
region := r.providerData.GetRegionWithOverride(model.Region)
@ -124,6 +127,9 @@ func (r *credentialsGroupDataSource) Read(ctx context.Context, req datasource.Re
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials group", fmt.Sprintf("getting credential group from list of credentials groups: %v", err))
return
}
ctx = core.LogResponse(ctx)
if !found {
resp.State.RemoveResource(ctx)
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentials group", fmt.Sprintf("Credentials group with ID %q does not exists in project %q", credentialsGroupId, projectId))

View file

@ -176,6 +176,9 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupName := model.Name.ValueString()
region := model.Region.ValueString()
@ -202,6 +205,8 @@ func (r *credentialsGroupResource) Create(ctx context.Context, req resource.Crea
return
}
ctx = core.LogResponse(ctx)
// Map response body to schema
err = mapFields(got, &model, region)
if err != nil {
@ -224,6 +229,9 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
region := r.providerData.GetRegionWithOverride(model.Region)
@ -237,6 +245,9 @@ func (r *credentialsGroupResource) Read(ctx context.Context, req resource.ReadRe
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading credentialsGroup", fmt.Sprintf("getting credential group from list of credentials groups: %v", err))
return
}
ctx = core.LogResponse(ctx)
if !found {
resp.State.RemoveResource(ctx)
return
@ -267,6 +278,9 @@ func (r *credentialsGroupResource) Delete(ctx context.Context, req resource.Dele
if resp.Diagnostics.HasError() {
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
credentialsGroupId := model.CredentialsGroupId.ValueString()
region := model.Region.ValueString()
@ -281,6 +295,8 @@ func (r *credentialsGroupResource) Delete(ctx context.Context, req resource.Dele
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting credentials group", fmt.Sprintf("Calling API: %v", err))
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "ObjectStorage credentials group deleted")
}