oci

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryResponse

type BinaryResponse struct {
	Body        []byte
	ContentType string
}

func (*BinaryResponse) WriteTo

func (v *BinaryResponse) WriteTo(w http.ResponseWriter, r *http.Request)

type DynamicRegistries

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

func NewDynamicRegistries

func NewDynamicRegistries(baseDir string, options []RegistryOption) *DynamicRegistries

func (*DynamicRegistries) FindRegistry

func (r *DynamicRegistries) FindRegistry(ctx context.Context, id string) (*Registry, error)

type FileResponse

type FileResponse struct {
	Stat        os.FileInfo
	ContentType string
	Path        string
}

func (*FileResponse) WriteTo

func (v *FileResponse) WriteTo(w http.ResponseWriter, r *http.Request)

type HTTPResponse

type HTTPResponse struct {
	Status      int
	Location    string
	ContentType string
	Range       string
}

func ErrorResponse

func ErrorResponse(statusCode int) *HTTPResponse

func (*HTTPResponse) WriteTo

func (v *HTTPResponse) WriteTo(w http.ResponseWriter, r *http.Request)

type JSONResponse

type JSONResponse struct {
	Object interface{}
}

func (*JSONResponse) WriteTo

func (v *JSONResponse) WriteTo(w http.ResponseWriter, r *http.Request)

type ManifestInfo

type ManifestInfo struct {
	ImageSizeBytes string   `json:"imageSizeBytes"`
	MediaType      string   `json:"mediaType"`
	TimeCreatedMs  string   `json:"timeCreatedMs"`
	TimeUploadedMS string   `json:"timeUploadedMs"`
	Tags           []string `json:"tag"`
}

type Registries

type Registries interface {
	FindRegistry(ctx context.Context, key string) (*Registry, error)
}

type Registry

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

Registry manages a single oci registry. Our registries serve a single named image, with multiple tags.

func NewRegistry

func NewRegistry(name string, rootDir string, options ...RegistryOption) (*Registry, error)

NewRegistry constructs an instance of Registry

func (*Registry) AppendUpload

func (r *Registry) AppendUpload(ctx context.Context, uuid string, pos int64, in io.Reader) (int64, error)

func (*Registry) CompleteUpload

func (r *Registry) CompleteUpload(ctx context.Context, uuid string, digest string) (string, error)

func (*Registry) CreateManifest

func (r *Registry) CreateManifest(ctx context.Context, tag string, b []byte) error

func (*Registry) ListTags

func (r *Registry) ListTags(ctx context.Context) (*Tags, error)

func (*Registry) ReadManifest

func (r *Registry) ReadManifest(ctx context.Context, tag string) ([]byte, error)

func (*Registry) ServeBlob

func (r *Registry) ServeBlob(ctx context.Context, blob string) (Response, error)

ServeBlob returns the HTTP response for a blob. The return type is optimized for serving for HTTP (we might want an internal method in the future)

func (*Registry) StartUpload

func (r *Registry) StartUpload(ctx context.Context) (string, error)

func (*Registry) UploadPosition

func (r *Registry) UploadPosition(ctx context.Context, uuid string) (int64, error)

type RegistryOption

type RegistryOption interface {
	// contains filtered or unexported methods
}

RegistryOption is implemented by configuration settings for git repository.

func WithBasicAuth

func WithBasicAuth(username, password string) RegistryOption

type Response

type Response interface {
	WriteTo(w http.ResponseWriter, r *http.Request)
}

type Server

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

Server is a mock OCI server implementing "just enough" of the oci protocol

func NewServer

func NewServer(registries Registries, opts ...ServerOption) (*Server, error)

NewGitServer constructs a GitServer backed by the specified repo.

func (*Server) Endpoint

func (s *Server) Endpoint() string

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context, listen string, addressChannel chan<- net.Addr) error

ListenAndServe starts the git server on "listen". The address we actually start listening on will be posted to addressChannel

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the entrypoint for http requests.

type ServerOption

type ServerOption interface {
	// contains filtered or unexported methods
}

ServerOption follows the option pattern for customizing the server

type StaticRegistries

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

StaticRegistries holds fixed registries

func NewStaticRegistries

func NewStaticRegistries() *StaticRegistries

NewStaticRegistries constructs an instance of StaticRegistries

func (*StaticRegistries) Add

func (r *StaticRegistries) Add(id string, repo *Registry) error

Add registers a git repository under the specified id

func (*StaticRegistries) FindRegistry

func (r *StaticRegistries) FindRegistry(ctx context.Context, id string) (*Registry, error)

FindRegistry returns a registry registered under the specified id, or nil if none is registered.

type StreamingResponse

type StreamingResponse struct {
	ContentType string
	Body        io.ReadCloser
}

func (*StreamingResponse) WriteTo

func (v *StreamingResponse) WriteTo(w http.ResponseWriter, r *http.Request)

type Tags

type Tags struct {
	Name      string                  `json:"name"`
	Manifests map[string]ManifestInfo `json:"manifest"`
	Tags      []string                `json:"tags"`
	Children  []string                `json:"child"`
}

type TextResponse

type TextResponse struct {
	Body string
}

func (*TextResponse) WriteTo

func (v *TextResponse) WriteTo(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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