@@ -166,6 +166,14 @@ var veleroCommandPattern = regexp.MustCompile(`(?m)(?:^|[\s\x60])velero\s+(?:` +
166166 `(?:version|install|uninstall|plugin|snapshot-location|backup-location|restic|repo|client|completion|bug|debug|datamover)` +
167167 `)` )
168168
169+ // veleroCreateVerbFirstPattern matches upstream Velero's "velero create <resource>" example
170+ // text (verb-first), which some commands hardcode instead of the actual resource-first
171+ // invocation. For example, velero's schedule create command is invoked as
172+ // "velero schedule create NAME", but its upstream Example text says "velero create schedule
173+ // NAME". veleroCommandPattern above doesn't catch this ordering, so it's normalized to
174+ // resource-first form here before the general replacement runs.
175+ var veleroCreateVerbFirstPattern = regexp .MustCompile (`(^|[\s\x60\n])velero\s+create\s+(backup|restore|schedule)\b` )
176+
169177// replaceVeleroCommandWithOADP performs context-aware replacement of "velero" with "oadp".
170178// It only replaces "velero" when it's being used as a CLI command, not when referring to
171179// the Velero project, server, or components.
@@ -174,6 +182,11 @@ func replaceVeleroCommandWithOADP(text string) string {
174182 // Use "oc" as the CLI prefix since OADP is primarily used on OpenShift
175183 cliPrefix := "oc"
176184
185+ // Normalize verb-first "velero create <resource>" examples to resource-first
186+ // "oc oadp <resource> create" before the general pattern runs, since the actual
187+ // command is always invoked resource-first.
188+ text = veleroCreateVerbFirstPattern .ReplaceAllString (text , "${1}" + cliPrefix + " oadp ${2} create" )
189+
177190 // Replace "velero <command>" patterns with "oc/kubectl oadp <command>"
178191 result := veleroCommandPattern .ReplaceAllStringFunc (text , func (match string ) string {
179192 // Preserve leading whitespace or backtick
0 commit comments