helpers

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const BundleFile = "bundle.yml"
View Source
const BundleYAML = `` /* 152-byte string literal not displayed */
View Source
const ImageFile = "images.yml"
View Source
const ImagesYAML = `---
apiVersion: imgpkg.carvel.dev/v1alpha1
kind: ImagesLock
`

Variables

This section is empty.

Functions

func CompareFiles

func CompareFiles(t *testing.T, path1, path2 string)

func ExtractDigest

func ExtractDigest(t *testing.T, out string) string

Types

type Assertion

type Assertion struct {
	T *testing.T
	// contains filtered or unexported fields
}

func (*Assertion) AssertBundleLock

func (a *Assertion) AssertBundleLock(path, expectedBundleRef, expectedTag string)

func (*Assertion) AssertImagesLock

func (a *Assertion) AssertImagesLock(path string, images []lockconfig.ImageRef)

func (*Assertion) ImagesDigestIsOnTar

func (a *Assertion) ImagesDigestIsOnTar(tarFilePath string, imagesDigestRef ...string)

func (*Assertion) ValidateCosignSignature

func (a *Assertion) ValidateCosignSignature(refs []string)

func (*Assertion) ValidateImagesPresenceInRegistry

func (a *Assertion) ValidateImagesPresenceInRegistry(refs []string) error

type Assets

type Assets struct {
	T              *testing.T
	CreatedFolders []string
}

func (*Assets) AddFileToFolder

func (a *Assets) AddFileToFolder(path, content string)

func (*Assets) CleanCreatedFolders

func (a *Assets) CleanCreatedFolders()

func (*Assets) CreateAndCopySimpleApp

func (a *Assets) CreateAndCopySimpleApp(prefix string) string

func (*Assets) CreateTempFolder

func (a *Assets) CreateTempFolder(prefix string) string

func (Assets) FilesInFolder

func (a Assets) FilesInFolder() []string

func (Assets) SimpleAppDir

func (a Assets) SimpleAppDir() string

func (*Assets) ValidateFilesAreEqual

func (a *Assets) ValidateFilesAreEqual(expected, got string, fileToCheck []string)

type BundleFactory

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

func NewBundleDir

func NewBundleDir(t *testing.T, assets *Assets) BundleFactory

func (*BundleFactory) AddFileToBundle

func (b *BundleFactory) AddFileToBundle(path, content string)

func (*BundleFactory) CreateBundleDir

func (b *BundleFactory) CreateBundleDir(bYml, iYml string) string

type BundleInfo

type BundleInfo struct {
	Image      v1.Image
	BundleName string
	BundlePath string
	Digest     string
	RefDigest  string
	// contains filtered or unexported fields
}

func (BundleInfo) WithEveryImageFromPath

func (b BundleInfo) WithEveryImageFromPath(path string, labels map[string]string) BundleInfo

func (BundleInfo) WithImageRefs

func (b BundleInfo) WithImageRefs(imageRefs []lockconfig.ImageRef) BundleInfo

type Env

type Env struct {
	Image          string
	ImgpkgPath     string
	RelocationRepo string
	BundleFactory  BundleFactory
	Assets         *Assets
	Assert         Assertion
	ImageFactory   ImageFactory
	Logger         *Logger
	// contains filtered or unexported fields
}

func BuildEnv

func BuildEnv(t *testing.T) *Env

func (*Env) AddCleanup

func (e *Env) AddCleanup(f func())

func (*Env) Cleanup

func (e *Env) Cleanup()

func (*Env) UpdateT

func (e *Env) UpdateT(t *testing.T)

func (Env) Validate

func (e Env) Validate(t *testing.T)

type FakeTestRegistryBuilder

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

func NewFakeRegistry

func NewFakeRegistry(t *testing.T, logger *Logger) *FakeTestRegistryBuilder

func (*FakeTestRegistryBuilder) Build

func (*FakeTestRegistryBuilder) BuildWithRegistryOpts added in v0.23.0

func (r *FakeTestRegistryBuilder) BuildWithRegistryOpts(opts registry.Opts) registry.Registry

BuildWithRegistryOpts Builds registry with provided Registry Opts

func (*FakeTestRegistryBuilder) CleanUp

func (r *FakeTestRegistryBuilder) CleanUp()

