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

make ContainsExpression(s string) public #388

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ type String struct {
Pos *Pos
}

func containsExpression(s string) bool {
func ContainsExpression(s string) bool {
i := strings.Index(s, "${{")
return i >= 0 && i < strings.Index(s, "}}")
}

// ContainsExpression returns whether the string contains at least one ${{ }} expression.
func (s *String) ContainsExpression() bool {
return containsExpression(s.Value)
return ContainsExpression(s.Value)
}

func isExprAssigned(s string) bool {
Expand Down
2 changes: 1 addition & 1 deletion reusable_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (c *LocalReusableWorkflowCache) writeCache(key string, val *ReusableWorkflo
//
// Calling this method is thread-safe.
func (c *LocalReusableWorkflowCache) FindMetadata(spec string) (*ReusableWorkflowMetadata, error) {
if c.proj == nil || !strings.HasPrefix(spec, "./") || containsExpression(spec) {
if c.proj == nil || !strings.HasPrefix(spec, "./") || ContainsExpression(spec) {
return nil, nil
}

Expand Down
4 changes: 2 additions & 2 deletions rule_runner_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (rule *RuleRunnerLabel) tryToGetLabelsInMatrix(label *String, m *Matrix) []
if m.Rows != nil {
if row, ok := m.Rows[prop]; ok {
for _, v := range row.Values {
if s, ok := v.(*RawYAMLString); ok && !containsExpression(s.Value) {
if s, ok := v.(*RawYAMLString); ok && !ContainsExpression(s.Value) {
labels = append(labels, &String{s.Value, false, s.Pos()})
}
}
Expand All @@ -258,7 +258,7 @@ func (rule *RuleRunnerLabel) tryToGetLabelsInMatrix(label *String, m *Matrix) []
for _, combi := range m.Include.Combinations {
if combi.Assigns != nil {
if assign, ok := combi.Assigns[prop]; ok {
if s, ok := assign.Value.(*RawYAMLString); ok && !containsExpression(s.Value) {
if s, ok := assign.Value.(*RawYAMLString); ok && !ContainsExpression(s.Value) {
labels = append(labels, &String{s.Value, false, s.Pos()})
}
}
Expand Down
Loading