Skip to content

Commit

Permalink
chore: fixes for docu + cleanup test leftovers (#993)
Browse files Browse the repository at this point in the history
<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
  • Loading branch information
mandelsoft authored Oct 21, 2024
1 parent 4ad368d commit 50cb639
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 284 deletions.
2 changes: 1 addition & 1 deletion api/ocm/extensions/accessmethods/s3/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func init() {

anon := accspeccpi.MustNewAccessSpecMultiFormatVersion(Type, formats)
Must(versions.Register(accspeccpi.NewAccessSpecTypeByFormatVersion(Type, anon, accspeccpi.WithDescription(usage), accspeccpi.WithConfigHandler(ConfigHandler()))))
Must(versions.Register(accspeccpi.NewAccessSpecTypeByFormatVersion(LegacyType, anon, accspeccpi.WithDescription(usage))))
Must(versions.Register(accspeccpi.NewAccessSpecTypeByFormatVersion(LegacyType, anon)))
accspeccpi.RegisterAccessTypeVersions(versions)
}

Expand Down
2 changes: 0 additions & 2 deletions api/ocm/extensions/attrs/mapocirepoattr/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ Notes:
- The mapping only occurs in transfer commands and only when transferring to OCI registries (e.g.
when transferring to a CTF archive this option will be ignored).
- The mapping only happens for local resources. When external image references are transferred (with
option --copy-resources) the mapping will be ignored.
- The mapping in mode <code>prefixMapping</code> requires a full prefix of the composed final name.
Partial matches are not supported. The host name of the target will be skipped.
- The artifact name of the component-descriptor is not mapped.
Expand Down
10 changes: 7 additions & 3 deletions api/ocm/extensions/repositories/genericocireg/annotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "ocm.software/ocm/api/helper/builder"

"ocm.software/ocm/api/oci/extensions/repositories/ctf"
metav1 "ocm.software/ocm/api/ocm/compdesc/meta/v1"
resourcetypes "ocm.software/ocm/api/ocm/extensions/artifacttypes"
"ocm.software/ocm/api/ocm/extensions/repositories/genericocireg"
"ocm.software/ocm/api/utils/accessio"
"ocm.software/ocm/api/utils/accessobj"
"ocm.software/ocm/api/utils/mime"
"ocm.software/ocm/api/version"
)

