You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[task] Consolidate safe output job builders to reduce duplication #4670
Eliminate 85% code duplication across 22 safe output files by extracting common job building patterns to reusable base types.
Context
Part of issue #4640 - Priority 2 (Medium Effort, High Value)
22 safe output files (create_*.go, close_*.go, add_*.go, update_*.go) follow nearly identical patterns for config parsing and job building, with ~2,500 lines of 85% similar code. This is the highest-value refactoring opportunity (could save 1,700 lines).
Approach
Create pkg/workflow/safe_output_builder.go with base types:
SafeOutputConfigParser struct for generic config parsing
SafeOutputJobBuilder struct for generic job building
Common parsing utilities for shared fields (labels, target-repo, etc.)
Common env var building patterns
Extract common patterns:
Config-to-env-var conversion logic (70-80% similar across all files)
Job condition building (85% identical)
Standard env var setup (100% identical)
Outputs map creation (100% identical)
Refactor existing safe output files to use new base types:
Start with 3-4 files as proof of concept
Gradually migrate remaining files
Maintain config-specific customization through builder functions
Activity