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

Add lint workflow_call input conflict with required and default #154

Merged
merged 1 commit into from
Jun 22, 2022
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
8 changes: 8 additions & 0 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ func (p *parser) parseWorkflowCallEvent(pos *Pos, n *yaml.Node) *WorkflowCallEve
name, spec := kv.key, kv.val
input := &WorkflowCallEventInput{}
sawType := false
sawDefault := false

for _, attr := range p.parseMapping("input of workflow_call event", spec, true) {
switch attr.key.Value {
Expand All @@ -464,6 +465,7 @@ func (p *parser) parseWorkflowCallEvent(pos *Pos, n *yaml.Node) *WorkflowCallEve
input.Required = p.parseBool(attr.val)
case "default":
input.Default = p.parseString(attr.val, true)
sawDefault = true
case "type":
switch attr.val.Value {
case "boolean":
Expand All @@ -488,6 +490,12 @@ func (p *parser) parseWorkflowCallEvent(pos *Pos, n *yaml.Node) *WorkflowCallEve
p.errorfAt(name.Pos, "\"type\" is missing at %q input of workflow_call event", name.Value)
}

if input.Required != nil {
if sawDefault && input.Required.Value {
p.errorfAt(input.Default.Pos, "unexpected default value \"%q\" is set at %q input of workflow_call event. it is set to required", input.Default.Value, name.Value)
}
}

ret.Inputs[name] = input
}
case "secrets":
Expand Down