MCPcopy
hub / github.com/containers/toolbox / create

Function create

src/cmd/create.go:122–188  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

120}
121
122func create(cmd *cobra.Command, args []string) error {
123 if utils.IsInsideContainer() {
124 if !utils.IsInsideToolboxContainer() {
125 return errors.New("this is not a Toolbx container")
126 }
127
128 exitCode, err := utils.ForwardToHost()
129 return &exitError{exitCode, err}
130 }
131
132 if cmd.Flag("distro").Changed && cmd.Flag("image").Changed {
133 var builder strings.Builder
134 fmt.Fprintf(&builder, "options --distro and --image cannot be used together\n")
135 fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
136
137 errMsg := builder.String()
138 return errors.New(errMsg)
139 }
140
141 if cmd.Flag("image").Changed && cmd.Flag("release").Changed {
142 var builder strings.Builder
143 fmt.Fprintf(&builder, "options --image and --release cannot be used together\n")
144 fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
145
146 errMsg := builder.String()
147 return errors.New(errMsg)
148 }
149
150 if cmd.Flag("authfile").Changed {
151 if !utils.PathExists(createFlags.authFile) {
152 var builder strings.Builder
153 fmt.Fprintf(&builder, "file %s not found\n", createFlags.authFile)
154 fmt.Fprintf(&builder, "'podman login' can be used to create the file.\n")
155 fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase)
156
157 errMsg := builder.String()
158 return errors.New(errMsg)
159 }
160 }
161
162 var container string
163 var containerArg string
164
165 if len(args) != 0 {
166 container = args[0]
167 containerArg = "CONTAINER"
168 } else if createFlags.container != "" {
169 container = createFlags.container
170 containerArg = "--container"
171 }
172
173 container, image, release, err := resolveContainerAndImageNames(container,
174 containerArg,
175 createFlags.distro,
176 createFlags.image,
177 createFlags.release)
178
179 if err != nil {

Callers

nothing calls this directly

Calls 2

createContainerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…