feat: add - prefix to ignore non-zero exit codes in Opsfile commands (Issue #20)#43
Merged
seanseannery merged 3 commits intomainfrom Mar 9, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes
IgnoreError boolfield toResolvedLineininternal/command_resolver.go@prefix check inResolve()with a loop that handles@,-,-@,@-in any order (at most one of each consumed)IgnoreErrorcheck ininternal/executor.go— useserrors.As(err, &exitErr)with*exec.ExitErrorso only non-zero exit codes are ignored; system-level errors (shell not found, permission denied) still propagateredeployexample command toexamples/Opsfiledemonstrating-and-@prefixesdocs/feat-dash-prefix-silent-failure.mdand test plan atdocs/testplans/testplan-dash-prefix-silent-failure.mdWhy do we need this?
Closes #20. Ops currently stops on the first shell line that returns a non-zero exit code. Some operations (e.g.
docker stop,rm -f,killall) may legitimately fail without indicating a real problem. This adds Makefile-style-prefix support so users can mark individual lines as failure-tolerant, allowing execution to continue to the next line.New modules or other dependencies introduced
None. Uses
errors.Asfrom the standard library (already imported).How was this tested?
internal/command_resolver_test.gocovering:-stripping, combined-@/@-,--(double-dash),-@-/@-@edge cases, dash in middle of line, dash in variable values, multi-line continuation, whitespace after dashinternal/executor_test.gocovering: ignored exit codes, system errors still propagate (invalid shelltest), combinedIgnoreError+Silent, all-linesIgnoreError, exit code 127 ignoredinternal/opsfile_parser_test.goupdated for newredeployexample command@prefix tests (20+) pass with the refactored loop-based prefix strippingmake lintandmake testpass cleanly