Skip to content

Commit 892a8bb

Browse files
authored
Merge pull request #3944 from apostasie/refactor-cleanup-1
Cleanup/refactor proposal
2 parents 4c8e2f8 + e21e4b2 commit 892a8bb

File tree

99 files changed

+431
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+431
-431
lines changed

cmd/nerdctl/apparmor/apparmor_inspect_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ import (
2626
"github.com/containerd/nerdctl/v2/pkg/defaults"
2727
)
2828

29-
func newApparmorInspectCommand() *cobra.Command {
29+
func inspectCommand() *cobra.Command {
3030
cmd := &cobra.Command{
3131
Use: "inspect",
3232
Short: fmt.Sprintf("Display the default AppArmor profile %q. Other profiles cannot be displayed with this command.", defaults.AppArmorProfileName),
3333
Args: cobra.NoArgs,
34-
RunE: apparmorInspectAction,
34+
RunE: inspectAction,
3535
SilenceUsage: true,
3636
SilenceErrors: true,
3737
}
3838
return cmd
3939
}
4040

41-
func apparmorInspectAction(cmd *cobra.Command, args []string) error {
41+
func inspectAction(cmd *cobra.Command, args []string) error {
4242
return apparmor.Inspect(types.ApparmorInspectOptions{
4343
Stdout: cmd.OutOrStdout(),
4444
})

cmd/nerdctl/apparmor/apparmor_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2323
)
2424

25-
func NewApparmorCommand() *cobra.Command {
25+
func Command() *cobra.Command {
2626
cmd := &cobra.Command{
2727
Annotations: map[string]string{helpers.Category: helpers.Management},
2828
Use: "apparmor",
@@ -32,10 +32,10 @@ func NewApparmorCommand() *cobra.Command {
3232
SilenceErrors: true,
3333
}
3434
cmd.AddCommand(
35-
newApparmorLsCommand(),
36-
newApparmorInspectCommand(),
37-
newApparmorLoadCommand(),
38-
newApparmorUnloadCommand(),
35+
listCommand(),
36+
inspectCommand(),
37+
loadCommand(),
38+
unloadCommand(),
3939
)
4040
return cmd
4141
}

cmd/nerdctl/apparmor/apparmor_list_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import (
2323
"github.com/containerd/nerdctl/v2/pkg/cmd/apparmor"
2424
)
2525

26-
func newApparmorLsCommand() *cobra.Command {
26+
func listCommand() *cobra.Command {
2727
cmd := &cobra.Command{
2828
Use: "ls",
2929
Aliases: []string{"list"},
3030
Short: "List the loaded AppArmor profiles",
3131
Args: cobra.NoArgs,
32-
RunE: apparmorLsAction,
32+
RunE: listAction,
3333
SilenceUsage: true,
3434
SilenceErrors: true,
3535
}
@@ -42,7 +42,7 @@ func newApparmorLsCommand() *cobra.Command {
4242
return cmd
4343
}
4444

45-
func processApparmorListOptions(cmd *cobra.Command) (types.ApparmorListOptions, error) {
45+
func listOptions(cmd *cobra.Command) (types.ApparmorListOptions, error) {
4646
quiet, err := cmd.Flags().GetBool("quiet")
4747
if err != nil {
4848
return types.ApparmorListOptions{}, err
@@ -58,8 +58,8 @@ func processApparmorListOptions(cmd *cobra.Command) (types.ApparmorListOptions,
5858
}, nil
5959
}
6060

61-
func apparmorLsAction(cmd *cobra.Command, args []string) error {
62-
options, err := processApparmorListOptions(cmd)
61+
func listAction(cmd *cobra.Command, args []string) error {
62+
options, err := listOptions(cmd)
6363
if err != nil {
6464
return err
6565
}

cmd/nerdctl/apparmor/apparmor_load_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ import (
2525
"github.com/containerd/nerdctl/v2/pkg/defaults"
2626
)
2727

28-
func newApparmorLoadCommand() *cobra.Command {
28+
func loadCommand() *cobra.Command {
2929
cmd := &cobra.Command{
3030
Use: "load",
3131
Short: fmt.Sprintf("Load the default AppArmor profile %q. Requires root.", defaults.AppArmorProfileName),
3232
Args: cobra.NoArgs,
33-
RunE: apparmorLoadAction,
33+
RunE: loadAction,
3434
SilenceUsage: true,
3535
SilenceErrors: true,
3636
}
3737
return cmd
3838
}
3939

40-
func apparmorLoadAction(cmd *cobra.Command, args []string) error {
40+
func loadAction(cmd *cobra.Command, args []string) error {
4141
return apparmor.Load()
4242
}

cmd/nerdctl/apparmor/apparmor_unload_linux.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ import (
2626
"github.com/containerd/nerdctl/v2/pkg/defaults"
2727
)
2828

29-
func newApparmorUnloadCommand() *cobra.Command {
29+
func unloadCommand() *cobra.Command {
3030
cmd := &cobra.Command{
3131
Use: "unload [PROFILE]",
3232
Short: fmt.Sprintf("Unload an AppArmor profile. The target profile name defaults to %q. Requires root.", defaults.AppArmorProfileName),
3333
Args: cobra.MaximumNArgs(1),
34-
RunE: apparmorUnloadAction,
35-
ValidArgsFunction: apparmorUnloadShellComplete,
34+
RunE: unloadAction,
35+
ValidArgsFunction: unloadShellComplete,
3636
SilenceUsage: true,
3737
SilenceErrors: true,
3838
}
3939
return cmd
4040
}
4141

42-
func apparmorUnloadAction(cmd *cobra.Command, args []string) error {
42+
func unloadAction(cmd *cobra.Command, args []string) error {
4343
target := defaults.AppArmorProfileName
4444
if len(args) > 0 {
4545
target = args[0]
4646
}
4747
return apparmor.Unload(target)
4848
}
4949

50-
func apparmorUnloadShellComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
50+
func unloadShellComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
5151
return completion.ApparmorProfiles(cmd)
5252
}

cmd/nerdctl/builder/builder.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"github.com/containerd/nerdctl/v2/pkg/cmd/builder"
3131
)
3232

33-
func NewBuilderCommand() *cobra.Command {
33+
func Command() *cobra.Command {
3434
var cmd = &cobra.Command{
3535
Annotations: map[string]string{helpers.Category: helpers.Management},
3636
Use: "builder",
@@ -40,20 +40,20 @@ func NewBuilderCommand() *cobra.Command {
4040
SilenceErrors: true,
4141
}
4242
cmd.AddCommand(
43-
NewBuildCommand(),
44-
newBuilderPruneCommand(),
45-
newBuilderDebugCommand(),
43+
BuildCommand(),
44+
pruneCommand(),
45+
debugCommand(),
4646
)
4747
return cmd
4848
}
4949

50-
func newBuilderPruneCommand() *cobra.Command {
50+
func pruneCommand() *cobra.Command {
5151
shortHelp := `Clean up BuildKit build cache`
5252
var cmd = &cobra.Command{
5353
Use: "prune",
5454
Args: cobra.NoArgs,
5555
Short: shortHelp,
56-
RunE: builderPruneAction,
56+
RunE: pruneAction,
5757
SilenceUsage: true,
5858
SilenceErrors: true,
5959
}
@@ -65,8 +65,8 @@ func newBuilderPruneCommand() *cobra.Command {
6565
return cmd
6666
}
6767

68-
func builderPruneAction(cmd *cobra.Command, _ []string) error {
69-
options, err := processBuilderPruneOptions(cmd)
68+
func pruneAction(cmd *cobra.Command, _ []string) error {
69+
options, err := pruneOptions(cmd)
7070
if err != nil {
7171
return err
7272
}
@@ -101,7 +101,7 @@ func builderPruneAction(cmd *cobra.Command, _ []string) error {
101101
return nil
102102
}
103103

104-
func processBuilderPruneOptions(cmd *cobra.Command) (types.BuilderPruneOptions, error) {
104+
func pruneOptions(cmd *cobra.Command) (types.BuilderPruneOptions, error) {
105105
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
106106
if err != nil {
107107
return types.BuilderPruneOptions{}, err
@@ -131,13 +131,13 @@ func processBuilderPruneOptions(cmd *cobra.Command) (types.BuilderPruneOptions,
131131
}, nil
132132
}
133133

134-
func newBuilderDebugCommand() *cobra.Command {
134+
func debugCommand() *cobra.Command {
135135
shortHelp := `Debug Dockerfile`
136136
var cmd = &cobra.Command{
137137
Use: "debug",
138138
Short: shortHelp,
139139
PreRunE: helpers.CheckExperimental("`nerdctl builder debug`"),
140-
RunE: builderDebugAction,
140+
RunE: debugAction,
141141
SilenceUsage: true,
142142
SilenceErrors: true,
143143
}
@@ -150,7 +150,7 @@ func newBuilderDebugCommand() *cobra.Command {
150150
return cmd
151151
}
152152

153-
func builderDebugAction(cmd *cobra.Command, args []string) error {
153+
func debugAction(cmd *cobra.Command, args []string) error {
154154
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
155155
if err != nil {
156156
return err

cmd/nerdctl/builder/builder_build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import (
3434
"github.com/containerd/nerdctl/v2/pkg/strutil"
3535
)
3636

37-
func NewBuildCommand() *cobra.Command {
37+
func BuildCommand() *cobra.Command {
3838
var cmd = &cobra.Command{
3939
Use: "build [flags] PATH",
4040
Short: "Build an image from a Dockerfile. Needs buildkitd to be running.",

cmd/nerdctl/compose/compose.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/containerd/nerdctl/v2/pkg/composer"
2424
)
2525

26-
func NewComposeCommand() *cobra.Command {
26+
func Command() *cobra.Command {
2727
var cmd = &cobra.Command{
2828
Use: "compose [flags] COMMAND",
2929
Short: "Compose",
@@ -41,29 +41,29 @@ func NewComposeCommand() *cobra.Command {
4141
cmd.PersistentFlags().StringArray("profile", []string{}, "Specify a profile to enable")
4242

4343
cmd.AddCommand(
44-
newComposeUpCommand(),
45-
newComposeLogsCommand(),
46-
newComposeConfigCommand(),
47-
newComposeCopyCommand(),
48-
newComposeBuildCommand(),
49-
newComposeExecCommand(),
50-
newComposeImagesCommand(),
51-
newComposePortCommand(),
52-
newComposePushCommand(),
53-
newComposePullCommand(),
54-
newComposeDownCommand(),
55-
newComposePsCommand(),
56-
newComposeKillCommand(),
57-
newComposeRestartCommand(),
58-
newComposeRemoveCommand(),
59-
newComposeRunCommand(),
60-
newComposeVersionCommand(),
61-
newComposeStartCommand(),
62-
newComposeStopCommand(),
63-
newComposePauseCommand(),
64-
newComposeUnpauseCommand(),
65-
newComposeTopCommand(),
66-
newComposeCreateCommand(),
44+
upCommand(),
45+
logsCommand(),
46+
configCommand(),
47+
copyCommand(),
48+
buildCommand(),
49+
execCommand(),
50+
imagesCommand(),
51+
portCommand(),
52+
pushCommand(),
53+
pullCommand(),
54+
downCommand(),
55+
psCommand(),
56+
killCommand(),
57+
restartCommand(),
58+
removeCommand(),
59+
runCommand(),
60+
versionCommand(),
61+
startCommand(),
62+
stopCommand(),
63+
pauseCommand(),
64+
unpauseCommand(),
65+
topCommand(),
66+
createCommand(),
6767
)
6868

6969
return cmd

cmd/nerdctl/compose/compose_build.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import (
2525
"github.com/containerd/nerdctl/v2/pkg/composer"
2626
)
2727

28-
func newComposeBuildCommand() *cobra.Command {
28+
func buildCommand() *cobra.Command {
2929
var cmd = &cobra.Command{
3030
Use: "build [flags] [SERVICE...]",
3131
Short: "Build or rebuild services",
32-
RunE: composeBuildAction,
32+
RunE: buildAction,
3333
SilenceUsage: true,
3434
SilenceErrors: true,
3535
}
@@ -40,7 +40,7 @@ func newComposeBuildCommand() *cobra.Command {
4040
return cmd
4141
}
4242

43-
func composeBuildAction(cmd *cobra.Command, args []string) error {
43+
func buildAction(cmd *cobra.Command, args []string) error {
4444
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
4545
if err != nil {
4646
return err

cmd/nerdctl/compose/compose_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import (
2727
"github.com/containerd/nerdctl/v2/pkg/composer"
2828
)
2929

30-
func newComposeConfigCommand() *cobra.Command {
30+
func configCommand() *cobra.Command {
3131
var cmd = &cobra.Command{
3232
Use: "config",
3333
Short: "Validate and view the Compose file",
34-
RunE: composeConfigAction,
34+
RunE: configAction,
3535
SilenceUsage: true,
3636
SilenceErrors: true,
3737
}
@@ -45,7 +45,7 @@ func newComposeConfigCommand() *cobra.Command {
4545
return cmd
4646
}
4747

48-
func composeConfigAction(cmd *cobra.Command, args []string) error {
48+
func configAction(cmd *cobra.Command, args []string) error {
4949
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
5050
if err != nil {
5151
return err

cmd/nerdctl/compose/compose_cp.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ import (
2828
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
2929
)
3030

31-
func newComposeCopyCommand() *cobra.Command {
31+
func copyCommand() *cobra.Command {
3232
usage := `cp [OPTIONS] SERVICE:SRC_PATH DEST_PATH|-
3333
nerdctl compose cp [OPTIONS] SRC_PATH|- SERVICE:DEST_PATH`
3434
var cmd = &cobra.Command{
3535
Use: usage,
3636
Short: "Copy files/folders between a service container and the local filesystem",
3737
Args: cobra.ExactArgs(2),
38-
RunE: composeCopyAction,
38+
RunE: copyAction,
3939
SilenceUsage: true,
4040
SilenceErrors: true,
4141
}
@@ -45,7 +45,7 @@ func newComposeCopyCommand() *cobra.Command {
4545
return cmd
4646
}
4747

48-
func composeCopyAction(cmd *cobra.Command, args []string) error {
48+
func copyAction(cmd *cobra.Command, args []string) error {
4949
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
5050
if err != nil {
5151
return err

cmd/nerdctl/compose/compose_create.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ import (
2727
"github.com/containerd/nerdctl/v2/pkg/composer"
2828
)
2929

30-
func newComposeCreateCommand() *cobra.Command {
30+
func createCommand() *cobra.Command {
3131
var cmd = &cobra.Command{
3232
Use: "create [flags] [SERVICE...]",
3333
Short: "Creates containers for one or more services",
34-
RunE: composeCreateAction,
34+
RunE: createAction,
3535
SilenceUsage: true,
3636
SilenceErrors: true,
3737
}
@@ -43,7 +43,7 @@ func newComposeCreateCommand() *cobra.Command {
4343
return cmd
4444
}
4545

46-
func composeCreateAction(cmd *cobra.Command, args []string) error {
46+
func createAction(cmd *cobra.Command, args []string) error {
4747
globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
4848
if err != nil {
4949
return err

0 commit comments

Comments
 (0)