testutil

package
v3.7.8-1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2017 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const SampleImageManifestSchema1 = `` /* 1130-byte string literal not displayed */

Variables

This section is empty.

Functions

func AddImage

func AddImage(t *testing.T, fos *FakeOpenShift, image *imageapiv1.Image, namespace, name, tag string)

AddImage tags image into the image stream namespace/name.

func AddImageStream

func AddImageStream(t *testing.T, fos *FakeOpenShift, namespace, name string, annotations map[string]string) *imageapiv1.ImageStream

AddImageStream creates a new image stream with annotations.

func AddImageStreamTag

func AddImageStreamTag(t *testing.T, fos *FakeOpenShift, image *imageapiv1.Image, namespace, name string, tag *imageapiv1.TagReference) *imageapiv1.ImageStreamTag

AddImageStreamTag creates an image stream tag.

func AddRandomImage

func AddRandomImage(t *testing.T, fos *FakeOpenShift, namespace, name, tag string) *imageapiv1.Image

AddRandomImage creates a new image with a random content and tags it into the image stream namespace/name. If the image stream doesn't exists, it will be created.

func AddUntaggedImage

func AddUntaggedImage(t *testing.T, fos *FakeOpenShift, image *imageapiv1.Image)

AddUntaggedImage creates image in fos.

func AssertManifestsEqual added in v1.5.0

func AssertManifestsEqual(t *testing.T, description string, ma distribution.Manifest, mb distribution.Manifest)

AssertManifestsEqual compares two manifests and returns if they are equal. Signatures of manifest schema 1 are not taken into account.

func CanonicalManifest

func CanonicalManifest(m distribution.Manifest) ([]byte, error)

CanonicalManifest returns m in its canonical representation.

func CreateAndUploadTestManifest added in v1.5.0

func CreateAndUploadTestManifest(
	ctx context.Context,
	schemaVersion ManifestSchemaVersion,
	layerCount int,
	serverURL *url.URL,
	creds auth.CredentialStore,
	repoName, tag string,
) (dgst digest.Digest, canonical, manifestConfig string, manifest distribution.Manifest, err error)

CreateUploadTestManifest generates a random manifest blob and uploads it to the given repository. For this purpose, a given number of layers will be created and uploaded.

func CreateRandomImage

func CreateRandomImage(namespace, name string) (*imageapiv1.Image, error)

CreateRandomImage creates an image with a random content.

func CreateRandomTarFile

func CreateRandomTarFile() ([]byte, error)

CreateRandomTarFile creates a random tarfile and returns its content. An error is returned if there is a problem generating valid content. Inspired by github.com/docker/distribution/testutil/tarfile.go.

func MakeRandomLayer

func MakeRandomLayer() ([]byte, distribution.Descriptor, error)

func MakeSchema1Manifest added in v1.5.0

func MakeSchema1Manifest(name, tag string, layers []distribution.Descriptor) (distribution.Manifest, error)

MakeSchema1Manifest constructs a schema 1 manifest from a given list of digests and returns the digest of the manifest

func MakeSchema2Manifest added in v1.5.0

func MakeSchema2Manifest(config distribution.Descriptor, layers []distribution.Descriptor) (distribution.Manifest, error)

MakeSchema2Manifest constructs a schema 2 manifest from a given list of digests and returns the digest of the manifest

func NewBasicCredentialStore added in v1.3.3

func NewBasicCredentialStore(username, password string) auth.CredentialStore

NewBasicCredentialStore returns a test credential store for use with registry token handler and/or basic handler.

func NewImageForManifest

func NewImageForManifest(repoName string, rawManifest string, manifestConfig string, managedByOpenShift bool) (*imageapiv1.Image, error)

NewImageManifest creates a new Image object for the given manifest string. Note that the manifest must contain signatures if it is of schema 1.

func NewRepository

func NewRepository(ctx context.Context, repoName string, baseURL string, transport http.RoundTripper) (distribution.Repository, error)

NewRepository creates a new Repository for the given repository name, base URL and creds.

func NewTransport

func NewTransport(baseURL string, repoName string, creds auth.CredentialStore) (http.RoundTripper, error)

func UploadBlob

func UploadBlob(ctx context.Context, repo distribution.Repository, desc distribution.Descriptor, content []byte) error

UploadBlob uploads the blob with content to repo and verifies its digest.

func UploadManifest

func UploadManifest(ctx context.Context, repo distribution.Repository, tag string, manifest distribution.Manifest) error

UploadManifest uploads manifest to repo and verifies its digest.

func UploadRandomTestBlob added in v1.5.0

func UploadRandomTestBlob(ctx context.Context, serverURL *url.URL, creds auth.CredentialStore, repoName string) (distribution.Descriptor, []byte, error)

UploadRandomTestBlob generates a random tar file and uploads it to the given repository.

func WithTestLogger

func WithTestLogger(parent context.Context, t *testing.T) context.Context

WithTestLogger creates a new context with a Distribution logger which records the text in the test's error log.

Types

type ConfigPayload added in v1.5.0

type ConfigPayload []byte

func MakeManifestConfig added in v1.5.0

func MakeManifestConfig() (ConfigPayload, distribution.Descriptor, error)

type FakeOpenShift

type FakeOpenShift struct {
	// contains filtered or unexported fields
}

FakeOpenShift is an in-mempory reactors for fake.Client.

func NewFakeOpenShift

func NewFakeOpenShift(ctx context.Context) *FakeOpenShift

NewFakeOpenShift constructs the fake OpenShift reactors.

func NewFakeOpenShiftWithClient

func NewFakeOpenShiftWithClient(ctx context.Context) (*FakeOpenShift, *imagefakeclient.FakeImageV1)

NewFakeOpenShiftWithClient constructs a fake client associated with the stateful fake in-memory OpenShift reactors. The fake OpenShift is available for direct interaction, so you can make buggy states.

func (*FakeOpenShift) AddReactorsTo

func (fos *FakeOpenShift) AddReactorsTo(c *imagefakeclient.FakeImageV1)

AddReactorsTo binds the reactors to client.

func (*FakeOpenShift) CreateImage

func (fos *FakeOpenShift) CreateImage(image *imageapiv1.Image) (*imageapiv1.Image, error)

func (*FakeOpenShift) CreateImageStream

func (fos *FakeOpenShift) CreateImageStream(namespace string, is *imageapiv1.ImageStream) (*imageapiv1.ImageStream, error)

func (*FakeOpenShift) CreateImageStreamMapping

func (fos *FakeOpenShift) CreateImageStreamMapping(namespace string, ism *imageapiv1.ImageStreamMapping) (*imageapiv1.ImageStreamMapping, error)

func (*FakeOpenShift) CreateImageStreamTag

func (fos *FakeOpenShift) CreateImageStreamTag(namespace string, istag *imageapiv1.ImageStreamTag) (*imageapiv1.ImageStreamTag, error)

func (*FakeOpenShift) GetImage

func (fos *FakeOpenShift) GetImage(name string) (*imageapiv1.Image, error)

func (*FakeOpenShift) GetImageStream

func (fos *FakeOpenShift) GetImageStream(namespace, repo string) (*imageapiv1.ImageStream, error)

func (*FakeOpenShift) GetImageStreamImage

func (fos *FakeOpenShift) GetImageStreamImage(namespace string, id string) (*imageapiv1.ImageStreamImage, error)

func (*FakeOpenShift) UpdateImage

func (fos *FakeOpenShift) UpdateImage(image *imageapiv1.Image) (*imageapiv1.Image, error)

func (*FakeOpenShift) UpdateImageStream

func (fos *FakeOpenShift) UpdateImageStream(namespace string, is *imageapiv1.ImageStream) (*imageapiv1.ImageStream, error)

type ManifestSchemaVersion added in v1.5.0

type ManifestSchemaVersion int
const (
	ManifestSchema1 ManifestSchemaVersion = 1
	ManifestSchema2 ManifestSchemaVersion = 2
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL