Documentation ¶
Overview ¶
Package testutil implements functions used to test the different packages
Index ¶
- func AssertChartAnnotations(t *testing.T, chartDir string, annotationsKey string, ...) bool
- func AssertErrorMatch(t *testing.T, err error, re *regexp.Regexp, msgAndArgs ...interface{}) bool
- func AssertFileDoesNotExist(t *testing.T, path string, msgAndArgs ...interface{}) bool
- func AssertFileExists(t *testing.T, path string, msgAndArgs ...interface{}) bool
- func AssertPanicsMatch(t *testing.T, fn func(), re *regexp.Regexp, msgAndArgs ...interface{}) bool
- func CosignImage(url string, key string, opts ...crane.Option) error
- func CosignVerifyImage(url string, key string, opts ...crane.Option) error
- func CreateOCILayout(ctx context.Context, srcDir, destDir string) error
- func CreateSampleImages(imageData *ImageData, archs []string) ([]v1.Image, error)
- func CreateSingleArchImage(imageData *ImageData, plat string) (v1.Image, error)
- func GenerateCosignCertificateFiles(tmpDir string) (privFile, pubFile string, err error)
- func Measure(fn func()) time.Duration
- func MustNormalizeYAML(text string) string
- func NewOCIServer(t *testing.T, dir string) (*repotest.OCIServer, error)
- func NewOCIServerWithCustomCreds(t *testing.T, dir string, username, password string) (*repotest.OCIServer, error)
- func NormalizeYAML(text string) (string, error)
- func PullArtifact(ctx context.Context, src string, dir string, opts ...crane.Option) error
- func ReadRemoteImageManifest(src string, opts ...Option) (map[string]DigestData, error)
- func RenderScenario(origin string, destDir string, data map[string]interface{}) error
- func RenderTemplateFile(file string, tplData interface{}, files ...string) (string, error)
- func RenderTemplateString(str string, tplData interface{}, files ...string) (string, error)
- func UnpackOCILayout(ctx context.Context, srcLayout string, destDir string) error
- type AnnotationEntry
- type Auth
- type Config
- type DigestData
- type ImageData
- type Option
- type Sandbox
- func (sb *Sandbox) Cleanup() error
- func (sb *Sandbox) ContainsPath(path string) bool
- func (sb *Sandbox) Mkdir(p string, mode os.FileMode) (string, error)
- func (sb *Sandbox) Normalize(path string) string
- func (sb *Sandbox) Symlink(oldname, newname string) (string, error)
- func (sb *Sandbox) TempFile(args ...string) string
- func (sb *Sandbox) Touch(file string) string
- func (sb *Sandbox) Track(p string)
- func (sb *Sandbox) Write(path string, data string) (string, error)
- func (sb *Sandbox) WriteFile(path string, data []byte, mode os.FileMode) (string, error)
- type TestServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertChartAnnotations ¶
func AssertChartAnnotations(t *testing.T, chartDir string, annotationsKey string, expectedImages []AnnotationEntry, msgAndArgs ...interface{}) bool
AssertChartAnnotations checks if the specified chart contains the provided annotations
func AssertErrorMatch ¶
AssertErrorMatch fails the test t if err is nil or if its message does not match the provided regexp re
func AssertFileDoesNotExist ¶
AssertFileDoesNotExist failts the test t if path exists
func AssertFileExists ¶
AssertFileExists failts the test t if path does not exists
func AssertPanicsMatch ¶
AssertPanicsMatch fails the test t if fn does not panic or if the panic message does not match the provided regexp re
func CosignImage ¶ added in v0.3.0
CosignImage signs a remote artifact with the provided key
func CosignVerifyImage ¶ added in v0.3.0
CosignVerifyImage verifies a remote artifact signature with the provided key
func CreateOCILayout ¶ added in v0.3.0
CreateOCILayout creates a oc-layout directory from a source directory containing a set of files
func CreateSampleImages ¶
CreateSampleImages create a multiplatform sample image
func CreateSingleArchImage ¶
CreateSingleArchImage creates a sample image for the specified platform
func GenerateCosignCertificateFiles ¶ added in v0.3.0
GenerateCosignCertificateFiles generates sample signing keys for usage with cosign
func MustNormalizeYAML ¶
MustNormalizeYAML returns the normalized version of the text YAML or panics
func NewOCIServer ¶ added in v0.4.0
NewOCIServer returns a new OCI server with basic auth for testing purposes
func NewOCIServerWithCustomCreds ¶ added in v0.4.0
func NewOCIServerWithCustomCreds(t *testing.T, dir string, username, password string) (*repotest.OCIServer, error)
NewOCIServerWithCustomCreds returns a new OCI server with custom credentials
func NormalizeYAML ¶
NormalizeYAML returns a normalized version of the provided YAML text
func PullArtifact ¶ added in v0.3.0
PullArtifact downloads an artifact from a remote oci into a oci-layout
func ReadRemoteImageManifest ¶
func ReadRemoteImageManifest(src string, opts ...Option) (map[string]DigestData, error)
ReadRemoteImageManifest reads the image src digests from a remote repository
func RenderScenario ¶
RenderScenario renders a full directory specified by origin in the destDir directory with the specified data
func RenderTemplateFile ¶
RenderTemplateFile renders the golang template specified in file with the provided tplData. It can receive an optional list of files to parse, including templates
func RenderTemplateString ¶
RenderTemplateString renders a golang template defined in str with the provided tplData. It can receive an optional list of files to parse, including templates
Types ¶
type AnnotationEntry ¶
AnnotationEntry defines an annotation entry
type Auth ¶ added in v0.4.0
Auth defines the authentication information to access the container registry
type DigestData ¶
type DigestData struct { Arch string Digest digest.Digest }
DigestData defines Digest information for an Architecture
type ImageData ¶
type ImageData struct { Name string Image string Digests []DigestData }
ImageData defines information for a docker image
type Option ¶ added in v0.3.0
type Option func(*Config)
Option defines a Config option
func WithMetadataDir ¶ added in v0.3.0
WithMetadataDir sets a signing key to be used while pushing images
func WithSignKey ¶ added in v0.3.0
WithSignKey sets a signing key to be used while pushing images
type Sandbox ¶
type Sandbox struct { sync.RWMutex // Root of the sandbox Root string // contains filtered or unexported fields }
Sandbox allows manipulating files and directories with paths sandboxed into the Root directory
func NewSandbox ¶
NewSandbox returns a new sandbox with the configured root or a random temporary one if none is provided
func (*Sandbox) ContainsPath ¶
ContainsPath returns true if path is contained inside the sandbox and false otherwise. This function does not check for the existence of the file, just checks if the path is contained in the sanbox root
func (*Sandbox) Normalize ¶
Normalize returns the fully normalized version of path, including the Root prefix
func (*Sandbox) TempFile ¶
TempFile returns a temporary non-existent file. An optional file tail can be provided
type TestServer ¶
type TestServer struct { ServerURL string // contains filtered or unexported fields }
TestServer defines a images registry for testing
func NewTestServer ¶
func NewTestServer() (*TestServer, error)
NewTestServer returns a new TestServer
func (*TestServer) AddImage ¶
func (s *TestServer) AddImage(img *ImageData) error
AddImage adds information for an image to the server so it can be later queried
func (*TestServer) LoadImagesFromFile ¶
func (s *TestServer) LoadImagesFromFile(file string) ([]*ImageData, error)
LoadImagesFromFile adds the images specified in the JSON file provided to the server