Skip to content

Commit

Permalink
replace regex w/ simple string match
Browse files Browse the repository at this point in the history
  • Loading branch information
aq17 committed Sep 27, 2023
1 parent dd3ed12 commit 7d1ade9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions ast/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ package ast
import (
"encoding/json"
"fmt"
"regexp"
"strings"

"github.com/hashicorp/hcl/v2"
"github.com/pulumi/esc/syntax"
)

var fnOpenRegex = regexp.MustCompile(`^fn::open::[a-zA-Z-]+$`)

// Expr represents a Pulumi YAML expression. Expressions may be literals, interpolated strings, symbols, or builtin
// functions.
type Expr interface {
Expand Down Expand Up @@ -534,7 +531,7 @@ func tryParseFunction(node *syntax.ObjectNode) (Expr, syntax.Diagnostics, bool)
case "fn::toString":
parse = parseToString
default:
if match, _ := regexp.MatchString(fnOpenRegex.String(), kvp.Key.Value()); match {
if strings.HasPrefix(kvp.Key.Value(), "fn::open::") {
// transform the node into fn::open format
providerName := strings.TrimPrefix(kvp.Key.Value(), "fn::")
// case 1: inputs are provided
Expand Down

0 comments on commit 7d1ade9

Please sign in to comment.