MCPcopy Create free account
hub / github.com/containerd/nerdctl / execOptions

Function execOptions

cmd/nerdctl/container/container_exec.go:58–123  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

56}
57
58func execOptions(cmd *cobra.Command) (types.ContainerExecOptions, error) {
59 // We do not check if we have a terminal here, as container.Exec calling console.Current will ensure that
60 globalOptions, err := helpers.ProcessRootCmdFlags(cmd)
61 if err != nil {
62 return types.ContainerExecOptions{}, err
63 }
64
65 isInteractive, err := cmd.Flags().GetBool("interactive")
66 if err != nil {
67 return types.ContainerExecOptions{}, err
68 }
69 isTerminal, err := cmd.Flags().GetBool("tty")
70 if err != nil {
71 return types.ContainerExecOptions{}, err
72 }
73 isDetach, err := cmd.Flags().GetBool("detach")
74 if err != nil {
75 return types.ContainerExecOptions{}, err
76 }
77
78 if isInteractive {
79 if isDetach {
80 return types.ContainerExecOptions{}, errors.New("currently flag -i and -d cannot be specified together (FIXME)")
81 }
82 }
83
84 if isTerminal {
85 if isDetach {
86 return types.ContainerExecOptions{}, errors.New("currently flag -t and -d cannot be specified together (FIXME)")
87 }
88 }
89
90 workdir, err := cmd.Flags().GetString("workdir")
91 if err != nil {
92 return types.ContainerExecOptions{}, err
93 }
94
95 envFile, err := cmd.Flags().GetStringSlice("env-file")
96 if err != nil {
97 return types.ContainerExecOptions{}, err
98 }
99 env, err := cmd.Flags().GetStringArray("env")
100 if err != nil {
101 return types.ContainerExecOptions{}, err
102 }
103 privileged, err := cmd.Flags().GetBool("privileged")
104 if err != nil {
105 return types.ContainerExecOptions{}, err
106 }
107 user, err := cmd.Flags().GetString("user")
108 if err != nil {
109 return types.ContainerExecOptions{}, err
110 }
111
112 return types.ContainerExecOptions{
113 GOptions: globalOptions,
114 TTY: isTerminal,
115 Interactive: isInteractive,

Callers 1

execActionFunction · 0.85

Calls 1

ProcessRootCmdFlagsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…