1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-10-15 19:42:06 +00:00

update to latest version of action parser

This commit is contained in:
Casey Lee 2019-01-31 16:36:28 -08:00
parent 4e66f2c8be
commit 9c3a288946
8 changed files with 84 additions and 43 deletions

View file

@ -0,0 +1,38 @@
package model
import (
"strings"
)
// Command represents the optional "runs" and "args" attributes.
// Each one takes one of two forms:
// - runs="entrypoint arg1 arg2 ..."
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
type Command interface {
isCommand()
Split() []string
}
// StringCommand represents the string based form of the "runs" or "args"
// attribute.
// - runs="entrypoint arg1 arg2 ..."
type StringCommand struct {
Value string
}
// ListCommand represents the list based form of the "runs" or "args" attribute.
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
type ListCommand struct {
Values []string
}
func (s *StringCommand) isCommand() {}
func (l *ListCommand) isCommand() {}
func (s *StringCommand) Split() []string {
return strings.Fields(s.Value)
}
func (l *ListCommand) Split() []string {
return l.Values
}

View file

@ -10,25 +10,12 @@ type Configuration struct {
type Action struct {
Identifier string
Uses Uses
Runs, Args ActionCommand
Runs, Args Command
Needs []string
Env map[string]string
Secrets []string
}
// ActionCommand represents the optional "runs" and "args" attributes.
// Each one takes one of two forms:
// - runs="entrypoint arg1 arg2 ..."
// - runs=[ "entrypoint", "arg1", "arg2", ... ]
// If the user uses the string form, "Raw" contains that value, and
// "Parsed" contains an array of the string value split at whitespace.
// If the user uses the array form, "Raw" is empty, and "Parsed" contains
// the array.
type ActionCommand struct {
Raw string
Parsed []string
}
// Workflow represents a single "workflow" stanza in a .workflow file.
type Workflow struct {
Identifier string

View file

@ -12,7 +12,7 @@ func IsAllowedEventType(eventType string) bool {
// IsMatchingEventType checks to see if the "flowOn" string from a flow's on attribute matches the incoming webhook of type eventType.
func IsMatchingEventType(flowOn, eventType string) bool {
return strings.ToLower(flowOn) == strings.ToLower(eventType)
return strings.EqualFold(flowOn, eventType)
}
// https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#events-supported-in-workflow-files