mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
fix: remove composite restrictions (#1128)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
b957248c0b
commit
7aa863a21c
3 changed files with 29 additions and 68 deletions
|
@ -23,21 +23,6 @@ type Workflow struct {
|
|||
Defaults Defaults `yaml:"defaults"`
|
||||
}
|
||||
|
||||
// CompositeRestrictions is the structure to control what is allowed in composite actions
|
||||
type CompositeRestrictions struct {
|
||||
AllowCompositeUses bool
|
||||
AllowCompositeIf bool
|
||||
AllowCompositeContinueOnError bool
|
||||
}
|
||||
|
||||
func defaultCompositeRestrictions() *CompositeRestrictions {
|
||||
return &CompositeRestrictions{
|
||||
AllowCompositeUses: true,
|
||||
AllowCompositeIf: true,
|
||||
AllowCompositeContinueOnError: false,
|
||||
}
|
||||
}
|
||||
|
||||
// On events for the workflow
|
||||
func (w *Workflow) On() []string {
|
||||
switch w.RawOn.Kind {
|
||||
|
@ -431,22 +416,6 @@ func (s *Step) Type() StepType {
|
|||
return StepTypeUsesActionRemote
|
||||
}
|
||||
|
||||
func (s *Step) Validate(config *CompositeRestrictions) error {
|
||||
if config == nil {
|
||||
config = defaultCompositeRestrictions()
|
||||
}
|
||||
if s.Type() != StepTypeRun && !config.AllowCompositeUses {
|
||||
return fmt.Errorf("(StepID: %s): Unexpected value 'uses'", s.String())
|
||||
} else if s.Type() == StepTypeRun && s.Shell == "" {
|
||||
return fmt.Errorf("(StepID: %s): Required property is missing: 'shell'", s.String())
|
||||
} else if !s.If.IsZero() && !config.AllowCompositeIf {
|
||||
return fmt.Errorf("(StepID: %s): Property is not available: 'if'", s.String())
|
||||
} else if s.ContinueOnError && !config.AllowCompositeContinueOnError {
|
||||
return fmt.Errorf("(StepID: %s): Property is not available: 'continue-on-error'", s.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadWorkflow returns a list of jobs for a given workflow file reader
|
||||
func ReadWorkflow(in io.Reader) (*Workflow, error) {
|
||||
w := new(Workflow)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue