MCPcopy Index your code
hub / github.com/devspace-sh/devspace / NewAttachCmd

Function NewAttachCmd

cmd/attach.go:30–61  ·  view source on GitHub ↗

NewAttachCmd creates a new attach command

(f factory.Factory, globalFlags *flags.GlobalFlags)

Source from the content-addressed store, hash-verified

28
29// NewAttachCmd creates a new attach command
30func NewAttachCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
31 cmd := &AttachCmd{GlobalFlags: globalFlags}
32
33 attachCmd := &cobra.Command{
34 Use: "attach",
35 Short: "Attaches to a container",
36 Long: `
37#######################################################
38################# devspace attach #####################
39#######################################################
40Attaches to a running container
41
42devspace attach
43devspace attach --pick # Select pod to enter
44devspace attach -c my-container
45devspace attach -n my-namespace
46#######################################################`,
47 RunE: func(cobraCmd *cobra.Command, args []string) error {
48 plugin.SetPluginCommand(cobraCmd, args)
49 return cmd.Run(f, cobraCmd, args)
50 },
51 }
52
53 attachCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to execute command")
54 attachCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to open a shell to")
55 attachCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})")
56 attachCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
57
58 attachCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod")
59
60 return attachCmd
61}
62
63// Run executes the command logic
64func (cmd *AttachCmd) Run(f factory.Factory, cobraCmd *cobra.Command, args []string) error {

Callers 1

BuildRootFunction · 0.85

Calls 2

RunMethod · 0.95
SetPluginCommandFunction · 0.92

Tested by

no test coverage detected