Skip to content

Commit bc55aad

Browse files
committed
transfer service
Signed-off-by: ChengyuZhu6 <[email protected]>
1 parent f380cca commit bc55aad

File tree

16 files changed

+829
-373
lines changed

16 files changed

+829
-373
lines changed

cmd/nerdctl/container/container_run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ func TestRunFromOCIArchive(t *testing.T) {
786786
tarPath := fmt.Sprintf("%s/%s.tar", buildCtx, imageName)
787787

788788
base.Cmd("build", "--tag", tag, fmt.Sprintf("--output=type=oci,dest=%s", tarPath), buildCtx).AssertOK()
789-
base.Cmd("run", "--rm", fmt.Sprintf("oci-archive://%s", tarPath)).AssertOutContainsAll(fmt.Sprintf("Loaded image: %s", tag), sentinel)
789+
base.Cmd("run", "--rm", fmt.Sprintf("oci-archive://%s", tarPath)).AssertOutContainsAll(tag, sentinel)
790790
}
791791

792792
func TestRunDomainname(t *testing.T) {

cmd/nerdctl/image/image_load_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package image
1818

1919
import (
20-
"fmt"
2120
"os"
2221
"path/filepath"
2322
"strings"
@@ -61,7 +60,7 @@ func TestLoadStdinFromPipe(t *testing.T) {
6160
identifier := data.Identifier()
6261
return &test.Expected{
6362
Output: expect.All(
64-
expect.Contains(fmt.Sprintf("Loaded image: %s:latest", identifier)),
63+
expect.Contains(identifier),
6564
func(stdout string, t tig.T) {
6665
assert.Assert(t, strings.Contains(helpers.Capture("images"), identifier))
6766
},
@@ -107,7 +106,7 @@ func TestLoadQuiet(t *testing.T) {
107106
Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
108107
return &test.Expected{
109108
Output: expect.All(
110-
expect.Contains(fmt.Sprintf("Loaded image: %s:latest", data.Identifier())),
109+
expect.Contains(data.Identifier()),
111110
expect.DoesNotContain("Loading layer"),
112111
),
113112
}

mod/tigron/test/data.go

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131

3232
const (
3333
identifierMaxLength = 76
34-
identifierSeparator = "-"
3534
identifierSignatureLength = 8
3635
)
3736

@@ -250,27 +249,18 @@ func newData(t tig.T, seed, parent Data) Data {
250249
func defaultIdentifierHashing(names ...string) string {
251250
// Notes: identifier MAY be used for namespaces, image names, etc.
252251
// So, the rules are stringent on what it can contain.
253-
replaceWith := []byte(identifierSeparator)
254-
name := strings.ToLower(strings.Join(names, string(replaceWith)))
252+
// Join names without separator to avoid '-' which causes display issues in progress output
253+
name := strings.ToLower(strings.Join(names, ""))
255254
// Ensure we have a unique identifier despite characters replacements
256255
// (well, as unique as the names collection being passed)
257256
signature := fmt.Sprintf("%x", sha256.Sum256([]byte(name)))[0:identifierSignatureLength]
258-
// Make sure we do not use any unsafe characters
259-
safeName := regexp.MustCompile(`[^a-z0-9-]+`)
260-
// And we avoid repeats of the separator
261-
noRepeat := regexp.MustCompile(fmt.Sprintf(`[%s]{2,}`, replaceWith))
262-
escapedName := safeName.ReplaceAll([]byte(name), replaceWith)
263-
escapedName = noRepeat.ReplaceAll(escapedName, replaceWith)
264-
// Do not allow trailing or leading dash (as that may stutter)
265-
name = strings.Trim(string(escapedName), string(replaceWith))
257+
safeName := regexp.MustCompile(`[^a-z0-9]+`)
258+
escapedName := safeName.ReplaceAll([]byte(name), []byte(""))
259+
name = string(escapedName)
266260

267261
// Ensure we will never go above 76 characters in length (with signature)
268-
if len(name) > (identifierMaxLength - len(signature)) {
269-
name = name[0 : identifierMaxLength-identifierSignatureLength-len(identifierSeparator)]
270-
}
271-
272-
if name[len(name)-1:] != identifierSeparator {
273-
signature = identifierSeparator + signature
262+
if len(name) > (identifierMaxLength - identifierSignatureLength) {
263+
name = name[0 : identifierMaxLength-identifierSignatureLength]
274264
}
275265

276266
return name + signature

mod/tigron/test/data_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestDataIdentifier(t *testing.T) {
7171
assertive.HasPrefix(t, one, "testdataidentifier")
7272

7373
three := dataObj.Identifier("Some Add ∞ Funky∞Prefix")
74-
assertive.HasPrefix(t, three, "testdataidentifier-some-add-funky-prefix")
74+
assertive.HasPrefix(t, three, "testdataidentifiersomeaddfunkyprefix")
7575
}
7676

7777
func TestDataIdentifierThatIsReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLong(

pkg/cmd/image/ensure.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package image
1818

1919
import (
2020
"context"
21-
"errors"
22-
"net/http"
2321
"os"
2422

2523
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -80,7 +78,6 @@ func ensureOne(ctx context.Context, client *containerd.Client, rawRef string, ta
8078
// Get a resolver
8179
var dOpts []dockerconfigresolver.Opt
8280
if options.InsecureRegistry {
83-
log.G(ctx).Warnf("skipping verifying HTTPS certs for %q", parsedReference.Domain)
8481
dOpts = append(dOpts, dockerconfigresolver.WithSkipVerifyCerts(true))
8582
}
8683
dOpts = append(dOpts, dockerconfigresolver.WithHostsDirs(options.HostsDir))
@@ -99,7 +96,7 @@ func ensureOne(ctx context.Context, client *containerd.Client, rawRef string, ta
9996

10097
if err != nil {
10198
// In some circumstance (e.g. people just use 80 port to support pure http), the error will contain message like "dial tcp <port>: connection refused".
102-
if !errors.Is(err, http.ErrSchemeMismatch) && !errutil.IsErrConnectionRefused(err) {
99+
if !errutil.IsErrHTTPSFallbackNeeded(err) {
103100
return err
104101
}
105102
if options.InsecureRegistry {

0 commit comments

Comments
 (0)