repotest

package
v3.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: Apache-2.0 Imports: 22 Imported by: 2

Documentation

Overview

Package repotest provides utilities for testing.

The server provides a testing server that can be set up and torn down quickly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OCIServer added in v3.5.0

type OCIServer struct {
	*registry.Registry
	RegistryURL  string
	Dir          string
	TestUsername string
	TestPassword string
	Client       *ociRegistry.Client
}

func NewOCIServer added in v3.5.0

func NewOCIServer(t *testing.T, dir string) (*OCIServer, error)

func (*OCIServer) Run added in v3.5.0

func (srv *OCIServer) Run(t *testing.T, opts ...OCIServerOpt)

type OCIServerOpt added in v3.5.0

type OCIServerOpt func(config *OCIServerRunConfig)

func WithDependingChart added in v3.5.0

func WithDependingChart(c *chart.Chart) OCIServerOpt

type OCIServerRunConfig added in v3.5.0

type OCIServerRunConfig struct {
	DependingChart *chart.Chart
}

type Server

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

Server is an implementation of a repository server for testing.

func NewServer

func NewServer(docroot string) *Server

NewServer creates a repository server for testing.

docroot should be a temp dir managed by the caller.

This will start the server, serving files off of the docroot.

Use CopyCharts to move charts into the repository and then index them for service.

func NewTempServer deprecated

func NewTempServer(glob string) (*Server, error)

NewTempServer creates a server inside of a temp dir.

If the passed in string is not "", it will be treated as a shell glob, and files will be copied from that path to the server's docroot.

The caller is responsible for destroying the temp directory as well as stopping the server.

Deprecated: use NewTempServerWithCleanup

func NewTempServerWithCleanup added in v3.4.0

func NewTempServerWithCleanup(t *testing.T, glob string) (*Server, error)

NewTempServerWithCleanup creates a server inside of a temp dir.

If the passed in string is not "", it will be treated as a shell glob, and files will be copied from that path to the server's docroot.

The caller is responsible for stopping the server. The temp dir will be removed by testing package automatically when test finished.

func NewTempServerWithCleanupAndBasicAuth added in v3.7.0

func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server

Set up a fake repo with basic auth enabled

func (*Server) CopyCharts

func (s *Server) CopyCharts(origin string) ([]string, error)

CopyCharts takes a glob expression and copies those charts to the server root.

func (*Server) CreateIndex

func (s *Server) CreateIndex() error

CreateIndex will read docroot and generate an index.yaml file.

func (*Server) LinkIndices

func (s *Server) LinkIndices() error

LinkIndices links the index created with CreateIndex and makes a symbolic link to the cache index.

This makes it possible to simulate a local cache of a repository.

func (*Server) Root

func (s *Server) Root() string

Root gets the docroot for the server.

func (*Server) Start

func (s *Server) Start()

func (*Server) StartTLS added in v3.1.2

func (s *Server) StartTLS()

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server and closes all connections.

It should be called explicitly.

func (*Server) URL

func (s *Server) URL() string

URL returns the URL of the server.

Example:

http://localhost:1776

func (*Server) WithMiddleware

func (s *Server) WithMiddleware(middleware http.HandlerFunc)

WithMiddleware injects middleware in front of the server. This can be used to inject additional functionality like layering in an authentication frontend.

Jump to

Keyboard shortcuts

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