Skip to content

Commit df29bb3

Browse files
chore: add upper camel case types (#1881)
On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> <!-- markdownlint-disable MD041 --> #### What this PR does / why we need it add upper camel case types for input and access --------- Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> Co-authored-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
1 parent bce4f1f commit df29bb3

11 files changed

Lines changed: 688 additions & 4 deletions

File tree

api/ocm/extensions/accessmethods/helm/method.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ import (
2121
const (
2222
Type = "helm"
2323
TypeV1 = Type + runtime.VersionSeparator + "v1"
24+
25+
UpperType = "Helm"
26+
UpperTypeV1 = UpperType + runtime.VersionSeparator + "v1"
2427
)
2528

2629
func init() {
2730
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](Type, accspeccpi.WithDescription(usage)))
2831
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](TypeV1, accspeccpi.WithFormatSpec(formatV1), accspeccpi.WithConfigHandler(ConfigHandler())))
32+
33+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](UpperType))
34+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](UpperTypeV1))
2935
}
3036

3137
// New creates a new Helm Chart accessor for helm repositories.

api/ocm/extensions/accessmethods/localblob/method.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import (
1515
const (
1616
Type = "localBlob"
1717
TypeV1 = Type + runtime.VersionSeparator + "v1"
18+
19+
UpperType = "LocalBlob"
20+
UpperTypeV1 = UpperType + runtime.VersionSeparator + "v1"
1821
)
1922

2023
// this package shows how to implement access types with multiple serialization versions.
@@ -51,6 +54,9 @@ func init() {
5154
Must(versions.Register(accspeccpi.NewAccessSpecTypeByConverter[*AccessSpec, *AccessSpecV1](Type, &converterV1{}, accspeccpi.WithDescription(usage))))
5255
Must(versions.Register(accspeccpi.NewAccessSpecTypeByConverter[*AccessSpec, *AccessSpecV1](TypeV1, &converterV1{}, accspeccpi.WithFormatSpec(formatV1), accspeccpi.WithConfigHandler(ConfigHandler()))))
5356
accspeccpi.RegisterAccessTypeVersions(versions)
57+
58+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecTypeByConverter[*AccessSpec, *AccessSpecV1](UpperType, &converterV1{}))
59+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecTypeByConverter[*AccessSpec, *AccessSpecV1](UpperTypeV1, &converterV1{}))
5460
}
5561

5662
func Is(spec accspeccpi.AccessSpec) bool {

api/ocm/extensions/accessmethods/ociblob/method.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ import (
2121
const (
2222
Type = "ociBlob"
2323
TypeV1 = Type + runtime.VersionSeparator + "v1"
24+
25+
UpperType = "OCIImageLayer"
26+
UpperTypeV1 = UpperType + runtime.VersionSeparator + "v1"
2427
)
2528

2629
func init() {
2730
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](Type, accspeccpi.WithDescription(usage)))
2831
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](TypeV1, accspeccpi.WithFormatSpec(formatV1), accspeccpi.WithConfigHandler(ConfigHandler())))
32+
33+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](UpperType))
34+
accspeccpi.RegisterAccessType(accspeccpi.NewAccessSpecType[*AccessSpec](UpperTypeV1))
2935
}
3036

3137
// New creates a new OCIBlob accessor.

cmds/ocm/commands/ocmcmds/common/inputs/types/directory/type.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ import (
55
"ocm.software/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
66
)
77

8-
const TYPE = "dir"
8+
const (
9+
TYPE = "dir"
10+
UPPER_TYPE = "Dir"
11+
)
912

1013
func init() {
1114
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(TYPE, &Spec{}, usage, ConfigHandler()))
15+
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(UPPER_TYPE, &Spec{}, usage, ConfigHandler()))
1216
}
1317

1418
const usage = `

cmds/ocm/commands/ocmcmds/common/inputs/types/file/type.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ import (
44
"ocm.software/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
55
)
66

7-
const TYPE = "file"
7+
const (
8+
TYPE = "file"
9+
UPPER_TYPE = "File"
10+
)
811

912
func init() {
1013
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(TYPE, &Spec{},
1114
Usage("The path must denote a file relative the resources file. "), ConfigHandler()))
15+
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(UPPER_TYPE, &Spec{},
16+
Usage("The path must denote a file relative the resources file. "), ConfigHandler()))
1217
}

cmds/ocm/commands/ocmcmds/common/inputs/types/helm/type.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import (
44
"ocm.software/ocm/cmds/ocm/commands/ocmcmds/common/inputs"
55
)
66

7-
const TYPE = "helm"
7+
const (
8+
TYPE = "helm"
9+
UPPER_TYPE = "Helm"
10+
)
811

912
func init() {
1013
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(TYPE, &Spec{}, usage, ConfigHandler()))
14+
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(UPPER_TYPE, &Spec{}, usage, ConfigHandler()))
1115
}
1216

1317
const usage = `

cmds/ocm/commands/ocmcmds/common/inputs/types/utf8/type.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ import (
55
"ocm.software/ocm/cmds/ocm/commands/ocmcmds/common/inputs/cpi"
66
)
77

8-
const TYPE = "utf8"
8+
const (
9+
TYPE = "utf8"
10+
UPPER_TYPE = "UTF8"
11+
)
912

1013
func init() {
1114
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(TYPE, &Spec{},
1215
usage, ConfigHandler()))
16+
inputs.DefaultInputTypeScheme.Register(inputs.NewInputType(UPPER_TYPE, &Spec{},
17+
usage, ConfigHandler()))
1318
}
1419

