mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-06 23:30:29 +00:00
Refactor expression evaluator to use parser from actionlint package (#908)
* feat: implement expression evaluator Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Philipp Hinrichsen <[email protected]> * feat: integrate exprparser into act Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Philipp Hinrichsen <[email protected]> * Escape { and }, do not fail on missing properties * Fix empty inputs context * fix: contains() comparison for complex values Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Philipp Hinrichsen <[email protected]> Co-authored-by: Christopher Homberger <[email protected]>
This commit is contained in:
12 files changed
+2056
-717
No files matched your search
@@ -426,19 +426,6 @@ func (rc *RunContext) isEnabled(ctx context.Context) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var splitPattern *regexp.Regexp
|
||||
|
||||
func previousOrNextPartIsAnOperator(i int, parts []string) bool {
|
||||
operator := false
|
||||
if i > 0 {
|
||||
operator = operatorPattern.MatchString(parts[i-1])
|
||||
}
|
||||
if i+1 < len(parts) {
|
||||
operator = operator || operatorPattern.MatchString(parts[i+1])
|
||||
}
|
||||
return operator
|
||||
}
|
||||
|
||||
func mergeMaps(maps ...map[string]string) map[string]string {
|
||||
rtnMap := make(map[string]string)
|
||||
for _, m := range maps {
|
||||
@@ -499,17 +486,6 @@ func (rc *RunContext) getStepsContext() map[string]*model.StepResult {
|
||||
return rc.StepResults
|
||||
}
|
||||
|
||||
func (rc *RunContext) getNeedsTransitive(job *model.Job) []string {
|
||||
needs := job.Needs()
|
||||
|
||||
for _, need := range needs {
|
||||
parentNeeds := rc.getNeedsTransitive(rc.Run.Workflow.GetJob(need))
|
||||
needs = append(needs, parentNeeds...)
|
||||
}
|
||||
|
||||
return needs
|
||||
}
|
||||
|
||||
func (rc *RunContext) getGithubContext() *model.GithubContext {
|
||||
ghc := &model.GithubContext{
|
||||
Event: make(map[string]interface{}),
|
||||
@@ -784,12 +760,11 @@ func (rc *RunContext) handleCredentials() (username, password string, err error)
|
||||
}
|
||||
|
||||
ee := rc.NewExpressionEvaluator()
|
||||
var ok bool
|
||||
if username, ok = ee.InterpolateWithStringCheck(container.Credentials["username"]); !ok {
|
||||
if username = ee.Interpolate(container.Credentials["username"]); username == "" {
|
||||
err = fmt.Errorf("failed to interpolate container.credentials.username")
|
||||
return
|
||||
}
|
||||
if password, ok = ee.InterpolateWithStringCheck(container.Credentials["password"]); !ok {
|
||||
if password = ee.Interpolate(container.Credentials["password"]); password == "" {
|
||||
err = fmt.Errorf("failed to interpolate container.credentials.password")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user