const (
Expand Down Expand Up @@ -63,6 +64,9 @@ var _ = Describe("Transfer handler", func() {
Expect(v.GetDescriptor()).To(YAMLEqual(`
mediaType: application/vnd.oci.image.manifest.v1+json
schemaVersion: 2
annotations:
` + genericocireg.OCM_COMPONENTVERSION + `: github.com/mandelsoft/ocm:v1
` + genericocireg.OCM_CREATOR + `: OCM Go Library ` + version.Current() + `
config:
digest: sha256:edf034a303e8cc7e5a05c522bb5fc74a09a00ed3aca390ffafba1020c97470cc
mediaType: application/vnd.ocm.software.component.config.v1+json
Expand All @@ -72,12 +76,12 @@ var _ = Describe("Transfer handler", func() {
mediaType: application/vnd.ocm.software.component-descriptor.v2+yaml+tar
size: 3584
- annotations:
ocm-artifact: '[{"kind":"resource","identity":{"name":"test1"}},{"kind":"resource","identity":{"name":"test2"}}]'
` + genericocireg.OCM_ARTIFACT + `: '[{"kind":"resource","identity":{"name":"test1"}},{"kind":"resource","identity":{"name":"test2"}}]'
digest: sha256:2e99758548972a8e8822ad47fa1017ff72f06f3ff6a016851f45c398732bc50c
mediaType: text/plain
size: 14
- annotations:
ocm-artifact: '[{"kind":"resource","identity":{"name":"test3"}},{"kind":"source","identity":{"name":"test4"}}]'
` + genericocireg.OCM_ARTIFACT + `: '[{"kind":"resource","identity":{"name":"test3"}},{"kind":"source","identity":{"name":"test4"}}]'
digest: sha256:f69bff44070ba35d7169196ba0095425979d96346a31486b507b4a3f77bd356d
mediaType: text/plain
size: 20
Expand Down
15 changes: 12 additions & 3 deletions api/ocm/extensions/repositories/genericocireg/componentversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
common "ocm.software/ocm/api/utils/misc"
"ocm.software/ocm/api/utils/refmgmt"
"ocm.software/ocm/api/utils/runtime"
"ocm.software/ocm/api/version"
)

// newComponentVersionAccess creates a component access for the artifact access, if this fails the artifact acess is closed.
Expand Down Expand Up @@ -158,9 +159,11 @@ type ArtifactInfo struct {
}

const (
ARTKIND_RESOURCE = "resource"
ARTKIND_SOURCE = "source"
OCM_ARTIFACT = "ocm-artifact"
OCM_COMPONENTVERSION = "software.ocm.componentversion"
OCM_CREATOR = "software.ocm.creator"
OCM_ARTIFACT = "software.ocm.artifact"
ARTKIND_RESOURCE = "resource"
ARTKIND_SOURCE = "source"
)

func (c *ComponentVersionContainer) Update() (bool, error) {
Expand Down Expand Up @@ -213,6 +216,12 @@ func (c *ComponentVersionContainer) Update() (bool, error) {
}
m := c.manifest.GetDescriptor()

if m.Annotations == nil {
m.Annotations = map[string]string{}
}
m.Annotations[OCM_COMPONENTVERSION] = common.VersionedElementKey(c.bridge).String()
m.Annotations[OCM_CREATOR] = "OCM Go Library " + version.Current()

for layer, info := range layerAnnotations {
data, err := runtime.DefaultJSONEncoding.Marshal(info)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ var _ = Describe("Input Type", func() {
Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", VERSION, "--provider", "mandelsoft", "--file", ARCH)).To(Succeed())
})

AfterEach(func() {
env.Cleanup()
})

It("add npm from npm registry described by cli options", func() {
meta := `
name: testdata
Expand Down
1 change: 0 additions & 1 deletion cmds/ocm/commands/ocmcmds/resources/download/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ var _ = Describe("Test Environment", func() {
Expect(err).To(Succeed())

BeforeEach(func() {
env = NewTestEnv()
data, err := rsa.KeyData(pub)
Expect(err).To(Succeed())
Expect(vfs.WriteFile(env.FileSystem(), PUBKEY, data, os.ModePerm)).To(Succeed())
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/ocm.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ The value can be a simple type or a JSON/YAML string for complex values

- The mapping only occurs in transfer commands and only when transferring to OCI registries (e.g.
when transferring to a CTF archive this option will be ignored).
- The mapping only happens for local resources. When external image references are transferred (with
option --copy-resources) the mapping will be ignored.
- The mapping in mode <code>prefixMapping</code> requires a full prefix of the composed final name.
Partial matches are not supported. The host name of the target will be skipped.
- The artifact name of the component-descriptor is not mapped.
Expand Down
54 changes: 0 additions & 54 deletions docs/reference/ocm_add_resource-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,60 +607,6 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>S3</code>

This method implements the access of a blob stored in an S3 bucket.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucket</code>** *string*

The name of the S3 bucket containing the blob

- **<code>key</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content

- Version <code>v2</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucketName</code>** *string*

The name of the S3 bucket containing the blob

- **<code>objectKey</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content


- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
54 changes: 0 additions & 54 deletions docs/reference/ocm_add_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,60 +618,6 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>S3</code>

This method implements the access of a blob stored in an S3 bucket.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucket</code>** *string*

The name of the S3 bucket containing the blob

- **<code>key</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content

- Version <code>v2</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucketName</code>** *string*

The name of the S3 bucket containing the blob

- **<code>objectKey</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content


- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
54 changes: 0 additions & 54 deletions docs/reference/ocm_add_source-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,60 +607,6 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>S3</code>

This method implements the access of a blob stored in an S3 bucket.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucket</code>** *string*

The name of the S3 bucket containing the blob

- **<code>key</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content

- Version <code>v2</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucketName</code>** *string*

The name of the S3 bucket containing the blob

- **<code>objectKey</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content


- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
54 changes: 0 additions & 54 deletions docs/reference/ocm_add_sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,60 +616,6 @@ The access method specification can be put below the <code>access</code> field.
If always requires the field <code>type</code> describing the kind and version
shown below.

- Access type <code>S3</code>

This method implements the access of a blob stored in an S3 bucket.

The following versions are supported:
- Version <code>v1</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucket</code>** *string*

The name of the S3 bucket containing the blob

- **<code>key</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content

- Version <code>v2</code>

The type specific specification fields are:

- **<code>region</code>** (optional) *string*

OCI repository reference (this artifact name used to store the blob).

- **<code>bucketName</code>** *string*

The name of the S3 bucket containing the blob

- **<code>objectKey</code>** *string*

The key of the desired blob

- **<code>version</code>** (optional) *string*

The key of the desired blob

- **<code>mediaType</code>** (optional) *string*

The media type of the content


- Access type <code>gitHub</code>

This method implements the access of the content of a git commit stored in a
Expand Down
2 changes: 0 additions & 2 deletions docs/reference/ocm_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ OCM library:

- The mapping only occurs in transfer commands and only when transferring to OCI registries (e.g.
when transferring to a CTF archive this option will be ignored).
- The mapping only happens for local resources. When external image references are transferred (with
option --copy-resources) the mapping will be ignored.
- The mapping in mode <code>prefixMapping</code> requires a full prefix of the composed final name.
Partial matches are not supported. The host name of the target will be skipped.
- The artifact name of the component-descriptor is not mapped.
Expand Down
Loading

0 comments on commit 50cb639

Please sign in to comment.