func (*FakeTestRegistryBuilder) CopyAllImagesFromRepo

func (r *FakeTestRegistryBuilder) CopyAllImagesFromRepo(imageRef, to string)

func (*FakeTestRegistryBuilder) CopyBundleImage

func (r *FakeTestRegistryBuilder) CopyBundleImage(bundleInfo BundleInfo, to string) BundleInfo

func (*FakeTestRegistryBuilder) CopyFromImageRef

func (r *FakeTestRegistryBuilder) CopyFromImageRef(imageRef, to string) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) CopyImage

func (*FakeTestRegistryBuilder) Host

func (r *FakeTestRegistryBuilder) Host() string

func (*FakeTestRegistryBuilder) ReferenceOnTestServer

func (r *FakeTestRegistryBuilder) ReferenceOnTestServer(repo string) string

func (*FakeTestRegistryBuilder) RemoveByImageRef

func (r *FakeTestRegistryBuilder) RemoveByImageRef(imageRef string)

RemoveByImageRef This function only works as expected before running Build() Prevents the creation in the registry of the image provided

func (*FakeTestRegistryBuilder) RemoveImage

func (r *FakeTestRegistryBuilder) RemoveImage(imageRef string)

func (*FakeTestRegistryBuilder) ResetHandler

func (*FakeTestRegistryBuilder) WithARandomImageIndex

func (r *FakeTestRegistryBuilder) WithARandomImageIndex(imageName string, numImages int64) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithBasicAuth

func (r *FakeTestRegistryBuilder) WithBasicAuth(username string, password string)

func (*FakeTestRegistryBuilder) WithBasicAuthPerRepository added in v0.23.0

func (r *FakeTestRegistryBuilder) WithBasicAuthPerRepository(repo, username, password string)

WithBasicAuthPerRepository Adds authentication check for a particular repository

func (*FakeTestRegistryBuilder) WithBundleFromPath

func (r *FakeTestRegistryBuilder) WithBundleFromPath(bundleName string, path string) BundleInfo

func (*FakeTestRegistryBuilder) WithCustomHandler

func (r *FakeTestRegistryBuilder) WithCustomHandler(handler http.HandlerFunc)

func (*FakeTestRegistryBuilder) WithHandlerFunc added in v0.24.0

func (r *FakeTestRegistryBuilder) WithHandlerFunc(handler func(writer http.ResponseWriter, request *http.Request) bool)

WithHandlerFunc Adds authentication check for a particular repository

func (*FakeTestRegistryBuilder) WithIdentityToken

func (r *FakeTestRegistryBuilder) WithIdentityToken(idToken string)

func (*FakeTestRegistryBuilder) WithImage

func (r *FakeTestRegistryBuilder) WithImage(imageNameFromTest string, image v1.Image) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithImageFromPath

func (r *FakeTestRegistryBuilder) WithImageFromPath(imageNameFromTest string, path string, labels map[string]string) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithImageIndex

func (r *FakeTestRegistryBuilder) WithImageIndex(imageIndexName string, images ...mutate.Appendable) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithImageStatusCodeRemap

func (r *FakeTestRegistryBuilder) WithImageStatusCodeRemap(img string, originalStatusCode int, remappedStatusCode int) *FakeTestRegistryBuilder

func (*FakeTestRegistryBuilder) WithImmutableTags

func (r *FakeTestRegistryBuilder) WithImmutableTags(repo string, imgTag string) *FakeTestRegistryBuilder

func (*FakeTestRegistryBuilder) WithLocationsImage

func (r *FakeTestRegistryBuilder) WithLocationsImage(bundleRef string, tmpFolder string, config bundle.ImageLocationsConfig) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithNonDistributableLayerInImage

func (r *FakeTestRegistryBuilder) WithNonDistributableLayerInImage(imageNames ...string)

func (*FakeTestRegistryBuilder) WithRandomBundle

func (r *FakeTestRegistryBuilder) WithRandomBundle(bundleName string) BundleInfo

func (*FakeTestRegistryBuilder) WithRandomImage

func (r *FakeTestRegistryBuilder) WithRandomImage(imageNameFromTest string) *ImageOrImageIndexWithTarPath

func (*FakeTestRegistryBuilder) WithRegistryToken

func (r *FakeTestRegistryBuilder) WithRegistryToken(regToken string)

