Skip to content

Commit 8247b57

Browse files
author
Maksym Pavlenko
authored
Merge pull request containerd#10321 from ktock/ctr-local-flag-deps
ctr: return explicit errors for flags unsupported by transfer service
2 parents 3debabb + df7f6ba commit 8247b57

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

cmd/ctr/commands/images/import.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ If foobar.tar contains an OCI ref named "latest" and anonymous ref "sha256:deadb
115115
defer cancel()
116116

117117
if !context.Bool("local") {
118+
unsupportedFlags := []string{"discard-unpacked-layers"}
119+
for _, s := range unsupportedFlags {
120+
if context.IsSet(s) {
121+
return fmt.Errorf("\"--%s\" requires \"--local\" flag", s)
122+
}
123+
}
118124
var opts []image.StoreOpt
119125
prefix := context.String("base-name")
120126
var overwrite bool

cmd/ctr/commands/images/pull.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ command. As part of this process, we do the following:
100100
defer cancel()
101101

102102
if !context.Bool("local") {
103+
unsupportedFlags := []string{"max-concurrent-downloads", "print-chainid",
104+
"skip-verify", "tlscacert", "tlscert", "tlskey", "http-dump", "http-trace", // RegistryFlags
105+
}
106+
for _, s := range unsupportedFlags {
107+
if context.IsSet(s) {
108+
return fmt.Errorf("\"--%s\" requires \"--local\" flag", s)
109+
}
110+
}
111+
103112
ch, err := commands.NewStaticCredentials(ctx, context, ref)
104113
if err != nil {
105114
return err

cmd/ctr/commands/images/push.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ var pushCommand = &cli.Command{
9696
defer cancel()
9797

9898
if !context.Bool("local") {
99+
unsupportedFlags := []string{
100+
"manifest", "manifest-type", "max-concurrent-uploaded-layers", "allow-non-distributable-blobs",
101+
"skip-verify", "tlscacert", "tlscert", "tlskey", "http-dump", "http-trace", // RegistryFlags
102+
}
103+
for _, s := range unsupportedFlags {
104+
if context.IsSet(s) {
105+
return fmt.Errorf("\"--%s\" requires \"--local\" flag", s)
106+
}
107+
}
108+
99109
ch, err := commands.NewStaticCredentials(ctx, context, ref)
100110
if err != nil {
101111
return err

0 commit comments

Comments
 (0)