-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: export and move shared contexts into pkg/model (#931)
This commit moves the githubContext, jobContext and stepResult structs from the runner package to the model package in preparation for #908 because the expression.go file lives in the runner package and would introduce cyclic dependencies with the exprparser package. Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5580812
commit ed01f46
Showing
10 changed files
with
132 additions
and
124 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package model | ||
|
||
type GithubContext struct { | ||
Event map[string]interface{} `json:"event"` | ||
EventPath string `json:"event_path"` | ||
Workflow string `json:"workflow"` | ||
RunID string `json:"run_id"` | ||
RunNumber string `json:"run_number"` | ||
Actor string `json:"actor"` | ||
Repository string `json:"repository"` | ||
EventName string `json:"event_name"` | ||
Sha string `json:"sha"` | ||
Ref string `json:"ref"` | ||
HeadRef string `json:"head_ref"` | ||
BaseRef string `json:"base_ref"` | ||
Token string `json:"token"` | ||
Workspace string `json:"workspace"` | ||
Action string `json:"action"` | ||
ActionPath string `json:"action_path"` | ||
ActionRef string `json:"action_ref"` | ||
ActionRepository string `json:"action_repository"` | ||
Job string `json:"job"` | ||
JobName string `json:"job_name"` | ||
RepositoryOwner string `json:"repository_owner"` | ||
RetentionDays string `json:"retention_days"` | ||
RunnerPerflog string `json:"runner_perflog"` | ||
RunnerTrackingID string `json:"runner_tracking_id"` | ||
} |
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,12 @@ | ||
package model | ||
|
||
type JobContext struct { | ||
Status string `json:"status"` | ||
Container struct { | ||
ID string `json:"id"` | ||
Network string `json:"network"` | ||
} `json:"container"` | ||
Services map[string]struct { | ||
ID string `json:"id"` | ||
} `json:"services"` | ||
} |
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,43 @@ | ||
package model | ||
|
||
import "fmt" | ||
|
||
type stepStatus int | ||
|
||
const ( | ||
StepStatusSuccess stepStatus = iota | ||
StepStatusFailure | ||
) | ||
|
||
var stepStatusStrings = [...]string{ | ||
"success", | ||
"failure", | ||
} | ||
|
||
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"` | ||
} |
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
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
Oops, something went wrong.