func (*FakeTestRegistryBuilder) WithRequestLogging

func (r *FakeTestRegistryBuilder) WithRequestLogging() *HTTPRequestLogs

WithRequestLogging enables the logging of the HTTP requests sent to the registry

type HTTPRequestLog

type HTTPRequestLog struct {
	Method string
	URL    string
}

HTTPRequestLog Log entry for HTTP requests sent to the registry

type HTTPRequestLogs added in v0.23.0

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

HTTPRequestLogs Slice of HTTP Requests

func NewHTTPRequestLogs added in v0.23.0

func NewHTTPRequestLogs() *HTTPRequestLogs

NewHTTPRequestLogs Build a new HTTPRequestLogs struct

func (*HTTPRequestLogs) Add added in v0.23.0

func (h *HTTPRequestLogs) Add(request HTTPRequestLog)

Add new HTTP Request to the Log

func (*HTTPRequestLogs) Last added in v0.23.0

func (h *HTTPRequestLogs) Last() HTTPRequestLog

Last Retrieve Last HTTP Request

func (*HTTPRequestLogs) Len added in v0.23.1

func (h *HTTPRequestLogs) Len() int

Len Length of request logs

type ImageFactory

type ImageFactory struct {
	Assets *Assets
	T      *testing.T
	// contains filtered or unexported fields
}

func (*ImageFactory) Download

func (i *ImageFactory) Download(imgRef, location string)

func (*ImageFactory) ImageDigest

func (i *ImageFactory) ImageDigest(imgRef string) string

func (*ImageFactory) PushImageIndex

func (i *ImageFactory) PushImageIndex(imgRef string)

func (*ImageFactory) PushImageWithANonDistributableLayer

func (i *ImageFactory) PushImageWithANonDistributableLayer(imgRef string, mediaType types.MediaType) string

func (*ImageFactory) PushImageWithLayerSize

func (i *ImageFactory) PushImageWithLayerSize(imgRef string, size int64) string

func (*ImageFactory) PushSimpleAppImageWithRandomFile

func (i *ImageFactory) PushSimpleAppImageWithRandomFile(imgpkg Imgpkg, imgRef string) string

func (*ImageFactory) PushSimpleAppImageWithRandomFileWithAuth

func (i *ImageFactory) PushSimpleAppImageWithRandomFileWithAuth(imgpkg Imgpkg, imgRef string, host, username, password string) string

func (*ImageFactory) SignImage

func (i *ImageFactory) SignImage(imgRef string) string

type ImageOrImageIndexWithTarPath

type ImageOrImageIndexWithTarPath struct {
	Image      v1.Image
	ImageIndex v1.ImageIndex

	RefDigest string
	Digest    string
	Tag       string
	// contains filtered or unexported fields
}

func (*ImageOrImageIndexWithTarPath) WithNonDistributableLayer

func (r *ImageOrImageIndexWithTarPath) WithNonDistributableLayer() *ImageOrImageIndexWithTarPath

type Imgpkg

type Imgpkg struct {
	T          *testing.T
	L          Logger
	ImgpkgPath string
}

func (Imgpkg) Run

func (i Imgpkg) Run(args []string) string

func (Imgpkg) RunWithOpts

func (i Imgpkg) RunWithOpts(args []string, opts RunOpts) (string, error)

type LogLevel

type LogLevel int
const (
	LogTrace LogLevel = iota
	LogDebug LogLevel = iota
)

type Logger

type Logger struct {
	LogLevel LogLevel
}

func (Logger) Debugf

func (l Logger) Debugf(msg string, args ...interface{})

func (Logger) Errorf

func (l Logger) Errorf(msg string, args ...interface{})

func (Logger) Logf

func (l Logger) Logf(msg string, args ...interface{})

func (Logger) Section

func (l Logger) Section(msg string, f func())

func (Logger) Tracef

func (l Logger) Tracef(msg string, args ...interface{})

func (Logger) Warnf

func (l Logger) Warnf(msg string, args ...interface{})

type RunOpts

type RunOpts struct {
	AllowError   bool
	StderrWriter io.Writer
	StdoutWriter io.Writer
	StdinReader  io.Reader
	CancelCh     chan struct{}
	Redact       bool
	EnvVars      []string
}

Jump to

Keyboard shortcuts

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