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

@ -162,6 +162,8 @@ func (r *serviceAccountKeyResource) Create(ctx context.Context, req resource.Cre
return
}
ctx = core.InitProviderContext(ctx)
// Set logging context with the project ID and service account email.
projectId := model.ProjectId.ValueString()
serviceAccountEmail := model.ServiceAccountEmail.ValueString()
@ -182,6 +184,8 @@ func (r *serviceAccountKeyResource) Create(ctx context.Context, req resource.Cre
// Initialize the API request with the required parameters.
saAccountKeyResp, err := r.client.CreateServiceAccountKey(ctx, projectId, serviceAccountEmail).CreateServiceAccountKeyPayload(*payload).Execute()
ctx = core.LogResponse(ctx)
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Failed to create service account key", fmt.Sprintf("API call error: %v", err))
return
@ -213,6 +217,8 @@ func (r *serviceAccountKeyResource) Read(ctx context.Context, req resource.ReadR
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
serviceAccountEmail := model.ServiceAccountEmail.ValueString()
keyId := model.KeyId.ValueString()
@ -230,6 +236,8 @@ func (r *serviceAccountKeyResource) Read(ctx context.Context, req resource.ReadR
return
}
ctx = core.LogResponse(ctx)
// No mapping needed for read response, as private_key is excluded and ID remains unchanged.
diags = resp.State.Set(ctx, &model)
resp.Diagnostics.Append(diags...)
@ -260,6 +268,8 @@ func (r *serviceAccountKeyResource) Delete(ctx context.Context, req resource.Del
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
serviceAccountEmail := model.ServiceAccountEmail.ValueString()
keyId := model.KeyId.ValueString()
@ -274,6 +284,8 @@ func (r *serviceAccountKeyResource) Delete(ctx context.Context, req resource.Del
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Service account key deleted")
}