Skip to content

Commit 61fff09

Browse files
committed
fix persistent flag conflict
Signed-off-by: fahed dorgaa <fahed.dorgaa@gmail.com>
1 parent 475f0d0 commit 61fff09

3 files changed

Lines changed: 13 additions & 73 deletions

File tree

cmd/nerdctl/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"strconv"
2525
"strings"
2626

27-
"github.com/containerd/containerd"
2827
"github.com/containerd/containerd/defaults"
2928
"github.com/containerd/containerd/namespaces"
3029
ncdefaults "github.com/containerd/nerdctl/pkg/defaults"
@@ -139,10 +138,8 @@ func initRootCmdFlags(rootCmd *cobra.Command, tomlPath string) error {
139138
}
140139
rootCmd.PersistentFlags().Bool("debug", cfg.Debug, "debug mode")
141140
rootCmd.PersistentFlags().Bool("debug-full", cfg.DebugFull, "debug mode (with full output)")
142-
// -a is nonPersistentAlias (conflicts with nerdctl images -a)
143-
AddPersistentStringFlag(rootCmd, "address", []string{"host"}, []string{"a", "H"}, cfg.Address, "CONTAINERD_ADDRESS", `containerd address, optionally with "unix://" prefix`)
144-
// -n is nonPersistentAlias (conflicts with nerdctl logs -n)
145-
AddPersistentStringFlag(rootCmd, "namespace", nil, []string{"n"}, cfg.Namespace, "CONTAINERD_NAMESPACE", `containerd namespace, such as "moby" for Docker, "k8s.io" for Kubernetes`)
141+
AddPersistentStringFlag(rootCmd, "address", []string{"host", "a"}, []string{"H"}, cfg.Address, "CONTAINERD_ADDRESS", `containerd address, optionally with "unix://" prefix`)
142+
AddPersistentStringFlag(rootCmd, "namespace", []string{"n"}, nil, cfg.Namespace, "CONTAINERD_NAMESPACE", `containerd namespace, such as "moby" for Docker, "k8s.io" for Kubernetes`)
146143
rootCmd.RegisterFlagCompletionFunc("namespace", shellCompleteNamespaceNames)
147144
AddPersistentStringFlag(rootCmd, "snapshotter", []string{"storage-driver"}, nil, cfg.Snapshotter, "CONTAINERD_SNAPSHOTTER", "containerd snapshotter")
148145
rootCmd.RegisterFlagCompletionFunc("snapshotter", shellCompleteSnapshotterNames)
@@ -299,6 +296,7 @@ Config file ($NERDCTL_TOML): %s
299296
)
300297
addApparmorCommand(rootCmd)
301298
addCpCommand(rootCmd)
299+
302300
return rootCmd, nil
303301
}
304302

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ require (
8989
github.com/hashicorp/errwrap v1.1.0 // indirect
9090
github.com/hashicorp/golang-lru v0.5.4 // indirect
9191
github.com/imdario/mergo v0.3.13 // indirect
92-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
92+
github.com/inconshreveable/mousetrap v1.0.1 // indirect
9393
github.com/ipfs/bbloom v0.0.4 // indirect
9494
github.com/ipfs/go-block-format v0.0.3 // indirect
9595
github.com/ipfs/go-blockservice v0.3.0 // indirect
@@ -185,4 +185,7 @@ replace (
185185
github.com/containerd/containerd => github.com/containerd/containerd v1.6.1-0.20220807041520-6deb1174fbfc
186186
// Temporary fork for avoiding importing patent-protected code: https://github.com/hashicorp/golang-lru/issues/73
187187
github.com/hashicorp/golang-lru => github.com/ktock/golang-lru v0.5.5-0.20211029085301-ec551be6f75c
188+
// Temporary fork for parent flags persistence: https://github.com/spf13/cobra/pull/1795
189+
github.com/spf13/cobra => github.com/fahedouch/cobra v0.0.0-20220905130657-0c653d6e38ad
190+
github.com/spf13/pflag => github.com/fahedouch/pflag v0.0.0-20220905133355-1113e9b3fb8b
188191
)

0 commit comments

Comments
 (0)