-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(transfer): accidental extra identity defaulting during transfer (#…
…1236) <!-- markdownlint-disable MD041 --> #### What this PR does / why we need it replaces #1223 as it does not contain the revert for the normalization algorithm Introduces DisableExtraIdentityDefaulting which is enabled by default during transport because IsModifyElement is not enough to differentiate if the component version is allowed to be modified during transfer. #### Which issue(s) this PR fixes PR that tackles a case in which `ocm transfer cv` caused accidental defaults to the extra identity. --------- Co-authored-by: Uwe Krueger <uwe.krueger@sap.com>
- Loading branch information
1 parent
8a5f983
commit 3e5f69b
Showing
13 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
api/ocm/tools/transfer/transferhandler/standard/compat_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package standard_test | ||
|
||
import ( | ||
. "github.com/mandelsoft/goutils/testutils" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "ocm.software/ocm/cmds/ocm/testhelper" | ||
|
||
"ocm.software/ocm/api/ocm/extensions/repositories/ctf" | ||
"ocm.software/ocm/api/ocm/tools/transfer" | ||
"ocm.software/ocm/api/utils/accessio" | ||
"ocm.software/ocm/api/utils/accessobj" | ||
common "ocm.software/ocm/api/utils/misc" | ||
) | ||
|
||
const COMPAT_ARCH = "/testdata/v0.18.0" | ||
const COMPAT_COMP = "github.com/mandelsoft/test1" | ||
const COMPAT_VERS = "1.0.0" | ||
|
||
var _ = Describe("Transfer Test Environment", func() { | ||
Context("extraid compatibility transfer", func() { | ||
|
||
var env *TestEnv | ||
|
||
BeforeEach(func() { | ||
env = NewTestEnv(TestData()) | ||
}) | ||
|
||
It("", func() { | ||
src := Must(ctf.Open(env.OCMContext(), accessobj.ACC_READONLY, COMPAT_ARCH, 0, env)) | ||
defer Close(src, "source") | ||
cv := Must(src.LookupComponentVersion(COMPAT_COMP, COMPAT_VERS)) | ||
defer Close(cv, "source cv") | ||
tgt := Must(ctf.Create(env.OCMContext(), accessobj.ACC_WRITABLE|accessobj.ACC_CREATE, OUT, 0o700, accessio.FormatDirectory, env)) | ||
defer Close(tgt, "target") | ||
|
||
p, buf := common.NewBufferedPrinter() | ||
MustBeSuccessful(transfer.Transfer(cv, tgt, transfer.WithPrinter(p))) | ||
Expect(env.DirExists(OUT)).To(BeTrue()) | ||
|
||
Expect(buf.String()).To(StringEqualTrimmedWithContext(` | ||
transferring version "github.com/mandelsoft/test1:1.0.0"... | ||
...resource 0 multi-implicit[plainText]... | ||
...resource 1 multi-implicit[plainText]... | ||
...resource 2 multi-explicit[plainText]... | ||
...resource 3 multi-explicit[plainText]... | ||
...source 0 multi-implicit[plainText]... | ||
...source 1 multi-implicit[plainText]... | ||
...source 2 multi-explicit[plainText]... | ||
...source 3 multi-explicit[plainText]... | ||
...adding component version... | ||
`)) | ||
|
||
tcv := Must(tgt.LookupComponentVersion(COMPAT_COMP, COMPAT_VERS)) | ||
defer Close(tcv, "target cv") | ||
Expect(tcv.GetDescriptor()).To(YAMLEqual(cv.GetDescriptor())) | ||
|
||
Expect(tcv.GetDescriptor().Resources[0].ExtraIdentity).To(BeNil()) | ||
Expect(tcv.GetDescriptor().Resources[1].ExtraIdentity).To(BeNil()) | ||
Expect(tcv.GetDescriptor().Sources[0].ExtraIdentity).To(BeNil()) | ||
Expect(tcv.GetDescriptor().Sources[1].ExtraIdentity).To(BeNil()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
api/ocm/tools/transfer/transferhandler/standard/testdata/v0.18.0/artifact-index.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"schemaVersion":1,"artifacts":[{"repository":"component-descriptors/github.com/mandelsoft/test1","tag":"1.0.0","digest":"sha256:210dda6808d47862660fdf5753d17e2b6152ff31fbd07ff947b821f717f1232a"}]} |
1 change: 1 addition & 0 deletions
1
...ata/v0.18.0/blobs/sha256.210dda6808d47862660fdf5753d17e2b6152ff31fbd07ff947b821f717f1232a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"schemaVersion":2,"mediaType":"application/vnd.oci.image.manifest.v1+json","config":{"mediaType":"application/vnd.ocm.software.component.config.v1+json","digest":"sha256:958eb6b2928a569d7aaab2aa924fb236e977bfbc43309908aa9c45b154f689cd","size":201},"layers":[{"mediaType":"application/vnd.ocm.software.component-descriptor.v2+yaml+tar","digest":"sha256:a4b84597729cfa026c51a47e903f449ad7b4a9ec9897f2084b982a66fcdbfb5f","size":4608},{"mediaType":"application/octet-stream","digest":"sha256:916f0027a575074ce72a331777c3478d6513f786a591bd892da1a577bf2335f9","size":9,"annotations":{"software.ocm.artifact":"[{\"kind\":\"resource\",\"identity\":{\"name\":\"multi-implicit\",\"version\":\"v1\"}},{\"kind\":\"resource\",\"identity\":{\"name\":\"multi-explicit\",\"version\":\"v1\"}},{\"kind\":\"source\",\"identity\":{\"name\":\"multi-implicit\",\"version\":\"v1\"}},{\"kind\":\"source\",\"identity\":{\"name\":\"multi-explicit\",\"version\":\"v1\"}}]"}},{"mediaType":"application/octet-stream","digest":"sha256:920ce99fb13b43ca0408caee6e61f6335ea5156d79aa98e733e1ed2393e0f649","size":18,"annotations":{"software.ocm.artifact":"[{\"kind\":\"resource\",\"identity\":{\"name\":\"multi-implicit\",\"version\":\"v2\"}},{\"kind\":\"resource\",\"identity\":{\"name\":\"multi-explicit\",\"version\":\"v2\"}},{\"kind\":\"source\",\"identity\":{\"name\":\"multi-implicit\",\"version\":\"v2\"}},{\"kind\":\"source\",\"identity\":{\"name\":\"multi-explicit\",\"version\":\"v2\"}}]"}}],"annotations":{"software.ocm.componentversion":"github.com/mandelsoft/test1:1.0.0","software.ocm.creator":"OCM Go Library 0.18.0"}} |
1 change: 1 addition & 0 deletions
1
...ata/v0.18.0/blobs/sha256.916f0027a575074ce72a331777c3478d6513f786a591bd892da1a577bf2335f9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test data |
1 change: 1 addition & 0 deletions
1
...ata/v0.18.0/blobs/sha256.920ce99fb13b43ca0408caee6e61f6335ea5156d79aa98e733e1ed2393e0f649
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
extended test data |
1 change: 1 addition & 0 deletions
1
...ata/v0.18.0/blobs/sha256.958eb6b2928a569d7aaab2aa924fb236e977bfbc43309908aa9c45b154f689cd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"componentDescriptorLayer":{"mediaType":"application/vnd.ocm.software.component-descriptor.v2+yaml+tar","digest":"sha256:a4b84597729cfa026c51a47e903f449ad7b4a9ec9897f2084b982a66fcdbfb5f","size":4608}} |
Binary file added
BIN
+4.5 KB
...ata/v0.18.0/blobs/sha256.a4b84597729cfa026c51a47e903f449ad7b4a9ec9897f2084b982a66fcdbfb5f
Binary file not shown.