mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-24 17:25:16 -06:00
73619ee8a2
This logic was duplicated for config processing and is useful inside the new build command when dealing with entrypoints so just move it into an internal package. Signed-off-by: Torin Sandall <torinsandall@gmail.com>
20 lines
572 B
Go
20 lines
572 B
Go
// Copyright 2020 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package ref implements internal helpers for references
|
|
package ref
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/open-policy-agent/opa/ast"
|
|
)
|
|
|
|
// ParseDataPath returns a ref from the slash separated path s rooted at data.
|
|
// All path segments are treated as identifier strings.
|
|
func ParseDataPath(s string) (ast.Ref, error) {
|
|
s = strings.Replace(strings.Trim(s, "/"), "/", ".", -1)
|
|
return ast.ParseRef("data." + s)
|
|
}
|