update to latest version of action parser
This commit is contained in:
38
vendor/github.com/actions/workflow-parser/model/command.go
generated
vendored
Normal file
38
vendor/github.com/actions/workflow-parser/model/command.go
generated
vendored
Normal 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
|
||||
}
|
15
vendor/github.com/actions/workflow-parser/model/configuration.go
generated
vendored
15
vendor/github.com/actions/workflow-parser/model/configuration.go
generated
vendored
@@ -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
|
||||
|
2
vendor/github.com/actions/workflow-parser/model/eventtypes.go
generated
vendored
2
vendor/github.com/actions/workflow-parser/model/eventtypes.go
generated
vendored
@@ -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
|
||||
|
9
vendor/github.com/actions/workflow-parser/parser/errors.go
generated
vendored
9
vendor/github.com/actions/workflow-parser/parser/errors.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -17,7 +18,13 @@ type ParserError struct {
|
||||
}
|
||||
|
||||
func (p *ParserError) Error() string {
|
||||
return p.message
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
buffer.WriteString(p.message)
|
||||
for _, e := range p.Errors {
|
||||
buffer.WriteString("\n ")
|
||||
buffer.WriteString(e.Error())
|
||||
}
|
||||
return buffer.String()
|
||||
}
|
||||
|
||||
// Error represents an error identified by the parser, either syntactic
|
||||
|
36
vendor/github.com/actions/workflow-parser/parser/parser.go
generated
vendored
36
vendor/github.com/actions/workflow-parser/parser/parser.go
generated
vendored
@@ -43,7 +43,7 @@ func Parse(reader io.Reader, options ...OptionFunc) (*model.Configuration, error
|
||||
pos := ErrorPos{File: pe.Pos.Filename, Line: pe.Pos.Line, Column: pe.Pos.Column}
|
||||
errors := ErrorList{newFatal(pos, pe.Err.Error())}
|
||||
return nil, &ParserError{
|
||||
message: pe.Err.Error(),
|
||||
message: "unable to parse",
|
||||
Errors: errors,
|
||||
}
|
||||
}
|
||||
@@ -548,24 +548,25 @@ func (ps *parseState) parseActionAttribute(name string, action *model.Action, va
|
||||
case "uses":
|
||||
ps.parseUses(action, val)
|
||||
case "needs":
|
||||
needs, ok := ps.literalToStringArray(val, true)
|
||||
if ok {
|
||||
if needs, ok := ps.literalToStringArray(val, true); ok {
|
||||
action.Needs = needs
|
||||
ps.posMap[&action.Needs] = val
|
||||
}
|
||||
case "runs":
|
||||
ps.parseCommand(action, &action.Runs, name, val, false)
|
||||
if runs := ps.parseCommand(action, action.Runs, name, val, false); runs != nil {
|
||||
action.Runs = runs
|
||||
}
|
||||
case "args":
|
||||
ps.parseCommand(action, &action.Args, name, val, true)
|
||||
if args := ps.parseCommand(action, action.Args, name, val, true); args != nil {
|
||||
action.Args = args
|
||||
}
|
||||
case "env":
|
||||
env := ps.literalToStringMap(val)
|
||||
if env != nil {
|
||||
if env := ps.literalToStringMap(val); env != nil {
|
||||
action.Env = env
|
||||
}
|
||||
ps.posMap[&action.Env] = val
|
||||
case "secrets":
|
||||
secrets, ok := ps.literalToStringArray(val, false)
|
||||
if ok {
|
||||
if secrets, ok := ps.literalToStringArray(val, false); ok {
|
||||
action.Secrets = secrets
|
||||
ps.posMap[&action.Secrets] = val
|
||||
}
|
||||
@@ -621,11 +622,11 @@ func (ps *parseState) parseUses(action *model.Action, node ast.Node) {
|
||||
}
|
||||
}
|
||||
|
||||
// parseUses sets the action.Runs or action.Command value based on the
|
||||
// parseUses sets the action.Runs or action.Args value based on the
|
||||
// contents of the AST node. This function enforces formatting
|
||||
// requirements on the value.
|
||||
func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionCommand, name string, node ast.Node, allowBlank bool) {
|
||||
if len(dest.Parsed) > 0 {
|
||||
func (ps *parseState) parseCommand(action *model.Action, cmd model.Command, name string, node ast.Node, allowBlank bool) model.Command {
|
||||
if cmd != nil {
|
||||
ps.addWarning(node, "`%s' redefined in action `%s'", name, action.Identifier)
|
||||
// continue, allowing the redefinition
|
||||
}
|
||||
@@ -633,9 +634,9 @@ func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionComma
|
||||
// Is it a list?
|
||||
if _, ok := node.(*ast.ListType); ok {
|
||||
if parsed, ok := ps.literalToStringArray(node, false); ok {
|
||||
dest.Parsed = parsed
|
||||
return &model.ListCommand{Values: parsed}
|
||||
}
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
// If not, parse a whitespace-separated string into a list.
|
||||
@@ -643,14 +644,13 @@ func (ps *parseState) parseCommand(action *model.Action, dest *model.ActionComma
|
||||
var ok bool
|
||||
if raw, ok = ps.literalToString(node); !ok {
|
||||
ps.addError(node, "The `%s' attribute must be a string or a list", name)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
if raw == "" && !allowBlank {
|
||||
ps.addError(node, "`%s' value in action `%s' cannot be blank", name, action.Identifier)
|
||||
return
|
||||
return nil
|
||||
}
|
||||
dest.Raw = raw
|
||||
dest.Parsed = strings.Fields(raw)
|
||||
return &model.StringCommand{Value: raw}
|
||||
}
|
||||
|
||||
func typename(val interface{}) string {
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -1,6 +1,6 @@
|
||||
# github.com/Microsoft/go-winio v0.4.11
|
||||
github.com/Microsoft/go-winio
|
||||
# github.com/actions/workflow-parser v0.0.0-20190130154146-aac54e2ba131
|
||||
# github.com/actions/workflow-parser v0.0.0-20190131180005-9cb71d183680
|
||||
github.com/actions/workflow-parser/model
|
||||
github.com/actions/workflow-parser/parser
|
||||
# github.com/containerd/continuity v0.0.0-20181203112020-004b46473808
|
||||
|
Reference in New Issue
Block a user