Skip to content

Commit cc43956

Browse files
committed
fix: skip empty-usage aliases in input type docs generation
Usage() checked the computed usage string which always includes options text even for alias types. Check the raw usage field on DefaultInputType instead, so UpperCamelCase aliases with empty usage are excluded from --help and generated reference docs. Add preamble note explaining the aliases. On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
1 parent d491b20 commit cc43956

5 files changed

Lines changed: 17 additions & 126 deletions

File tree

cmds/ocm/commands/ocmcmds/common/inputs/inputtype.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,16 @@ func newGenericInputSpec(data []byte, unmarshaler runtime.Unmarshaler) (*Generic
431431
func Usage(scheme InputTypeScheme) string {
432432
s := `
433433
The resource specification supports the following blob input types, specified
434-
with the field <code>type</code> in the <code>input</code> field:`
434+
with the field <code>type</code> in the <code>input</code> field:
435+
436+
UpperCamelCase type names (e.g. <code>Helm</code>) are aliases for the corresponding
437+
lowercase types (e.g. <code>helm</code>). See the lowercase entry for full documentation.`
435438
for _, t := range scheme.KnownTypeNames() {
436-
s = fmt.Sprintf("%s\n\n- Input type <code>%s</code>\n\n%s", s, t, utils.IndentLines(scheme.GetInputType(t).Usage(), " "))
439+
it := scheme.GetInputType(t)
440+
if dit, ok := it.(*DefaultInputType); ok && dit.usage == "" {
441+
continue
442+
}
443+
s = fmt.Sprintf("%s\n\n- Input type <code>%s</code>\n\n%s", s, t, utils.IndentLines(it.Usage(), " "))
437444
}
438445
return s + "\n"
439446
}

docs/reference/ocm_add_resource-configuration.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -182,37 +182,8 @@ There are several templaters that can be selected by the <code>--templater</code
182182
The resource specification supports the following blob input types, specified
183183
with the field <code>type</code> in the <code>input</code> field:
184184

185-
- Input type <code>Dir</code>
186-
187-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputExcludes</code>, <code>--inputFollowSymlinks</code>, <code>--inputIncludes</code>, <code>--inputPath</code>, <code>--inputPreserveDir</code>, <code>--mediaType</code>
188-
189-
- Input type <code>File</code>
190-
191-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>
192-
193-
- Input type <code>Git</code>
194-
195-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>
196-
197-
- Input type <code>Helm</code>
198-
199-
Options used to configure fields: <code>--hint</code>, <code>--inputCompress</code>, <code>--inputHelmRepository</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--mediaType</code>
200-
201-
- Input type <code>Maven</code>
202-
203-
Options used to configure fields: <code>--artifactId</code>, <code>--classifier</code>, <code>--extension</code>, <code>--groupId</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--url</code>
204-
205-
- Input type <code>NPM</code>
206-
207-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>, <code>--package</code>
208-
209-
- Input type <code>UTF8</code>
210-
211-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputFormattedJson</code>, <code>--inputJson</code>, <code>--inputText</code>, <code>--inputYaml</code>, <code>--mediaType</code>
212-
213-
- Input type <code>Wget</code>
214-
215-
Options used to configure fields: <code>--body</code>, <code>--header</code>, <code>--mediaType</code>, <code>--noredirect</code>, <code>--url</code>, <code>--verb</code>
185+
UpperCamelCase type names (e.g. <code>Helm</code>) are aliases for the corresponding
186+
lowercase types (e.g. <code>helm</code>). See the lowercase entry for full documentation.
216187

217188
- Input type <code>binary</code>
218189

docs/reference/ocm_add_resources.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,8 @@ There are several templaters that can be selected by the <code>--templater</code
194194
The resource specification supports the following blob input types, specified
195195
with the field <code>type</code> in the <code>input</code> field:
196196

197-
- Input type <code>Dir</code>
198-
199-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputExcludes</code>, <code>--inputFollowSymlinks</code>, <code>--inputIncludes</code>, <code>--inputPath</code>, <code>--inputPreserveDir</code>, <code>--mediaType</code>
200-
201-
- Input type <code>File</code>
202-
203-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>
204-
205-
- Input type <code>Git</code>
206-
207-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>
208-
209-
- Input type <code>Helm</code>
210-
211-
Options used to configure fields: <code>--hint</code>, <code>--inputCompress</code>, <code>--inputHelmRepository</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--mediaType</code>
212-
213-
- Input type <code>Maven</code>
214-
215-
Options used to configure fields: <code>--artifactId</code>, <code>--classifier</code>, <code>--extension</code>, <code>--groupId</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--url</code>
216-
217-
- Input type <code>NPM</code>
218-
219-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>, <code>--package</code>
220-
221-
- Input type <code>UTF8</code>
222-
223-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputFormattedJson</code>, <code>--inputJson</code>, <code>--inputText</code>, <code>--inputYaml</code>, <code>--mediaType</code>
224-
225-
- Input type <code>Wget</code>
226-
227-
Options used to configure fields: <code>--body</code>, <code>--header</code>, <code>--mediaType</code>, <code>--noredirect</code>, <code>--url</code>, <code>--verb</code>
197+
UpperCamelCase type names (e.g. <code>Helm</code>) are aliases for the corresponding
198+
lowercase types (e.g. <code>helm</code>). See the lowercase entry for full documentation.
228199

229200
- Input type <code>binary</code>
230201

docs/reference/ocm_add_source-configuration.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -182,37 +182,8 @@ There are several templaters that can be selected by the <code>--templater</code
182182
The resource specification supports the following blob input types, specified
183183
with the field <code>type</code> in the <code>input</code> field:
184184

185-
- Input type <code>Dir</code>
186-
187-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputExcludes</code>, <code>--inputFollowSymlinks</code>, <code>--inputIncludes</code>, <code>--inputPath</code>, <code>--inputPreserveDir</code>, <code>--mediaType</code>
188-
189-
- Input type <code>File</code>
190-
191-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>
192-
193-
- Input type <code>Git</code>
194-
195-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>
196-
197-
- Input type <code>Helm</code>
198-
199-
Options used to configure fields: <code>--hint</code>, <code>--inputCompress</code>, <code>--inputHelmRepository</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--mediaType</code>
200-
201-
- Input type <code>Maven</code>
202-
203-
Options used to configure fields: <code>--artifactId</code>, <code>--classifier</code>, <code>--extension</code>, <code>--groupId</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--url</code>
204-
205-
- Input type <code>NPM</code>
206-
207-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>, <code>--package</code>
208-
209-
- Input type <code>UTF8</code>
210-
211-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputFormattedJson</code>, <code>--inputJson</code>, <code>--inputText</code>, <code>--inputYaml</code>, <code>--mediaType</code>
212-
213-
- Input type <code>Wget</code>
214-
215-
Options used to configure fields: <code>--body</code>, <code>--header</code>, <code>--mediaType</code>, <code>--noredirect</code>, <code>--url</code>, <code>--verb</code>
185+
UpperCamelCase type names (e.g. <code>Helm</code>) are aliases for the corresponding
186+
lowercase types (e.g. <code>helm</code>). See the lowercase entry for full documentation.
216187

217188
- Input type <code>binary</code>
218189

docs/reference/ocm_add_sources.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -192,37 +192,8 @@ There are several templaters that can be selected by the <code>--templater</code
192192
The resource specification supports the following blob input types, specified
193193
with the field <code>type</code> in the <code>input</code> field:
194194

195-
- Input type <code>Dir</code>
196-
197-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputExcludes</code>, <code>--inputFollowSymlinks</code>, <code>--inputIncludes</code>, <code>--inputPath</code>, <code>--inputPreserveDir</code>, <code>--mediaType</code>
198-
199-
- Input type <code>File</code>
200-
201-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>
202-
203-
- Input type <code>Git</code>
204-
205-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>
206-
207-
- Input type <code>Helm</code>
208-
209-
Options used to configure fields: <code>--hint</code>, <code>--inputCompress</code>, <code>--inputHelmRepository</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--mediaType</code>
210-
211-
- Input type <code>Maven</code>
212-
213-
Options used to configure fields: <code>--artifactId</code>, <code>--classifier</code>, <code>--extension</code>, <code>--groupId</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--url</code>
214-
215-
- Input type <code>NPM</code>
216-
217-
Options used to configure fields: <code>--inputRepository</code>, <code>--inputVersion</code>, <code>--package</code>
218-
219-
- Input type <code>UTF8</code>
220-
221-
Options used to configure fields: <code>--inputCompress</code>, <code>--inputFormattedJson</code>, <code>--inputJson</code>, <code>--inputText</code>, <code>--inputYaml</code>, <code>--mediaType</code>
222-
223-
- Input type <code>Wget</code>
224-
225-
Options used to configure fields: <code>--body</code>, <code>--header</code>, <code>--mediaType</code>, <code>--noredirect</code>, <code>--url</code>, <code>--verb</code>
195+
UpperCamelCase type names (e.g. <code>Helm</code>) are aliases for the corresponding
196+
lowercase types (e.g. <code>helm</code>). See the lowercase entry for full documentation.
226197

227198
- Input type <code>binary</code>
228199

0 commit comments

Comments
 (0)