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

@ -102,6 +102,8 @@ func (r *serviceAccountDataSource) Read(ctx context.Context, req datasource.Read
return
}
ctx = core.InitProviderContext(ctx)
// Extract the project ID from the model configuration
projectId := model.ProjectId.ValueString()
@ -120,6 +122,8 @@ func (r *serviceAccountDataSource) Read(ctx context.Context, req datasource.Read
return
}
ctx = core.LogResponse(ctx)
// Iterate over the service accounts returned by the API to find the one matching the email
serviceAccounts := *listSaResp.Items
for i := range serviceAccounts {

View file

@ -128,6 +128,8 @@ func (r *serviceAccountResource) Create(ctx context.Context, req resource.Create
return
}
ctx = core.InitProviderContext(ctx)
// Set logging context with the project ID and service account name.
projectId := model.ProjectId.ValueString()
serviceAccountName := model.Name.ValueString()
@ -148,6 +150,8 @@ func (r *serviceAccountResource) Create(ctx context.Context, req resource.Create
return
}
ctx = core.LogResponse(ctx)
// Set the service account name and map the response to the resource schema.
model.Name = types.StringValue(serviceAccountName)
err = mapFields(serviceAccountResp, &model)
@ -178,6 +182,8 @@ func (r *serviceAccountResource) Read(ctx context.Context, req resource.ReadRequ
return
}
ctx = core.InitProviderContext(ctx)
// Extract the project ID for the service account.
projectId := model.ProjectId.ValueString()
@ -188,6 +194,8 @@ func (r *serviceAccountResource) Read(ctx context.Context, req resource.ReadRequ
return
}
ctx = core.LogResponse(ctx)
// Iterate over the list of service accounts to find the one that matches the email from the state.
serviceAccounts := *listSaResp.Items
for i := range serviceAccounts {
@ -233,6 +241,8 @@ func (r *serviceAccountResource) Delete(ctx context.Context, req resource.Delete
return
}
ctx = core.InitProviderContext(ctx)
projectId := model.ProjectId.ValueString()
serviceAccountName := model.Name.ValueString()
serviceAccountEmail := model.Email.ValueString()
@ -245,6 +255,9 @@ func (r *serviceAccountResource) Delete(ctx context.Context, req resource.Delete
core.LogAndAddError(ctx, &resp.Diagnostics, "Error deleting service account", fmt.Sprintf("Calling API: %v", err))
return
}
ctx = core.LogResponse(ctx)
tflog.Info(ctx, "Service account deleted")
}