Replies: 1 comment 1 reply
-
Unfortunately, I can't reproduce your issue. Please offer a minimal reproducible demo that excludes irrelevant commands such as build. package main
import (
"context"
"fmt"
"os"
"strings"
"testing"
"github.com/containerd/nerdctl/pkg/api/types"
"github.com/containerd/nerdctl/pkg/clientutil"
"github.com/containerd/nerdctl/pkg/cmd/image"
ncdefaults "github.com/containerd/nerdctl/pkg/defaults"
"github.com/containerd/nerdctl/pkg/testutil"
"github.com/containerd/nerdctl/pkg/testutil/testregistry"
"gotest.tools/v3/assert"
)
func TestTagAndPush(t *testing.T) {
testutil.RequiresBuild(t)
base := testutil.NewBase(t)
reg := testregistry.NewPlainHTTP(base, 5000)
defer reg.Cleanup()
localhostIP := "127.0.0.1"
t.Logf("localhost IP=%q", localhostIP)
tomlPath := ncdefaults.NerdctlTOML()
if v, ok := os.LookupEnv("NERDCTL_TOML"); ok {
tomlPath = v
}
cmd := newPullCommand()
aliasToBeInherited, err := initRootCmdFlags(cmd, tomlPath)
assert.NilError(t, err)
cmd.InheritedFlags().AddFlagSet(aliasToBeInherited)
options, err := processPullCommandFlags(cmd)
assert.NilError(t, err)
client, ctx, cancel, err := clientutil.NewClient(context.Background(), testutil.Namespace, options.GOptions.Address)
defer cancel()
err = image.Pull(ctx, client, testutil.CommonImage, options)
assert.NilError(t, err)
for _, testImageRef := range []string{
fmt.Sprintf("%s:%d/%s:%s_1",
localhostIP, reg.ListenPort, testutil.Identifier(t), strings.Split(testutil.CommonImage, ":")[1]),
fmt.Sprintf("%s:%d/%s:%s_2",
localhostIP, reg.ListenPort, testutil.Identifier(t), strings.Split(testutil.CommonImage, ":")[1]),
} {
t.Logf("testImageRef=%q", testImageRef)
{
cmd := newTagCommand()
aliasToBeInherited, err := initRootCmdFlags(cmd, tomlPath)
assert.NilError(t, err)
cmd.InheritedFlags().AddFlagSet(aliasToBeInherited)
gOptions, err := processRootCmdFlags(cmd)
assert.NilError(t, err)
options := types.ImageTagOptions{
GOptions: gOptions,
Source: testutil.CommonImage,
Target: testImageRef,
}
client, ctx, cancel, err := clientutil.NewClient(context.Background(), testutil.Namespace, options.GOptions.Address)
defer cancel()
err = image.Tag(ctx, client, options)
assert.NilError(t, err)
}
{
cmd := newPushCommand()
aliasToBeInherited, err := initRootCmdFlags(cmd, tomlPath)
assert.NilError(t, err)
cmd.InheritedFlags().AddFlagSet(aliasToBeInherited)
options, err := processImagePushOptions(cmd)
assert.NilError(t, err)
client, ctx, cancel, err := clientutil.NewClient(context.Background(), testutil.Namespace, options.GOptions.Address)
defer cancel()
err = image.Push(ctx, client, testImageRef, options)
assert.NilError(t, err)
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi~
I'm suffering from this issue. I need your help~ I wanna know why~
I made some library(imgwrapper) using nerdctl codes,
which include push, pull and commit functions and related necessary codes in nerdctl project.
when I made some test codes that it builds a image and push the image twice, with just different tag name.
so it made same image with different tag name.
well, the result is always same. first push is success, but, second push is not working and no errors.
I don't know why..
so I tested same thing with nerdctl cli.
but, it worked. no problem.
yesterday, I followed twice consecutive pushing process in debug-mode
but I couldn't find any issue or error.
I leave my some codes for pushing, actually the codes using nerdctl codes and testing code
and I found out different image id solved this issue when I tested yesterday.
I think the build has no problem.
Beta Was this translation helpful? Give feedback.
All reactions