@@ -57,6 +57,7 @@ func main() {
5757func runGenerator (args ... string ) {
5858 outputDir := "config/crd"
5959 ctVer := ""
60+ crdRoot := "github.com/operator-framework/operator-controller/api/v1"
6061 if len (args ) >= 1 {
6162 // Get the output directory
6263 outputDir = args [0 ]
@@ -65,10 +66,15 @@ func runGenerator(args ...string) {
6566 // get the controller-tools version
6667 ctVer = args [1 ]
6768 }
69+ if len (args ) >= 3 {
70+ crdRoot = args [2 ]
71+ }
72+
73+ log .Printf ("crdRoot: %s" , crdRoot )
6874
6975 roots , err := loader .LoadRoots (
7076 "k8s.io/apimachinery/pkg/runtime/schema" , // Needed to parse generated register functions.
71- "github.com/operator-framework/operator-controller/api/v1" ,
77+ crdRoot ,
7278 )
7379 if err != nil {
7480 log .Fatalf ("failed to load package roots: %s" , err )
@@ -90,6 +96,7 @@ func runGenerator(args ...string) {
9096
9197 crd .AddKnownTypes (parser )
9298 for _ , r := range roots {
99+ log .Printf ("Looking at package %v" , r )
93100 parser .NeedPackage (r )
94101 }
95102
@@ -137,6 +144,7 @@ func runGenerator(args ...string) {
137144
138145 conv , err := crd .AsVersion (* channelCrd , apiextensionsv1 .SchemeGroupVersion )
139146 if err != nil {
147+ log .Printf ("CRD: %v" , * channelCrd )
140148 log .Fatalf ("failed to convert CRD: %s" , err )
141149 }
142150
@@ -166,6 +174,8 @@ func runGenerator(args ...string) {
166174 out = append (breakLine , out ... )
167175 }
168176
177+ log .Printf ("writing %v bytes" , len (out ))
178+
169179 fileName := fmt .Sprintf ("%s/%s/%s_%s.yaml" , outputDir , channel , crdRaw .Spec .Group , crdRaw .Spec .Names .Plural )
170180 err = os .WriteFile (fileName , out , 0o600 )
171181 if err != nil {
@@ -206,6 +216,8 @@ func opconTweaks(channel string, name string, jsonProps apiextensionsv1.JSONSche
206216 numExpressions := strings .Count (jsonProps .Description , validationPrefix )
207217 numValid := 0
208218 if numExpressions > 0 {
219+ log .Printf ("found validations" )
220+
209221 enumRe := regexp .MustCompile (validationPrefix + "Enum=([A-Za-z;]*)>" )
210222 enumMatches := enumRe .FindAllStringSubmatch (jsonProps .Description , 64 )
211223 for _ , enumMatch := range enumMatches {
@@ -220,7 +232,7 @@ func opconTweaks(channel string, name string, jsonProps apiextensionsv1.JSONSche
220232 }
221233 }
222234
223- celRe := regexp .MustCompile (validationPrefix + "XValidation:message =\" ([^\" ]*)\" ,rule =\" ([^\" ]*)\" >" )
235+ celRe := regexp .MustCompile (validationPrefix + "XValidation:rule =\" ([^\" ]*)\" ,message =\" ([^\" ]*)\" >" )
224236 celMatches := celRe .FindAllStringSubmatch (jsonProps .Description , 64 )
225237 for _ , celMatch := range celMatches {
226238 if len (celMatch ) != 3 {
@@ -262,6 +274,7 @@ func formatDescription(description string, channel string, name string) string {
262274 log .Fatalf ("Invalid <opcon:experimental:description> tag for %s" , name )
263275 }
264276 description = re .ReplaceAllString (description , "\n \n " )
277+ log .Printf ("found experimental:description" )
265278 } else {
266279 description = strings .ReplaceAll (description , startTag , "" )
267280 description = strings .ReplaceAll (description , endTag , "" )
@@ -279,6 +292,7 @@ func formatDescription(description string, channel string, name string) string {
279292 log .Fatalf ("Invalid <opcon:util:excludeFromCRD> tag for %s" , name )
280293 }
281294 description = re .ReplaceAllString (description , "\n \n \n " )
295+ log .Printf ("found excludeFromCRD" )
282296 }
283297
284298 opconRe := regexp .MustCompile (`<opcon:.*>` )
0 commit comments