-
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.
## Description The transfer of OCI indix manifests accidently rewrites the manifest, even if it has not been changed during a transfer step. ## What type of PR is this? (check all applicable) - [ ] 🍕 Feature - [ ] 🐛 Bug Fix - [ ] 📝 Documentation Update - [ ] 🎨 Style - [ ] 🧑💻 Code Refactor - [ ] 🔥 Performance Improvements - [ ] ✅ Test - [ ] 🤖 Build - [ ] 🔁 CI - [ ] 📦 Chore (Release) - [ ] ⏩ Revert ## Related Tickets & Documents <!-- Please use this format link issue numbers: Fixes #123 https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword --> - Related Issue # (issue) - Closes # (issue) - Fixes # (issue) > Remove if not applicable ## Screenshots <!-- Visual changes require screenshots --> ## Added tests? - [ ] 👍 yes - [ ] 🙅 no, because they aren't needed - [ ] 🙋 no, because I need help - [ ] Separate ticket for tests # (issue/pr) Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration ## Added to documentation? - [ ] 📜 README.md - [ ] 🙅 no documentation needed ## Checklist: - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
- Loading branch information
1 parent
f3416ae
commit e4d14a1
Showing
5 changed files
with
169 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Open Component Model contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package cpi | ||
|
||
import ( | ||
"github.com/opencontainers/go-digest" | ||
|
||
"github.com/open-component-model/ocm/pkg/common/accessobj" | ||
"github.com/open-component-model/ocm/pkg/contexts/oci/artdesc" | ||
) | ||
|
||
type _Artifact = artdesc.Artifact | ||
|
||
type modifiedArtifact struct { | ||
state accessobj.State | ||
*_Artifact | ||
} | ||
|
||
var _ Artifact = (*modifiedArtifact)(nil) | ||
|
||
// NewArtifact provides a copy of the given artifact, | ||
// which will keep track of the original serialization. | ||
// This one is used as long as the artifact is unchanged. | ||
// (the returned underlying implementation of the Artifact interface | ||
// might differ from the original one). | ||
func NewArtifact(art Artifact) (Artifact, error) { | ||
blob, err := art.Blob() | ||
if err != nil { | ||
return nil, err | ||
} | ||
state, err := accessobj.NewBlobStateForBlob(accessobj.ACC_WRITABLE, blob, NewArtifactStateHandler()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &modifiedArtifact{ | ||
_Artifact: state.GetState().(*_Artifact), | ||
state: state, | ||
}, nil | ||
} | ||
|
||
func (a *modifiedArtifact) Blob() (BlobAccess, error) { | ||
return a.state.GetBlob() | ||
} | ||
|
||
func (a *modifiedArtifact) Digest() digest.Digest { | ||
blob, _ := a.Blob() | ||
if blob != nil { | ||
return blob.Digest() | ||
} | ||
return "" | ||
} |
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