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

Function runCommand

src/cmd/run.go:169–355  ·  view source on GitHub ↗
(container string,
	defaultContainer bool,
	image, release string,
	preserveFDs uint,
	command []string,
	emitEscapeSequence, fallbackToBash, pedantic bool)

Source from the content-addressed store, hash-verified

167}
168
169func runCommand(container string,
170 defaultContainer bool,
171 image, release string,
172 preserveFDs uint,
173 command []string,
174 emitEscapeSequence, fallbackToBash, pedantic bool) error {
175
176 if !pedantic {
177 if image == "" {
178 panic("image not specified")
179 }
180
181 if release == "" {
182 panic("release not specified")
183 }
184 }
185
186 logrus.Debugf("Checking if container %s exists", container)
187
188 if _, err := podman.ContainerExists(container); err != nil {
189 logrus.Debugf("Container %s not found", container)
190
191 if pedantic {
192 err := createErrorContainerNotFound(container)
193 return err
194 }
195
196 containers, err := getContainers()
197 if err != nil {
198 err := createErrorContainerNotFound(container)
199 return err
200 }
201
202 containersCount := len(containers)
203 logrus.Debugf("Found %d containers", containersCount)
204
205 if containersCount == 0 {
206 var shouldCreateContainer bool
207 promptForCreate := true
208
209 if rootFlags.assumeYes {
210 shouldCreateContainer = true
211 promptForCreate = false
212 }
213
214 if promptForCreate {
215 prompt := "No Toolbx containers found. Create now? [y/N]"
216 shouldCreateContainer = askForConfirmation(prompt)
217 }
218
219 if !shouldCreateContainer {
220 fmt.Printf("A container can be created later with the 'create' command.\n")
221 fmt.Printf("Run '%s --help' for usage.\n", executableBase)
222 return nil
223 }
224
225 if err := createContainer(container, image, release, "", false); err != nil {
226 return err

Callers 3

enterFunction · 0.85
runFunction · 0.85
rootRunImplFunction · 0.85

Calls 15

getContainersFunction · 0.85
askForConfirmationFunction · 0.85
createContainerFunction · 0.85
callFlatpakSessionHelperFunction · 0.85
startP11KitServerFunction · 0.85
getCDIFileForNvidiaFunction · 0.85
saveCDISpecToFunction · 0.85
startContainerFunction · 0.85
showEntryPointLogsFunction · 0.85
runCommandWithFallbacksFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…