Documentation ¶
Index ¶
- func AssertBlobsLen(t *testing.T, path string, expected int)
- func AssertContains(t *testing.T, slice []string, elements ...string)
- func AssertDockerMediaTypes(t *testing.T, image v1.Image)
- func AssertDoesNotContain(t *testing.T, slice []string, elements ...string)
- func AssertEq(t *testing.T, actual, expected interface{})
- func AssertEqAnnotation(t *testing.T, manifest v1.Descriptor, key, value string)
- func AssertError(t *testing.T, actual error, expected string)
- func AssertMatch(t *testing.T, actual string, expected *regexp.Regexp)
- func AssertNil(t *testing.T, actual interface{})
- func AssertNotEq(t *testing.T, v1, v2 interface{})
- func AssertNotNil(t *testing.T, actual any)
- func AssertOCIMediaTypes(t *testing.T, image v1.Image)
- func AssertPathDoesNotExists(t *testing.T, path string)
- func AssertPathExists(t *testing.T, path string)
- func AssertRemoteImageIndex(t *testing.T, repoName string, mediaType types.MediaType, ...)
- func AssertTrue(t *testing.T, p func() bool)
- func BasicAuth(handler http.Handler, username, password, realm string) http.Handler
- func CreateSingleFileLayerTar(layerPath, txt, osType string) (string, error)
- func CreateSingleFileTar(path, txt string) (io.Reader, error)
- func CreateSingleFileTarReader(path, txt string) io.ReadCloser
- func DeleteRegistryBlob(t *testing.T, repoName string, digest v1.Hash, encodedAuth string)
- func DigestsFromImageIndex(t *testing.T, index v1.ImageIndex) []v1.Hash
- func DockerCli(t *testing.T) dockercli.CommonAPIClient
- func DockerHostname(t *testing.T) string
- func DockerRmi(dockerCli dockercli.CommonAPIClient, repoNames ...string) error
- func Eventually(t *testing.T, test func() bool, every time.Duration, timeout time.Duration)
- func FetchImageIndexDescriptor(t *testing.T, repoName string) v1.ImageIndex
- func FetchManifestImageConfigFile(t *testing.T, repoName string) *v1.ConfigFile
- func FetchManifestLayers(t *testing.T, repoName string) []string
- func FileDiffID(t *testing.T, path string) string
- func ImageID(t *testing.T, repoName string) string
- func PullIfMissing(t *testing.T, docker dockercli.CommonAPIClient, ref string)
- func PushImage(t *testing.T, _ dockercli.CommonAPIClient, refStr string)
- func RandString(n int) string
- func RandomLayer(t *testing.T, tmpDir string) (path string, sha string, contents []byte)
- func ReadConfigFile(t *testing.T, manifest *v1.Manifest, path string) *v1.ConfigFile
- func ReadImageIndex(t *testing.T, path string) v1.ImageIndex
- func ReadIndexManifest(t *testing.T, path string) *v1.IndexManifest
- func ReadManifest(t *testing.T, digest v1.Hash, path string) *v1.Manifest
- func ReadManifestAndConfigFile(t *testing.T, path string) (*v1.Manifest, *v1.ConfigFile)
- func ReadOnly(handler http.Handler) http.Handler
- func RemoteImage(t *testing.T, testImageName string, opts []remote.Option) v1.Image
- func RemoteRunnableBaseImage(t *testing.T) v1.Image
- func Run(t *testing.T, cmd *exec.Cmd) string
- func RunE(cmd *exec.Cmd) (output string, exitCode int, err error)
- func RunnableBaseImage(os string) string
- func StringElementAt(elements []string, offset int) string
- type DockerRegistry
- func (r *DockerRegistry) EncodedAuth() string
- func (r *DockerRegistry) EncodedLabeledAuth() string
- func (r *DockerRegistry) RepoName(name string) string
- func (r *DockerRegistry) SetInaccessible(imageName string) string
- func (r *DockerRegistry) SetReadOnly(imageName string) string
- func (r *DockerRegistry) SetReadWrite(imageName string) string
- func (r *DockerRegistry) SetWriteOnly(imageName string) string
- func (r *DockerRegistry) Start(t *testing.T)
- func (r *DockerRegistry) Stop(t *testing.T)
- type ImageAccess
- type ImagePrivileges
- type RegistryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDoesNotContain ¶
func AssertEqAnnotation ¶
func AssertEqAnnotation(t *testing.T, manifest v1.Descriptor, key, value string)
func AssertNotEq ¶
func AssertNotNil ¶
func AssertPathDoesNotExists ¶
func AssertPathExists ¶
func AssertRemoteImageIndex ¶
func AssertTrue ¶
func BasicAuth ¶
BasicAuth wraps a handler, allowing requests with matching username and password headers, otherwise rejecting with a 401
func CreateSingleFileTarReader ¶
func CreateSingleFileTarReader(path, txt string) io.ReadCloser
func DeleteRegistryBlob ¶
DeleteRegistryBlob deletes the blob with the given digest from the registry by issuing an HTTP DELETE request.
func DigestsFromImageIndex ¶
func DockerHostname ¶
DockerHostname discovers the appropriate registry hostname. For test to run where "localhost" is not the daemon host, a `insecure-registries` entry of `<host net>/<mask>` with a range that contains the host's non-loopback IP. For Docker Desktop, this can be set here: https://docs.docker.com/docker-for-mac/#docker-engine Otherwise, its set in the daemon.json: https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file If the entry is not found, the fallback is "localhost"
func Eventually ¶
func FetchImageIndexDescriptor ¶
func FetchImageIndexDescriptor(t *testing.T, repoName string) v1.ImageIndex
func FetchManifestImageConfigFile ¶
func FetchManifestImageConfigFile(t *testing.T, repoName string) *v1.ConfigFile
func PullIfMissing ¶
func PullIfMissing(t *testing.T, docker dockercli.CommonAPIClient, ref string)
func PushImage ¶
func PushImage(t *testing.T, _ dockercli.CommonAPIClient, refStr string)
PushImage pushes an image to a registry, optionally using credentials from any set DOCKER_CONFIG
func RandString ¶
func RandomLayer ¶
func ReadConfigFile ¶
func ReadImageIndex ¶
func ReadImageIndex(t *testing.T, path string) v1.ImageIndex
func ReadIndexManifest ¶
func ReadIndexManifest(t *testing.T, path string) *v1.IndexManifest
func ReadOnly ¶
ReadOnly wraps a handler, allowing only GET and HEAD requests, otherwise rejecting with a 405
func RemoteImage ¶
func RunnableBaseImage ¶
RunnableBaseImage returns an image that can be used by a daemon of the same OS to create an container or run a command
func StringElementAt ¶
Types ¶
type DockerRegistry ¶
type DockerRegistry struct { Host string Port string Name string DockerDirectory string // contains filtered or unexported fields }
func NewDockerRegistry ¶
func NewDockerRegistry(ops ...RegistryOption) *DockerRegistry
func (*DockerRegistry) EncodedAuth ¶
func (r *DockerRegistry) EncodedAuth() string
func (*DockerRegistry) EncodedLabeledAuth ¶
func (r *DockerRegistry) EncodedLabeledAuth() string
func (*DockerRegistry) RepoName ¶
func (r *DockerRegistry) RepoName(name string) string
func (*DockerRegistry) SetInaccessible ¶
func (r *DockerRegistry) SetInaccessible(imageName string) string
SetInaccessible set the given image name to do not have any access when the ImagePrivileges feature was enabled Returns RepoName(imageName)
func (*DockerRegistry) SetReadOnly ¶
func (r *DockerRegistry) SetReadOnly(imageName string) string
SetReadOnly set the given image name to be readable when the ImagePrivileges feature was enabled Returns RepoName(imageName)
func (*DockerRegistry) SetReadWrite ¶
func (r *DockerRegistry) SetReadWrite(imageName string) string
SetReadWrite set the given image name to be readable and writable when the ImagePrivileges feature was enabled Returns RepoName(imageName)
func (*DockerRegistry) SetWriteOnly ¶
func (r *DockerRegistry) SetWriteOnly(imageName string) string
SetWriteOnly set the given image name to be writable when the ImagePrivileges feature was enabled Returns RepoName(imageName)
func (*DockerRegistry) Start ¶
func (r *DockerRegistry) Start(t *testing.T)
Start creates a docker registry following these rules:
- Shared handler will be used, otherwise a new one will be created
- By default the shared handler will be wrapped with a read only handler
- In case credentials are configured, the shared handler will be wrapped with a basic authentication handler and if any image privileges were set, then the custom handler will be used to wrap the auth handler.
func (*DockerRegistry) Stop ¶
func (r *DockerRegistry) Stop(t *testing.T)
type ImagePrivileges ¶
type ImagePrivileges struct {
// contains filtered or unexported fields
}
func NewImagePrivileges ¶
func NewImagePrivileges(imageAccess ...ImageAccess) ImagePrivileges
NewImagePrivileges creates a new ImagePrivileges, use Readable or Writable to set the properties accordingly. For examples: NewImagePrivileges() returns ImagePrivileges{readable: false, writable: false} NewImagePrivileges(Readable) returns ImagePrivileges{readable: true, writable: false} NewImagePrivileges(Writable) returns ImagePrivileges{readable: false, writable: true} NewImagePrivileges(Readable, Writable) returns ImagePrivileges{readable: true, writable: true}
type RegistryOption ¶
type RegistryOption func(registry *DockerRegistry)
func WithAuth ¶
func WithAuth(dockerConfigDir string) RegistryOption
WithAuth adds credentials to registry. Omitting will make the registry read-only
func WithImagePrivileges ¶
func WithImagePrivileges() RegistryOption
WithImagePrivileges enables the execution of read/write access validations based on the image name
func WithSharedHandler ¶
func WithSharedHandler(handler http.Handler) RegistryOption
WithSharedHandler allows two instances to share the same data by re-using the registry handler. Use an authenticated registry to write to a read-only unauthenticated registry.