(container string, defaultContainer bool, image, release string, preserveFDs uint, command []string, emitEscapeSequence, fallbackToBash, pedantic bool)
| 167 | } |
| 168 | |
| 169 | func 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 |
no test coverage detected
searching dependent graphs…