-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this commit implements tep-0049 - ignore a step error When a `step` in a `task` results in a failure, the rest of the steps in the `task` are skipped and the `taskRun` is declared a failure. If you would like to ignore such step errors and continue executing the rest of the steps in the task, you can specify `onError` for such a `step`. `onError` can be set to either `continue` or `fail` as part of the step definition. If `onError` is set to `continue`, the entrypoint sets the original failed exit code of the script in the container terminated state. A `step` with `onError` set to `continue` does not fail the `taskRun` and continues executing the rest of the steps in a task. This is an alpha feature. The `enable-api-fields` feature flag must be set to `"alpha"` to specify `onError` for a `step`. This commit includes following changes: * Changing entrypoint to include three new flags `onError`, `stepMetadataDir`, and `stepMetadataDirLink`. * Adding one new function as part of the runner CreateDirWithSymlink * Creating a volume `/tekton/steps/` * Supporting a path variable $(steps.step-<stepName>.exitCode.path) and $(steps.step-unnamed-<stepIndex>.exitCode.path) * API spec `onError` while defining a step * Writing exitCode at /tekton/steps/step-<step-name>/exitCode or /tekton/steps/step-unnamed-<step-index>/exitCode * Set the exitCode of a terminated state to a non-zero exit code * Doc, unit test, and examples for this feature
- Loading branch information
1 parent
9b9c925
commit 92746a2
Showing
28 changed files
with
1,482 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestRealPostWriter_WriteFileContent(t *testing.T) { | ||
tests := []struct { | ||
name, file, content string | ||
}{{ | ||
name: "write a file content", | ||
file: "sample.txt", | ||
content: "this is a sample file", | ||
}, { | ||
name: "write a file without specifying any path", | ||
}, { | ||
name: "create an empty file", | ||
file: "sample.txt", | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
rw := realPostWriter{} | ||
rw.Write(tt.file, tt.content) | ||
if tt.file != "" { | ||
defer os.Remove(tt.file) | ||
if _, err := os.Stat(tt.file); err != nil { | ||
t.Fatalf("Failed to create a file %q", tt.file) | ||
} | ||
b, err := os.ReadFile(tt.file) | ||
if err != nil { | ||
t.Fatalf("Failed to read the file %q", tt.file) | ||
} | ||
if tt.content != string(b) { | ||
t.Fatalf("Failed to write the desired content %q to the file %q", tt.content, tt.file) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestRealPostWriter_CreateStepPath(t *testing.T) { | ||
tests := []struct { | ||
name, source, link string | ||
}{{ | ||
name: "Create a path with a file", | ||
source: "sample.txt", | ||
link: "0", | ||
}, { | ||
name: "Create a path without specifying any path", | ||
}, { | ||
name: "Create a sym link without specifying any link path", | ||
source: "sample.txt", | ||
}, { | ||
name: "Create a sym link without specifying any source", | ||
link: "0.txt", | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
rw := realPostWriter{} | ||
rw.CreateDirWithSymlink(tt.source, tt.link) | ||
if tt.source != "" { | ||
defer os.Remove(tt.source) | ||
if _, err := os.Stat(tt.source); err != nil { | ||
t.Fatalf("Failed to create a file %q", tt.source) | ||
} | ||
} | ||
if tt.source != "" && tt.link != "" { | ||
defer os.Remove(tt.link) | ||
if _, err := os.Stat(tt.link); err != nil { | ||
t.Fatalf("Failed to create a sym link %q", tt.link) | ||
} | ||
} | ||
}) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.