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

Function createOptions

cmd/nerdctl/container/container_create.go:60–521  ·  view source on GitHub ↗

revive:disable:function-length

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

58
59//revive:disable:function-length
60func createOptions(cmd *cobra.Command) (types.ContainerCreateOptions, error) {
61 var err error
62 opt := types.ContainerCreateOptions{
63 Stdout: cmd.OutOrStdout(),
64 Stderr: cmd.ErrOrStderr(),
65 }
66
67 opt.GOptions, err = helpers.ProcessRootCmdFlags(cmd)
68 if err != nil {
69 return opt, err
70 }
71
72 opt.NerdctlCmd, opt.NerdctlArgs = helpers.GlobalFlags(cmd)
73
74 // #region for basic flags
75 // The command `container start` doesn't support the flag `--interactive`. Set the default value of `opt.Interactive` false.
76 opt.Interactive = false
77 opt.TTY, err = cmd.Flags().GetBool("tty")
78 if err != nil {
79 return opt, err
80 }
81 // The nerdctl create command similar to nerdctl run -d except the container is never started.
82 // So we keep the default value of `opt.Detach` true.
83 opt.Detach = true
84 opt.Restart, err = cmd.Flags().GetString("restart")
85 if err != nil {
86 return opt, err
87 }
88 opt.Rm, err = cmd.Flags().GetBool("rm")
89 if err != nil {
90 return opt, err
91 }
92 opt.Pull, err = cmd.Flags().GetString("pull")
93 if err != nil {
94 return opt, err
95 }
96 opt.Pid, err = cmd.Flags().GetString("pid")
97 if err != nil {
98 return opt, err
99 }
100 opt.StopSignal, err = cmd.Flags().GetString("stop-signal")
101 if err != nil {
102 return opt, err
103 }
104 opt.StopTimeout, err = cmd.Flags().GetInt("stop-timeout")
105 if err != nil {
106 return opt, err
107 }
108 // #endregion
109
110 // #region for platform flags
111 opt.Platform, err = cmd.Flags().GetString("platform")
112 if err != nil {
113 return opt, err
114 }
115 // #endregion
116
117 // #region for init process flags

Callers 2

createActionFunction · 0.70

Calls 4

ProcessRootCmdFlagsFunction · 0.92
GlobalFlagsFunction · 0.92
ValidateHealthcheckFlagsFunction · 0.92
VerifyOptionsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…