Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using log.Fatal in pkg/* #1759

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 14 additions & 21 deletions pkg/model/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ func (w *Workflow) On() []string {
func (w *Workflow) OnEvent(event string) interface{} {
if w.RawOn.Kind == yaml.MappingNode {
var val map[string]interface{}
err := w.RawOn.Decode(&val)
if err != nil {
log.Fatal(err)
if !decodeNode(w.RawOn, &val) {
return nil
}
return val[event]
}
Expand All @@ -85,16 +84,14 @@ func (w *Workflow) WorkflowDispatchConfig() *WorkflowDispatch {
}

var val map[string]yaml.Node
err := w.RawOn.Decode(&val)
if err != nil {
log.Fatal(err)
if !decodeNode(w.RawOn, &val) {
return nil
}

var config WorkflowDispatch
node := val["workflow_dispatch"]
err = node.Decode(&config)
if err != nil {
log.Fatal(err)
if !decodeNode(node, &config) {
return nil
}

return &config
Expand Down Expand Up @@ -128,16 +125,14 @@ func (w *Workflow) WorkflowCallConfig() *WorkflowCall {
}

var val map[string]yaml.Node
err := w.RawOn.Decode(&val)
if err != nil {
log.Fatal(err)
if !decodeNode(w.RawOn, &val) {
return &WorkflowCall{}
}

var config WorkflowCall
node := val["workflow_call"]
err = node.Decode(&config)
if err != nil {
log.Fatal(err)
if !decodeNode(node, &config) {
return &WorkflowCall{}
}

return &config
Expand Down Expand Up @@ -220,9 +215,8 @@ func (j *Job) InheritSecrets() bool {
}

var val string
err := j.RawSecrets.Decode(&val)
if err != nil {
log.Fatal(err)
if !decodeNode(j.RawSecrets, &val) {
return false
}

return val == "inherit"
Expand All @@ -234,9 +228,8 @@ func (j *Job) Secrets() map[string]string {
}

var val map[string]string
err := j.RawSecrets.Decode(&val)
if err != nil {
log.Fatal(err)
if !decodeNode(j.RawSecrets, &val) {
return nil
}

return val
Expand Down