Skip to content

Commit 7582f7d

Browse files
committed
transfer service
Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
1 parent f380cca commit 7582f7d

File tree

13 files changed

+796
-367
lines changed

13 files changed

+796
-367
lines changed

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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func ensureOne(ctx context.Context, client *containerd.Client, rawRef string, ta
8080
// Get a resolver
8181
var dOpts []dockerconfigresolver.Opt
8282
if options.InsecureRegistry {
83-
log.G(ctx).Warnf("skipping verifying HTTPS certs for %q", parsedReference.Domain)
8483
dOpts = append(dOpts, dockerconfigresolver.WithSkipVerifyCerts(true))
8584
}
8685
dOpts = append(dOpts, dockerconfigresolver.WithHostsDirs(options.HostsDir))

0 commit comments

Comments
 (0)