package repotest
import "helm.sh/helm/v3/pkg/repo/repotest"
Package repotest provides utilities for testing.
The server provides a testing server that can be set up and torn down quickly.
Index ¶
- type OCIServer
- func NewOCIServer(t *testing.T, dir string) (*OCIServer, error)
- func (srv *OCIServer) Run(t *testing.T, opts ...OCIServerOpt)
- type OCIServerOpt
- type OCIServerRunConfig
- type Server
- func NewServer(docroot string) *Server
- func NewTempServer(glob string) (*Server, error)
- func NewTempServerWithCleanup(t *testing.T, glob string) (*Server, error)
- func NewTempServerWithCleanupAndBasicAuth(t *testing.T, glob string) *Server
- func (s *Server) CopyCharts(origin string) ([]string, error)
- func (s *Server) CreateIndex() error
- func (s *Server) LinkIndices() error
- func (s *Server) Root() string
- func (s *Server) Start()
- func (s *Server) StartTLS()
- func (s *Server) Stop()
- func (s *Server) URL() string
- func (s *Server) WithMiddleware(middleware http.HandlerFunc)
Types ¶
type OCIServer ¶
type OCIServer struct { *registry.Registry RegistryURL string Dir string TestUsername string TestPassword string Client *ociRegistry.Client }
func NewOCIServer ¶
func (*OCIServer) Run ¶
func (srv *OCIServer) Run(t *testing.T, opts ...OCIServerOpt)
type OCIServerOpt ¶
type OCIServerOpt func(config *OCIServerRunConfig)
func WithDependingChart ¶
func WithDependingChart(c *chart.Chart) OCIServerOpt
type OCIServerRunConfig ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an implementation of a repository server for testing.
func NewServer ¶
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 ¶
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 ¶
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 ¶
Set up a fake repo with basic auth enabled
func (*Server) CopyCharts ¶
CopyCharts takes a glob expression and copies those charts to the server root.
func (*Server) CreateIndex ¶
CreateIndex will read docroot and generate an index.yaml file.
func (*Server) LinkIndices ¶
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 ¶
Root gets the docroot for the server.
func (*Server) Start ¶
func (s *Server) Start()
func (*Server) StartTLS ¶
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 ¶
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.
Source Files ¶
doc.go server.go
- Version
- v3.17.3 (latest)
- Published
- Apr 9, 2025
- Platform
- linux/amd64
- Imports
- 21 packages
- Last checked
- 1 month ago –
Tools for package owners.