Skip to content

Commit ec53014

Browse files
committed
Move constants Categroy/Management to helpers
Signed-off-by: apostasie <[email protected]>
1 parent 38bca1f commit ec53014

File tree

13 files changed

+55
-20
lines changed

13 files changed

+55
-20
lines changed

cmd/nerdctl/apparmor_linux.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newApparmorCommand() *cobra.Command {
2426
cmd := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "apparmor",
2729
Short: "Manage AppArmor profiles",
2830
RunE: unknownSubcommandAction,

cmd/nerdctl/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232

3333
func newBuilderCommand() *cobra.Command {
3434
var builderCommand = &cobra.Command{
35-
Annotations: map[string]string{Category: Management},
35+
Annotations: map[string]string{helpers.Category: helpers.Management},
3636
Use: "builder",
3737
Short: "Manage builds",
3838
RunE: unknownSubcommandAction,

cmd/nerdctl/container.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newContainerCommand() *cobra.Command {
2426
containerCommand := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "container",
2729
Short: "Manage containers",
2830
RunE: unknownSubcommandAction,

cmd/nerdctl/helpers/consts.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright The containerd Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package helpers
18+
19+
const (
20+
Category = "category"
21+
Management = "management"
22+
)

cmd/nerdctl/image.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newImageCommand() *cobra.Command {
2426
cmd := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "image",
2729
Short: "Manage images",
2830
RunE: unknownSubcommandAction,

cmd/nerdctl/ipfs.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newIPFSCommand() *cobra.Command {
2426
cmd := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "ipfs",
2729
Short: "Distributing images on IPFS",
2830
RunE: unknownSubcommandAction,

cmd/nerdctl/ipfs_registry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newIPFSRegistryCommand() *cobra.Command {
2426
cmd := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "registry",
2729
Short: "Manage read-only registry backed by IPFS",
2830
PreRunE: checkExperimental("ipfs"),

cmd/nerdctl/main.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ import (
4242
"github.com/containerd/nerdctl/v2/pkg/version"
4343
)
4444

45-
const (
46-
Category = "category"
47-
Management = "management"
48-
)
49-
5045
var (
5146
// To print Bold Text
5247
Bold = color.New(color.Bold).SprintfFunc()
@@ -75,7 +70,7 @@ func usage(c *cobra.Command) error {
7570
if f.Hidden {
7671
continue
7772
}
78-
if f.Annotations[Category] == Management {
73+
if f.Annotations[helpers.Category] == helpers.Management {
7974
managementCommands = append(managementCommands, f)
8075
} else {
8176
nonManagementCommands = append(nonManagementCommands, f)
@@ -103,7 +98,7 @@ func usage(c *cobra.Command) error {
10398
t += "\n"
10499
return t
105100
}
106-
s += printCommands("Management commands", managementCommands)
101+
s += printCommands("helpers.Management commands", managementCommands)
107102
s += printCommands("Commands", nonManagementCommands)
108103

109104
s += Bold("Flags") + ":\n"
@@ -293,7 +288,7 @@ Config file ($NERDCTL_TOML): %s
293288
newTopCommand(),
294289
newStatsCommand(),
295290

296-
// #region Management
291+
// #region helpers.Management
297292
newContainerCommand(),
298293
newImageCommand(),
299294
newNetworkCommand(),

cmd/nerdctl/namespace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535

3636
func newNamespaceCommand() *cobra.Command {
3737
namespaceCommand := &cobra.Command{
38-
Annotations: map[string]string{Category: Management},
38+
Annotations: map[string]string{helpers.Category: helpers.Management},
3939
Use: "namespace",
4040
Aliases: []string{"ns"},
4141
Short: "Manage containerd namespaces",

cmd/nerdctl/network.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ package main
1818

1919
import (
2020
"github.com/spf13/cobra"
21+
22+
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2123
)
2224

2325
func newNetworkCommand() *cobra.Command {
2426
networkCommand := &cobra.Command{
25-
Annotations: map[string]string{Category: Management},
27+
Annotations: map[string]string{helpers.Category: helpers.Management},
2628
Use: "network",
2729
Short: "Manage networks",
2830
RunE: unknownSubcommandAction,

0 commit comments

Comments
 (0)