refactor: decompose large multi-cluster files (audit.go, import_field_extractor.go)#43898
Conversation
…usters pkg/cli/audit.go (1257 → 933 lines): - Extract job audit cluster → audit_job.go (223 lines) - Extract workflow run metadata cluster → workflow_run_metadata.go (127 lines) pkg/parser/import_field_extractor.go (1369 → 899 lines): - Extract observability/OTLP cluster → import_observability.go (202 lines) - Extract import schema validation cluster → import_schema_validation.go (228 lines) - Extract import input substitution cluster → import_input_substitution.go (57 lines) Pure function moves within each package — no signature or behavior changes. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors two previously large files by decomposing them into smaller, responsibility-focused Go source files in pkg/cli and pkg/parser, aiming to keep behavior/signatures the same while improving maintainability.
Changes:
- Split import handling helpers out of
pkg/parser/import_field_extractor.gointo dedicated files for schema validation, observability merging, and input substitution. - Split audit job log extraction helpers and workflow-run metadata helpers out of
pkg/cli/audit.gointo separate files.
Show a summary per file
| File | Description |
|---|---|
| pkg/parser/import_schema_validation.go | New file containing import-schema validation and default-application helpers moved out of the extractor. |
| pkg/parser/import_observability.go | New file containing OTLP endpoint extraction and observability merge logic moved out of the extractor. |
| pkg/parser/import_input_substitution.go | New file containing import-input expression substitution helpers moved out of the extractor. |
| pkg/parser/import_field_extractor.go | Removes the moved helper clusters and trims imports accordingly. |
| pkg/cli/workflow_run_metadata.go | New file containing workflow run metadata fetching and workflow display-name resolution moved out of audit. |
| pkg/cli/audit_job.go | New file containing job-specific audit log download/parsing helpers moved out of audit. |
| pkg/cli/audit.go | Removes the moved helper clusters and trims imports accordingly. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Low
| // applyImportSchemaDefaultsFromFrontmatter applies import-schema defaults from an | ||
| // already-parsed frontmatter map, avoiding a redundant YAML parse when the caller | ||
| // has already extracted the frontmatter. Returns a copy of inputs augmented with | ||
| // default values for any schema parameters declared with a "default" field but not | ||
| // present in the provided inputs map. Parameters already in inputs are left unchanged. |
|
@copilot please run the
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Implemented in c62914e. I addressed the unresolved parser review items (canonical |
|
@copilot please run the
|
Done. I ran the
No additional code changes were required in this pass, so there is no new commit hash to share. CI on this agent HEAD still needs a maintainer-triggered re-run (close/reopen PR, |
|
🎉 This pull request is included in a new release. Release: |
Two files exceeded 1,200 lines each by mixing distinct function clusters. Split each by semantic responsibility — pure function moves, no signature or behavior changes.
pkg/cli/audit.go(1,257 → 933 lines)audit_job.go— job-specific audit:auditJobRun,fetchAuditJobLog,extractStepOutput,findFirstFailingStep, step log renderingworkflow_run_metadata.go— GitHub API metadata fetching:fetchWorkflowRunMetadata,resolveWorkflowDisplayName,extractWorkflowNameFromYAMLpkg/parser/import_field_extractor.go(1,369 → 899 lines)import_observability.go— OTLP config merging:mergeObservabilityConfigs,extractOTLPEndpointsFromObsMap,extractOTLPGitHubAppFromObsMap,extractOTLPAttributesFromObsMapimport_schema_validation.go— import-schema validation:validateWithImportSchema,validateObjectInput,validateImportInputType,applyImportSchemaDefaultsFromFrontmatterimport_input_substitution.go— expression substitution:substituteImportInputsInContent,buildImportInputReplaceFunc,resolveImportInputPath