@@ -57,6 +57,7 @@ func main() {
57
57
func runGenerator (args ... string ) {
58
58
outputDir := "config/crd"
59
59
ctVer := ""
60
+ crdRoot := "github.com/operator-framework/operator-controller/api/v1"
60
61
if len (args ) >= 1 {
61
62
// Get the output directory
62
63
outputDir = args [0 ]
@@ -65,10 +66,15 @@ func runGenerator(args ...string) {
65
66
// get the controller-tools version
66
67
ctVer = args [1 ]
67
68
}
69
+ if len (args ) >= 3 {
70
+ crdRoot = args [2 ]
71
+ }
72
+
73
+ log .Printf ("crdRoot: %s" , crdRoot )
68
74
69
75
roots , err := loader .LoadRoots (
70
76
"k8s.io/apimachinery/pkg/runtime/schema" , // Needed to parse generated register functions.
71
- "github.com/operator-framework/operator-controller/api/v1" ,
77
+ crdRoot ,
72
78
)
73
79
if err != nil {
74
80
log .Fatalf ("failed to load package roots: %s" , err )
@@ -90,6 +96,7 @@ func runGenerator(args ...string) {
90
96
91
97
crd .AddKnownTypes (parser )
92
98
for _ , r := range roots {
99
+ log .Printf ("Looking at package %v" , r )
93
100
parser .NeedPackage (r )
94
101
}
95
102
@@ -137,6 +144,7 @@ func runGenerator(args ...string) {
137
144
138
145
conv , err := crd .AsVersion (* channelCrd , apiextensionsv1 .SchemeGroupVersion )
139
146
if err != nil {
147
+ log .Printf ("CRD: %v" , * channelCrd )
140
148
log .Fatalf ("failed to convert CRD: %s" , err )
141
149
}
142
150
@@ -166,6 +174,8 @@ func runGenerator(args ...string) {
166
174
out = append (breakLine , out ... )
167
175
}
168
176
177
+ log .Printf ("writing %v bytes" , len (out ))
178
+
169
179
fileName := fmt .Sprintf ("%s/%s/%s_%s.yaml" , outputDir , channel , crdRaw .Spec .Group , crdRaw .Spec .Names .Plural )
170
180
err = os .WriteFile (fileName , out , 0o600 )
171
181
if err != nil {
@@ -206,6 +216,8 @@ func opconTweaks(channel string, name string, jsonProps apiextensionsv1.JSONSche
206
216
numExpressions := strings .Count (jsonProps .Description , validationPrefix )
207
217
numValid := 0
208
218
if numExpressions > 0 {
219
+ log .Printf ("found validations" )
220
+
209
221
enumRe := regexp .MustCompile (validationPrefix + "Enum=([A-Za-z;]*)>" )
210
222
enumMatches := enumRe .FindAllStringSubmatch (jsonProps .Description , 64 )
211
223
for _ , enumMatch := range enumMatches {
@@ -220,7 +232,7 @@ func opconTweaks(channel string, name string, jsonProps apiextensionsv1.JSONSche
220
232
}
221
233
}
222
234
223
- celRe := regexp .MustCompile (validationPrefix + "XValidation:message =\" ([^\" ]*)\" ,rule =\" ([^\" ]*)\" >" )
235
+ celRe := regexp .MustCompile (validationPrefix + "XValidation:rule =\" ([^\" ]*)\" ,message =\" ([^\" ]*)\" >" )
224
236
celMatches := celRe .FindAllStringSubmatch (jsonProps .Description , 64 )
225
237
for _ , celMatch := range celMatches {
226
238
if len (celMatch ) != 3 {
@@ -262,6 +274,7 @@ func formatDescription(description string, channel string, name string) string {
262
274
log .Fatalf ("Invalid <opcon:experimental:description> tag for %s" , name )
263
275
}
264
276
description = re .ReplaceAllString (description , "\n \n " )
277
+ log .Printf ("found experimental:description" )
265
278
} else {
266
279
description = strings .ReplaceAll (description , startTag , "" )
267
280
description = strings .ReplaceAll (description , endTag , "" )
@@ -279,6 +292,7 @@ func formatDescription(description string, channel string, name string) string {
279
292
log .Fatalf ("Invalid <opcon:util:excludeFromCRD> tag for %s" , name )
280
293
}
281
294
description = re .ReplaceAllString (description , "\n \n \n " )
295
+ log .Printf ("found excludeFromCRD" )
282
296
}
283
297
284
298
opconRe := regexp .MustCompile (`<opcon:.*>` )
0 commit comments