@@ -18,6 +18,8 @@ import (
1818 "fmt"
1919 "regexp"
2020
21+ "k8s.io/apimachinery/pkg/util/sets"
22+
2123 "github.com/kubernetes-sigs/kro/api/v1alpha1"
2224)
2325
3436 // kubernetesVersionRegex
3537 kubernetesVersionRegex = regexp .MustCompile (`^v\d+(?:(?:alpha|beta)\d+)?$` )
3638
37- // reservedKeyWords is a list of reserved words in kro.
38- reservedKeyWords = []string {
39+ // celReservedSymbols is a list of RESERVED symbols defined in the CEL lexer.
40+ // No identifiers are allowed to collide with these symbols.
41+ // https://github.com/google/cel-spec/blob/master/doc/langdef.md#syntax
42+ celReservedSymbols = sets .NewString (
43+ "true" , "false" , "null" , "in" ,
44+ "as" , "break" , "const" , "continue" , "else" ,
45+ "for" , "function" , "if" , "import" , "let" ,
46+ "loop" , "package" , "namespace" , "return" ,
47+ "var" , "void" , "while" ,
48+ )
49+
50+ // kroReservedKeyWords is a list of reserved words in kro.
51+ kroReservedKeyWords = sets .NewString (
3952 "apiVersion" ,
4053 "context" ,
4154 "dependency" ,
6881 "variables" ,
6982 "vars" ,
7083 "version" ,
71- }
84+ )
85+
86+ reservedKeyWords = kroReservedKeyWords .Union (celReservedSymbols )
7287)
7388
7489// isValidResourceID checks if the given id is a valid KRO resource id (loawercase)
@@ -83,7 +98,7 @@ func isValidKindName(name string) bool {
8398
8499// isKROReservedWord checks if the given word is a reserved word in KRO.
85100func isKROReservedWord (word string ) bool {
86- for _ , w := range reservedKeyWords {
101+ for _ , w := range reservedKeyWords . List () {
87102 if w == word {
88103 return true
89104 }
0 commit comments