Skip to content

Commit ca637fd

Browse files
committed
Move cmd/container to subpackage
Signed-off-by: apostasie <[email protected]>
1 parent f2bfc60 commit ca637fd

File tree

89 files changed

+253
-185
lines changed

Some content is hidden

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

89 files changed

+253
-185
lines changed

cmd/nerdctl/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func newComposeCommand() *cobra.Command {
7070
}
7171

7272
func getComposeOptions(cmd *cobra.Command, debugFull, experimental bool) (composer.Options, error) {
73-
nerdctlCmd, nerdctlArgs := globalFlags(cmd)
73+
nerdctlCmd, nerdctlArgs := helpers.GlobalFlags(cmd)
7474
projectDirectory, err := cmd.Flags().GetString("project-directory")
7575
if err != nil {
7676
return composer.Options{}, err

cmd/nerdctl/container.go renamed to cmd/nerdctl/container/container.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"github.com/spf13/cobra"
2121

2222
"github.com/containerd/nerdctl/v2/cmd/nerdctl/helpers"
2323
)
2424

25-
func newContainerCommand() *cobra.Command {
25+
func NewContainerCommand() *cobra.Command {
2626
containerCommand := &cobra.Command{
2727
Annotations: map[string]string{helpers.Category: helpers.Management},
2828
Use: "container",
@@ -32,35 +32,35 @@ func newContainerCommand() *cobra.Command {
3232
SilenceErrors: true,
3333
}
3434
containerCommand.AddCommand(
35-
newCreateCommand(),
36-
newRunCommand(),
37-
newUpdateCommand(),
38-
newExecCommand(),
35+
NewCreateCommand(),
36+
NewRunCommand(),
37+
NewUpdateCommand(),
38+
NewExecCommand(),
3939
containerLsCommand(),
4040
newContainerInspectCommand(),
41-
newLogsCommand(),
42-
newPortCommand(),
43-
newRmCommand(),
44-
newStopCommand(),
45-
newStartCommand(),
46-
newRestartCommand(),
47-
newKillCommand(),
48-
newPauseCommand(),
49-
newDiffCommand(),
50-
newWaitCommand(),
51-
newUnpauseCommand(),
52-
newCommitCommand(),
53-
newRenameCommand(),
41+
NewLogsCommand(),
42+
NewPortCommand(),
43+
NewRmCommand(),
44+
NewStopCommand(),
45+
NewStartCommand(),
46+
NewRestartCommand(),
47+
NewKillCommand(),
48+
NewPauseCommand(),
49+
NewDiffCommand(),
50+
NewWaitCommand(),
51+
NewUnpauseCommand(),
52+
NewCommitCommand(),
53+
NewRenameCommand(),
5454
newContainerPruneCommand(),
55-
newStatsCommand(),
56-
newAttachCommand(),
55+
NewStatsCommand(),
56+
NewAttachCommand(),
5757
)
58-
addCpCommand(containerCommand)
58+
AddCpCommand(containerCommand)
5959
return containerCommand
6060
}
6161

6262
func containerLsCommand() *cobra.Command {
63-
x := newPsCommand()
63+
x := NewPsCommand()
6464
x.Use = "ls"
6565
x.Aliases = []string{"list"}
6666
return x

cmd/nerdctl/container_attach.go renamed to cmd/nerdctl/container/container_attach.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"github.com/spf13/cobra"
@@ -29,7 +29,7 @@ import (
2929
"github.com/containerd/nerdctl/v2/pkg/consoleutil"
3030
)
3131

32-
func newAttachCommand() *cobra.Command {
32+
func NewAttachCommand() *cobra.Command {
3333
const shortHelp = "Attach stdin, stdout, and stderr to a running container."
3434
const longHelp = `Attach stdin, stdout, and stderr to a running container. For example:
3535

cmd/nerdctl/container_attach_linux_test.go renamed to cmd/nerdctl/container/container_attach_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"bytes"

cmd/nerdctl/container_commit.go renamed to cmd/nerdctl/container/container_commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"github.com/spf13/cobra"
@@ -26,7 +26,7 @@ import (
2626
"github.com/containerd/nerdctl/v2/pkg/cmd/container"
2727
)
2828

29-
func newCommitCommand() *cobra.Command {
29+
func NewCommitCommand() *cobra.Command {
3030
var commitCommand = &cobra.Command{
3131
Use: "commit [flags] CONTAINER REPOSITORY[:TAG]",
3232
Short: "Create a new image from a container's changes",

cmd/nerdctl/container_commit_linux_test.go renamed to cmd/nerdctl/container/container_commit_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"strings"

cmd/nerdctl/container_commit_test.go renamed to cmd/nerdctl/container/container_commit_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"fmt"

cmd/nerdctl/container_cp.go renamed to cmd/nerdctl/container/container_cp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"errors"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 container
18+
19+
import "github.com/spf13/cobra"
20+
21+
func AddCpCommand(rootCmd *cobra.Command) {
22+
// NOP
23+
}

cmd/nerdctl/container_cp_linux.go renamed to cmd/nerdctl/container/container_cp_linux.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
package main
17+
package container
1818

1919
import (
2020
"fmt"
@@ -127,3 +127,7 @@ func processCpOptions(cmd *cobra.Command, args []string) (types.ContainerCpOptio
127127
FollowSymLink: flagL,
128128
}, nil
129129
}
130+
131+
func AddCpCommand(rootCmd *cobra.Command) {
132+
rootCmd.AddCommand(newCpCommand())
133+
}

0 commit comments

Comments
 (0)