Skip to content

Commit bf7a925

Browse files
implemented logic for excluding comments from CRD generation
1 parent ff517b3 commit bf7a925

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pkg/generator/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,19 @@ func gatewayTweaks(channel string, props map[string]apiext.JSONSchemaProps) map[
222222
jsonProps.Description = strings.ReplaceAll(jsonProps.Description, endTag, "")
223223
}
224224

225+
startTag = "<gateway:util:excludeFromCRD>"
226+
endTag = "</gateway:util:excludeFromCRD>"
227+
regexPattern = `(?:\r?\n)*` + regexp.QuoteMeta(startTag) + `(?s:(.*?))` + regexp.QuoteMeta(endTag) + `(?:\r?\n)*`
228+
if strings.Contains(jsonProps.Description, "<gateway:util:excludeFromCRD>") {
229+
re := regexp.MustCompile(regexPattern)
230+
match := re.FindStringSubmatch(jsonProps.Description)
231+
if len(match) != 2 {
232+
log.Fatalf("Invalid <gateway:util:excludeFromCRD> tag for %s", name)
233+
}
234+
modifiedDescription := re.ReplaceAllString(jsonProps.Description, "\n\n")
235+
jsonProps.Description = modifiedDescription
236+
}
237+
225238
if numValid < numExpressions {
226239
fmt.Printf("Description: %s\n", jsonProps.Description)
227240
log.Fatalf("Found %d Gateway validation expressions, but only %d were valid", numExpressions, numValid)

0 commit comments

Comments
 (0)