Skip to content

refactor(cli): migrate commands to RunE with a single exit funnel#490

Open
Caesarsage wants to merge 4 commits into
microcks:masterfrom
Caesarsage:pr2/runE-single-exit-funnel
Open

refactor(cli): migrate commands to RunE with a single exit funnel#490
Caesarsage wants to merge 4 commits into
microcks:masterfrom
Caesarsage:pr2/runE-single-exit-funnel

Conversation

@Caesarsage

Copy link
Copy Markdown
Contributor

depend on #489

Part of the Microcks CLI v2 work (#255). Stacked on PR #489.

  • All ten commands move from Run + scattered os.Exit/log.Fatal to RunE returning errors.
  • A single funnel — cmd.Handle, called only by main — prints to stderr and maps Failure Kind → exit code (cmd/exit.go). Nothing else exits.
  • A non-conforming contract test travels as the silent ErrTestFailed sentinel → exit 1 with no spurious error line (mirrors kubectl diff).

No impact on the microcks binary: commands, flags, args, and success output are unchanged. Only code importing these packages is affected.

Exit codes (new, user-visible)

0 = success / non-zero = failure still holds, and 1 still means "contract test failed". Operational failures now carry distinct codes so CI can branch on why:

Code Meaning
0 success / contract conformed
1 contract test failed (a clean run)
2 usage — bad arguments or flags
11 connection — couldn't reach Microcks/Keycloak
12 API — server rejected the request / unusable response
13 not-found — remote resource missing
14 environment — local precondition (container runtime, image, readiness)
20 generic — unclassified failure

These codes were previously undocumented and inconsistent (1/2/20 interchangeably), so there is no prior contract to break. Documented in README.md + documentation/error-handling.md.

Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
@Caesarsage

Copy link
Copy Markdown
Contributor Author

HOLD

till PR #489 is review and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant