summaryrefslogtreecommitdiffstats
path: root/pkg/model/step_result.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/model/step_result.go')
-rw-r--r--pkg/model/step_result.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/pkg/model/step_result.go b/pkg/model/step_result.go
new file mode 100644
index 0000000..86e5ebf
--- /dev/null
+++ b/pkg/model/step_result.go
@@ -0,0 +1,45 @@
+package model
+
+import "fmt"
+
+type stepStatus int
+
+const (
+ StepStatusSuccess stepStatus = iota
+ StepStatusFailure
+ StepStatusSkipped
+)
+
+var stepStatusStrings = [...]string{
+ "success",
+ "failure",
+ "skipped",
+}
+
+func (s stepStatus) MarshalText() ([]byte, error) {
+ return []byte(s.String()), nil
+}
+
+func (s *stepStatus) UnmarshalText(b []byte) error {
+ str := string(b)
+ for i, name := range stepStatusStrings {
+ if name == str {
+ *s = stepStatus(i)
+ return nil
+ }
+ }
+ return fmt.Errorf("invalid step status %q", str)
+}
+
+func (s stepStatus) String() string {
+ if int(s) >= len(stepStatusStrings) {
+ return ""
+ }
+ return stepStatusStrings[s]
+}
+
+type StepResult struct {
+ Outputs map[string]string `json:"outputs"`
+ Conclusion stepStatus `json:"conclusion"`
+ Outcome stepStatus `json:"outcome"`
+}