Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace current platform image with the new one when it already … #1077

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/cmd/mod/mod_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (o *PushModOptions) Run() error {

// Copy to temp module dir and push artifact to OCI repository
err = ioutil.CopyDir(targetDir, o.ModulePath, func(path string) bool {
skipDirs := []string{filepath.Join(o.ModulePath, ".git"), filepath.Join(o.ModulePath, "src")}
skipDirs := []string{filepath.Join(o.ModulePath, ".git"), filepath.Join(o.ModulePath, ".idea"), filepath.Join(o.ModulePath, "src")}

// skip files in skipDirs
for _, dir := range skipDirs {
Expand Down Expand Up @@ -354,7 +354,7 @@ func (o *PushModOptions) buildModule() (string, error) {
func buildBinary(goBin, operatingSystem, arch, srcDirectory, outfile string, ioStreams genericiooptions.IOStreams) (string, error) {
if outfile == "" {
// If no outfile is supplied, write the Go binary to a temporary file.
f, err := os.CreateTemp("", "generator.*")
f, err := os.CreateTemp("", "module.*")
if err != nil {
return "", fmt.Errorf("unable to create go program temp file: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/oci/client/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/match"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/remote"
Expand Down Expand Up @@ -147,7 +148,10 @@ func (c *Client) Push(
Add: image,
Descriptor: *newDesc,
}
idx := mutate.AppendManifests(base, addendum)

// replace current platform image with the new one
// remove is removed before adds
idx := mutate.AppendManifests(mutate.RemoveManifests(base, match.Platforms(*newDesc.Platform)), addendum)
idxDigest, err := idx.Digest()
if err != nil {
return "", "", fmt.Errorf("parsing index digest failed: %w", err)
Expand Down
Loading