testserver package - github.com/fluxcd/pkg/testserver - Go Packages

This section is empty.

This section is empty.

This section is empty.

type ArtifactServer struct {
	*HTTPServer
}

ArtifactServer is an HTTP/S artifact server for testing purposes. It offers utilities to generate mock tarball artifacts to be served by the server.

func NewTempArtifactServer() (*ArtifactServer, error)

NewTempArtifactServer returns an ArtifactServer with a newly created temp dir as the artifact docroot.

ArtifactFromDir creates a tar.gz artifact from the source directory into the destination dir and returns the artifact SHA256 checksum.

ArtifactFromFiles creates a tar.gz artifact from the given files and returns the file name of the artifact.

URLForFile returns the URL the given file can be reached at or an error if the server has not been started.

File holds the name and string contents of an artifact file.

type HTTPServer struct {
	
}

HTTPServer is an HTTP/S server for testing purposes. It can serve files from the configured docroot and offers a lightweight middleware configuration option.

func NewHTTPServer(docroot string) *HTTPServer

NewHTTPServer returns a HTTPServer with the given docroot set.

func NewTempHTTPServer() (*HTTPServer, error)

NewTempHTTPServer returns a HTTPServer with a newly created temp dir as the docroot.

Root returns the configured docroot of the HTTPServer.

func (s *HTTPServer) Start()

Start starts the HTTPServer.

StartTLS starts the TLS HTTPServer with the given TLS configuration.

func (s *HTTPServer) Stop()

Stop stops the HTTPServer, if started.

URL returns the address the HTTPServer is listening at, if started.

WithMiddleware configures the middleware of the HTTPServer, this can for example be used to configure Basic Auth credentials. It should be called before starting the server, or requires a stop/start cycle.