ocitest

package
v0.0.0-...-cca4c9a Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteErrors

func WriteErrors(errors []ResponseError) map[string]interface{}

WriteErrors writes error response object for OCI server errors

Types

type MockOCIServer

type MockOCIServer struct {
	ServeManifest func(c *gin.Context) // Handler for serving a manifest for a blob
	ServeBlob     func(c *gin.Context) // Handler for serving a blob from the OCI server
	// contains filtered or unexported fields
}

MockOCIServer is an entity for mocking an OCI server for testing. At the moment, this is only needed for the devfile registry index server endpoint testing, however, this entity could be used in a testing scenario where an OCI server is needed.

More on the OCI server specification, see https://github.com/opencontainers/distribution-spec/blob/main/spec.md

func NewMockOCIServer

func NewMockOCIServer() *MockOCIServer

NewMockOCIServer creates a MockOCIServer entity

func (*MockOCIServer) Close

func (server *MockOCIServer) Close()

Close the MockOCIServer connection

func (*MockOCIServer) Start

func (server *MockOCIServer) Start(listenAddr string) error

Start listening on listenAddr for requests to the MockOCIServer

type ProxyRecorder

type ProxyRecorder struct {
	*httptest.ResponseRecorder
	http.CloseNotifier
}

ProxyRecorder is an extension of the ResponseRecorder struct within httptest with an additional receiver CloseNotifier which is needed for testing the proxy route to the OCI server

func NewProxyRecorder

func NewProxyRecorder() *ProxyRecorder

NewProxyRecorder creates a new ProxyRecorder entity

func (*ProxyRecorder) CloseNotify

func (rec *ProxyRecorder) CloseNotify() <-chan bool

CloseNotify creates a bool channel for notifying a closure of a request

type ResponseError

type ResponseError struct {
	Code    string                 `json:"code"`    // Error code
	Message string                 `json:"message"` // Error Message
	Detail  map[string]interface{} `json:"detail"`  // Additional detail on the error (optional)
}

ResponseError repersents an error returned in an errors response by an OCI server, see https://github.com/opencontainers/distribution-spec/blob/main/spec.md#error-codes

Jump to

Keyboard shortcuts

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