Skip to content

Commit b50223c

Browse files
committed
add rego version stringer
1 parent 96370e4 commit b50223c

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

build.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,45 @@ const (
7474
RegoV1
7575
)
7676

77+
const (
78+
regoUndefined string = "undefined"
79+
regoV0 string = "rego.v0"
80+
regoV0V1 string = "rego.v0v1"
81+
regoV1 string = "rego.v1"
82+
)
83+
7784
func (v RegoVersion) ToAstRegoVersion() ast.RegoVersion {
7885
return ast.RegoVersionFromInt(int(v))
7986
}
8087

88+
func (v RegoVersion) String() string {
89+
switch v {
90+
case RegoUndefined:
91+
return regoUndefined
92+
case RegoV0:
93+
return regoV0
94+
case RegoV0CompatV1:
95+
return regoV0V1
96+
case RegoV1:
97+
return regoV1
98+
default:
99+
return regoUndefined
100+
}
101+
}
102+
103+
func RegoVersionFromString(v string) RegoVersion {
104+
switch v {
105+
case regoV0:
106+
return RegoV0
107+
case regoV0V1:
108+
return RegoV0CompatV1
109+
case regoV1:
110+
return RegoV1
111+
default:
112+
return RegoV1
113+
}
114+
}
115+
81116
// BuildParams contains all parameters used for doing a build.
82117
type BuildParams struct {
83118
CapabilitiesJSONFile string

0 commit comments

Comments
 (0)