Skip to content

Commit 419a0f2

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

3 files changed

Lines changed: 13 additions & 72 deletions

File tree

cmd/nerdctl/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ func initRootCmdFlags(rootCmd *cobra.Command, tomlPath string) error {
139139
}
140140
rootCmd.PersistentFlags().Bool("debug", cfg.Debug, "debug mode")
141141
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`)
142+
AddPersistentStringFlag(rootCmd, "address", []string{"host", "a"}, []string{"H"}, cfg.Address, "CONTAINERD_ADDRESS", `containerd address, optionally with "unix://" prefix`)
143+
AddPersistentStringFlag(rootCmd, "namespace", []string{"n"}, nil, cfg.Namespace, "CONTAINERD_NAMESPACE", `containerd namespace, such as "moby" for Docker, "k8s.io" for Kubernetes`)
146144
rootCmd.RegisterFlagCompletionFunc("namespace", shellCompleteNamespaceNames)
147145
AddPersistentStringFlag(rootCmd, "snapshotter", []string{"storage-driver"}, nil, cfg.Snapshotter, "CONTAINERD_SNAPSHOTTER", "containerd snapshotter")
148146
rootCmd.RegisterFlagCompletionFunc("snapshotter", shellCompleteSnapshotterNames)
@@ -299,6 +297,7 @@ Config file ($NERDCTL_TOML): %s
299297
)
300298
addApparmorCommand(rootCmd)
301299
addCpCommand(rootCmd)
300+
302301
return rootCmd, nil
303302
}
304303

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)