helpers

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 34 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 CompleteImageRef

func CompleteImageRef(ref string) string

CompleteImageRef returns image reference

func ExtractDigest

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

func GetDockerHubRegistry

func GetDockerHubRegistry() string

GetDockerHubRegistry returns dockerhub registry or proxy

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)

AddFileToFolder Adds a file to a folder with 0600 permission

func (*Assets) AddFileToFolderWithPermissions

func (a *Assets) AddFileToFolderWithPermissions(path, content string, perm os.FileMode)

AddFileToFolderWithPermissions Adds a file to a folder and sets permissions

func (*Assets) AddFolder

func (a *Assets) AddFolder(path string, perm os.FileMode)

AddFolder Adds a file to a folder with 0600 permission

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
	Tag        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

NewFakeRegistry Creates a registry that uses the ggcr version

func NewFakeRegistryWithDiskBackend

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

NewFakeRegistryWithDiskBackend Creates a registry that saves blobs to disk

func NewFakeRegistryWithRepoSeparation

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

NewFakeRegistryWithRepoSeparation Creates a registry that saves the blobs based on the repository

func (*FakeTestRegistryBuilder) Build

func (*FakeTestRegistryBuilder) BuildWithRegistryOpts

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)

CopyAllImagesFromRepo Copies all images in a particular repository to a destination

func (*FakeTestRegistryBuilder) CopyBundleImage

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

CopyBundleImage Copies a bundle metadata that will create a bundle in to location

func (*FakeTestRegistryBuilder) CopyFromImageRef

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

func (*FakeTestRegistryBuilder) CopyImage

func (*FakeTestRegistryBuilder) Host

func (r *FakeTestRegistryBuilder) Host() string

func (*FakeTestRegistryBuilder) IsConfigBlobLayer

func (r *FakeTestRegistryBuilder) IsConfigBlobLayer(digest v1.Hash) bool

IsConfigBlobLayer checks if digest is from configuration blob

func (*FakeTestRegistryBuilder) Layer

func (r *FakeTestRegistryBuilder) Layer(digest v1.Hash) (v1.Layer, error)

Layer retrieves a layer from images At this point the function does *NOT* search on Indexes

func (*FakeTestRegistryBuilder) ProcessedImages

func (r *FakeTestRegistryBuilder) ProcessedImages() *imageset.ProcessedImages

ProcessedImages returns the images that where created in the registry

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) Tag

func (r *FakeTestRegistryBuilder) Tag(imageRef, tag string)

Tag the referenced image

func (*FakeTestRegistryBuilder) WithARandomImageIndex

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

WithARandomImageIndex Creates random index with reference imageName and with numImages images

func (*FakeTestRegistryBuilder) WithBasicAuth

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

func (*FakeTestRegistryBuilder) WithBasicAuthPerRepository

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

WithBundleFromPath Creates bundle from the provided path

func (*FakeTestRegistryBuilder) WithCustomHandler

func (r *FakeTestRegistryBuilder) WithCustomHandler(handler func(http.ResponseWriter, *http.Request) bool)

WithCustomHandler Adds the provided http handler that will be called before the default one If the provided handler returns true it means that no further processing is needed. this will skip any further handlers

func (*FakeTestRegistryBuilder) WithHandlerFunc

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)

WithNonDistributableLayerInImage Adds non-distributable layer of the type types.OCIUncompressedRestrictedLayer to all the provided images

func (*FakeTestRegistryBuilder) WithRandomBundle

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

WithRandomBundle sample function This function creates a bundle image, but WithImageRefs or WithEveryImageFromPath needs to be called on the return value of this function to ensure that a bundle is correctly created on the registry

func (*FakeTestRegistryBuilder) WithRandomBundleAndImages

func (r *FakeTestRegistryBuilder) WithRandomBundleAndImages(bundleName string, imageRefs []lockconfig.ImageRef) BundleInfo

WithRandomBundleAndImages creates a random bundle image with the provided images

func (*FakeTestRegistryBuilder) WithRandomImage

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

WithRandomImage adds a new random image with 3 layers

func (*FakeTestRegistryBuilder) WithRandomImageWithLayers

func (r *FakeTestRegistryBuilder) WithRandomImageWithLayers(imageNameFromTest string, n int64) *ImageOrImageIndexWithTarPath

WithRandomImageWithLayers adds a new random image with n number of layers provided

func (*FakeTestRegistryBuilder) WithRandomTaggedImage

func (r *FakeTestRegistryBuilder) WithRandomTaggedImage(imageNameFromTest, tag string) *ImageOrImageIndexWithTarPath

WithRandomTaggedImage Creates a random image with a tag

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

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

HTTPRequestLogs Slice of HTTP Requests

func NewHTTPRequestLogs

func NewHTTPRequestLogs() *HTTPRequestLogs

NewHTTPRequestLogs Build a new HTTPRequestLogs struct

func (*HTTPRequestLogs) Add

func (h *HTTPRequestLogs) Add(request HTTPRequestLog)

Add new HTTP Request to the Log

func (*HTTPRequestLogs) Last

func (h *HTTPRequestLogs) Last() HTTPRequestLog

Last Retrieve Last HTTP Request

func (*HTTPRequestLogs) Len

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) GetImageLayersDigest added in v0.40.0

func (i *ImageFactory) GetImageLayersDigest(image string) []string

GetImageLayersDigest will return image's layers digest

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, v1.Layer)

WithNonDistributableLayer Adds non-distributable layer of the type types.OCIUncompressedRestrictedLayer to the current image

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
	Buf      *bytes.Buffer
}

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
}

Directories

Path Synopsis
Package registry implements a docker V2 registry and the OCI distribution specification.
Package registry implements a docker V2 registry and the OCI distribution specification.
httptest
Package httptest provides a method for testing a TLS server a la net/http/httptest.
Package httptest provides a method for testing a TLS server a la net/http/httptest.

Jump to

Keyboard shortcuts

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