1520
const usage = `

docs/reference/ocm_add_resource-configuration.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,168 @@ 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+
The path must denote a directory relative to the resources file, which is packed
188+
with tar and optionally compressed
189+
if the <code>compress</code> field is set to <code>true</code>. If the field
190+
<code>preserveDir</code> is set to true the directory itself is added to the tar.
191+
If the field <code>followSymLinks</code> is set to <code>true</code>, symbolic
192+
links are not packed but their targets files or folders.
193+
With the list fields <code>includeFiles</code> and <code>excludeFiles</code> it is
194+
possible to specify which files should be included or excluded. The values are
195+
regular expression used to match relative file paths. If no includes are specified
196+
all file not explicitly excluded are used.
197+
198+
This blob type specification supports the following fields:
199+
- **<code>path</code>** *string*
200+
201+
This REQUIRED property describes the file path to directory relative to the
202+
resource file location.
203+
204+
- **<code>mediaType</code>** *string*
205+
206+
This OPTIONAL property describes the media type to store with the local blob.
207+
The default media type is application/x-tar and
208+
application/gzip if compression is enabled.
209+
210+
- **<code>compress</code>** *bool*
211+
212+
This OPTIONAL property describes whether the file content should be stored
213+
compressed or not.
214+
215+
- **<code>preserveDir</code>** *bool*
216+
217+
This OPTIONAL property describes whether the specified directory with its
218+
basename should be included as top level folder.
219+
220+
- **<code>followSymlinks</code>** *bool*
221+
222+
This OPTIONAL property describes whether symbolic links should be followed or
223+
included as links.
224+
225+
- **<code>excludeFiles</code>** *list of regex*
226+
227+
This OPTIONAL property describes regular expressions used to match files
228+
that should NOT be included in the tar file. It takes precedence over
229+
the include match.
230+
231+
- **<code>includeFiles</code>** *list of regex*
232+
233+
This OPTIONAL property describes regular expressions used to match files
234+
that should be included in the tar file. If this option is not given
235+
all files not explicitly excluded are used.
236+
237+
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>
238+
239+
- Input type <code>File</code>
240+
241+
The path must denote a file relative the resources file.
242+
The content is compressed if the <code>compress</code> field
243+
is set to <code>true</code>.
244+
245+
This blob type specification supports the following fields:
246+
- **<code>path</code>** *string*
247+
248+
This REQUIRED property describes the path to the file relative to the
249+
resource file location.
250+
251+
- **<code>mediaType</code>** *string*
252+
253+
This OPTIONAL property describes the media type to store with the local blob.
254+
The default media type is application/octet-stream and
255+
application/gzip if compression is enabled.
256+
257+
- **<code>compress</code>** *bool*
258+
259+
This OPTIONAL property describes whether the content should be stored
260+
compressed or not.
261+
262+
Options used to configure fields: <code>--inputCompress</code>, <code>--inputPath</code>, <code>--mediaType</code>
263+
264+
- Input type <code>Helm</code>
265+
266+
The path must denote an helm chart archive or directory
267+
relative to the resources file or a chart name in a helm chart repository.
268+
The denoted chart is packed as an OCI artifact set.
269+
For the filesystem version additional provider info is taken from a file with
270+
the same name and the suffix <code>.prov</code>.
271+
272+
If the chart should just be stored as plain archive, please use the
273+
type <code>file</code> or <code>dir</code>, instead.
274+
275+
This blob type specification supports the following fields:
276+
- **<code>path</code>** *string*
277+
278+
This REQUIRED property describes the file path to the helm chart relative to the
279+
resource file location.
280+
281+
- **<code>version</code>** *string*
282+
283+
This OPTIONAL property can be set to configure an explicit version hint.
284+
If not specified the version from the chart will be used.
285+
Basically, it is a good practice to use the component version for local resources
286+
This can be achieved by using templating for this attribute in the resource file.
287+
288+
- **<code>helmRepository</code>** *string*
289+
290+
This OPTIONAL property can be set, if the helm chart should be loaded from
291+
a helm repository instead of the local filesystem. It describes
292+
the base URL of the chart repository. If specified, the <code>path</code> field
293+
must describe the name of the chart in the chart repository, and <code>version</code>
294+
must describe the version of the chart imported from the chart repository
295+
296+
- **<code>repository</code>** *string*
297+
298+
This OPTIONAL property can be used to specify the repository hint for the
299+
generated local artifact access. It is prefixed by the component name if
300+
it does not start with slash "/".
301+
302+
- **<code>caCertFile</code>** *string*
303+
304+
This OPTIONAL property can be used to specify a relative filename for
305+
the TLS root certificate used to access a helm repository.
306+
307+
- **<code>caCert</code>** *string*
308+
309+
This OPTIONAL property can be used to specify a TLS root certificate used to
310+
access a helm repository.
311+
312+
Options used to configure fields: <code>--hint</code>, <code>--inputCompress</code>, <code>--inputHelmRepository</code>, <code>--inputPath</code>, <code>--inputVersion</code>, <code>--mediaType</code>
313+
314+
- Input type <code>UTF8</code>
315+
316+
This blob type is used to provide inline text based content (UTF8). The
317+
specification supports the following fields:
318+
- **<code>text</code>** *string*
319+
320+
The utf8 string content to provide.
321+
322+
- **<code>json</code>** *JSON or JSON string interpreted as JSON*
323+
324+
The content emitted as JSON.
325+
326+
- **<code>formattedJson</code>** *YAML/JSON or JSON/YAML string interpreted as JSON*
327+
328+
The content emitted as formatted JSON.
329+
330+
- **<code>yaml</code>** *AML/JSON or JSON/YAML string interpreted as YAML*
331+
332+
The content emitted as YAML.
333+
334+
- **<code>mediaType</code>** *string*
335+
336+
This OPTIONAL property describes the media type to store with the local blob.
337+
The default media type is application/octet-stream and
338+
application/gzip if compression is enabled.
339+
340+
- **<code>compress</code>** *bool*
341+
342+
This OPTIONAL property describes whether the content should be stored
343+
compressed or not.
344+
345+
Options used to configure fields: <code>--inputCompress</code>, <code>--inputFormattedJson</code>, <code>--inputJson</code>, <code>--inputText</code>, <code>--inputYaml</code>, <code>--mediaType</code>
346+
185347
- Input type <code>binary</code>
186348

187349
This blob type is used to provide base64 encoded binary content. The

0 commit comments

Comments
 (0)