labstack / labstack/onebox

Two copies of the job-step lookup on OperationPlan

Open
#177 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
3
Forks
0
Avg merge
2h 40m
Merged PRs (30d)
63

Description

The problem

Two functions walk an OperationPlan's steps to find its single job step:

  • jobStepOf (cmd/ob/commands.go:900-910) returns the step, for the approval
    summary and the typed token.
  • jobNameOfOperation (internal/onebox/expiry_errors.go:67-76) returns just
    the name, for expiry messages.

Same loop, same guarantee behind it — JobPlan.validateContent
(internal/onebox/job_plan.go:97-104) ensures exactly one StepJob whose
Component matches Artifact.Job. Two copies means a future change to what
"the job step" is has two places to land, and the CLI copy exists only because
the onebox one is unexported and returns the wrong shape.

Proposed change

Export one accessor on OperationPlanJobStep() (OperationStep, bool)
next to the type it belongs to, and have both callers use it.
jobNameOfOperation becomes a thin wrapper or disappears.

Current workaround

None needed; both copies are correct today. This is about keeping them that
way.

Scope and safety

Pure refactor. No behaviour change, no schema change, no new command surface.

Found while auditing #171.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the OperationPlan type and JobPlan.validateContent in internal/onebox/job_plan.go to understand the single-job-step guarantee. Then inspect the two callers in cmd/ob/commands.go and internal/onebox/expiry_errors.go. Done means both callers use one exported OperationPlan accessor, with no behavior or schema changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.