(container, image, release, authFile string, showCommandToEnter bool)
| 188 | } |
| 189 | |
| 190 | func createContainer(container, image, release, authFile string, showCommandToEnter bool) error { |
| 191 | if container == "" { |
| 192 | panic("container not specified") |
| 193 | } |
| 194 | |
| 195 | if image == "" { |
| 196 | panic("image not specified") |
| 197 | } |
| 198 | |
| 199 | if release == "" { |
| 200 | panic("release not specified") |
| 201 | } |
| 202 | |
| 203 | enterCommand := getEnterCommand(container) |
| 204 | |
| 205 | logrus.Debugf("Checking if container %s already exists", container) |
| 206 | |
| 207 | if exists, _ := podman.ContainerExists(container); exists { |
| 208 | var builder strings.Builder |
| 209 | fmt.Fprintf(&builder, "container %s already exists\n", container) |
| 210 | fmt.Fprintf(&builder, "Enter with: %s\n", enterCommand) |
| 211 | fmt.Fprintf(&builder, "Run '%s --help' for usage.", executableBase) |
| 212 | |
| 213 | errMsg := builder.String() |
| 214 | return errors.New(errMsg) |
| 215 | } |
| 216 | |
| 217 | pulled, err := pullImage(image, release, authFile) |
| 218 | if err != nil { |
| 219 | return err |
| 220 | } |
| 221 | if !pulled { |
| 222 | return nil |
| 223 | } |
| 224 | |
| 225 | imageFull, err := podman.GetFullyQualifiedImageFromRepoTags(image) |
| 226 | if err != nil { |
| 227 | var errImage *podman.ImageError |
| 228 | |
| 229 | if errors.As(err, &errImage) { |
| 230 | if errors.Is(err, podman.ErrImageRepoTagsEmpty) { |
| 231 | logrus.Debugf("Image %s has empty RepoTags, likely because it is without a name", image) |
| 232 | imageFull = image |
| 233 | } else if errors.Is(err, podman.ErrImageRepoTagsMissing) { |
| 234 | return fmt.Errorf("missing RepoTags for image %s", image) |
| 235 | } else { |
| 236 | panicMsg := fmt.Sprintf("unexpected %T: %s", err, err) |
| 237 | panic(panicMsg) |
| 238 | } |
| 239 | } else { |
| 240 | return err |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | var toolbxDelayEntryPointEnv []string |
| 245 | |
| 246 | if toolbxDelayEntryPoint, ok := os.LookupEnv("TOOLBX_DELAY_ENTRY_POINT"); ok { |
| 247 | toolbxDelayEntryPointEnvArg := "TOOLBX_DELAY_ENTRY_POINT=" + toolbxDelayEntryPoint |
no test coverage detected
searching dependent graphs…