open-nomad/testutil/container_images.go
Daniel Bennett f7e316e9cd
tests: enable newer windows (#17401)
* "allow" (don't try to drop) linux capabilities
  in the docker test driver harness (see #15181)
* refactor to allow different busybox images
  since windows containers need to be the same
  version as the underlying OS, and we're
  moving from 2016 to 2019
* one docker test was flaky from apparently
  being a bit slower on windows, so add Wait()
2023-06-02 11:38:38 -05:00

44 lines
937 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package testutil
import (
"os"
"runtime"
)
const (
// BusyboxImageEnvName is always used, if set, by TestBusyboxImage()
BusyboxImageEnvName = "BUSYBOX_IMAGE"
)
func TestDockerImage(name, tag string) string {
img := name + ":" + tag
if IsCI() {
// use our mirror to avoid rate-limiting in CI
img = "docker.mirror.hashicorp.services/" + img
} else {
// explicitly include docker.io for podman
img = "docker.io/" + img
}
return img
}
func TestBusyboxImage() string {
// if env is set, use it verbatim
if img, ok := os.LookupEnv(BusyboxImageEnvName); ok {
return img
}
// otherwise, figure it out
name := "busybox"
tag := "1"
if runtime.GOOS == "windows" {
// this image is maintained in https://github.com/hashicorp/busybox-windows
name = "hashicorpdev/busybox-windows"
tag = "server2016-0.1"
}
return TestDockerImage(name, tag)
}