utils

package
v3.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 32 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVersionNotGiven returned when version not given by client
	ErrVersionNotGiven = errors.New("version not given in URL path")
	// ErrVersionNotSupported returned when given version is too old
	ErrVersionNotSupported = errors.New("given version is not supported")
)
View Source
var (
	ErrLinkNotSupport = errors.New("Link is not supported")
)

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, key string, value string, err error)

func ContainerNotFound

func ContainerNotFound(w http.ResponseWriter, name string, err error)

func ContainerNotRunning

func ContainerNotRunning(w http.ResponseWriter, containerID string, err error)

func Error

func Error(w http.ResponseWriter, apiMessage string, code int, err error)

Error formats an API response to an error

apiMessage and code must match the container API, and are sent to client err is logged on the system running the podman service

func FilterMapToString

func FilterMapToString(filters map[string][]string) (string, error)

func GetImage

func GetImage(r *http.Request, name string) (*libimage.Image, error)

func GetImages

func GetImages(w http.ResponseWriter, r *http.Request) ([]*libimage.Image, error)

GetImages is a common function used to get images for libpod and other compatibility mechanisms

func GetName

func GetName(r *http.Request) string

GetName extracts the name from the mux

func ImageNotFound

func ImageNotFound(w http.ResponseWriter, name string, err error)

func InternalServerError

func InternalServerError(w http.ResponseWriter, err error)

func IsLibpodRequest

func IsLibpodRequest(r *http.Request) bool

IsLibpodRequest returns true if the request related to a libpod endpoint (e.g., /v2/libpod/...).

func IsRegistryReference added in v3.2.2

func IsRegistryReference(name string) error

IsRegistryReference checks if the specified name points to the "docker://" transport. If it points to no supported transport, we'll assume a non-transport reference pointing to an image (e.g., "fedora:latest").

func MarshalErrorJSON

func MarshalErrorJSON(ptr unsafe.Pointer, stream *jsoniter.Stream)

MarshalErrorJSON writes error to stream as string

func MarshalErrorJSONIsEmpty

func MarshalErrorJSONIsEmpty(_ unsafe.Pointer) bool

func MarshalErrorSliceJSON

func MarshalErrorSliceJSON(ptr unsafe.Pointer, stream *jsoniter.Stream)

MarshalErrorSliceJSON writes []error to stream as []string JSON blob

func MarshalErrorSliceJSONIsEmpty

func MarshalErrorSliceJSONIsEmpty(_ unsafe.Pointer) bool

func NetworkNotFound

func NetworkNotFound(w http.ResponseWriter, name string, err error)

func ParseStorageReference

func ParseStorageReference(name string) (types.ImageReference, error)

ParseStorageReference parses the specified image name to a `types.ImageReference` and enforces it to refer to a containers-storage-transport reference.

func PodNotFound

func PodNotFound(w http.ResponseWriter, name string, err error)

func SecretNotFound added in v3.1.0

func SecretNotFound(w http.ResponseWriter, nameOrID string, err error)

func SessionNotFound

func SessionNotFound(w http.ResponseWriter, name string, err error)

func SupportedVersion

func SupportedVersion(r *http.Request, condition string) (semver.Version, error)

SupportedVersion validates that the version provided by client is included in the given condition https://github.com/blang/semver#ranges provides the details for writing conditions If a version is not given in URL path, ErrVersionNotGiven is returned

func SupportedVersionWithDefaults

func SupportedVersionWithDefaults(r *http.Request) (semver.Version, error)

SupportedVersionWithDefaults validates that the version provided by client valid is supported by server minimal API version <= client path version <= maximum API version focused on the endpoint tree from URL

func UnSupportedParameter

func UnSupportedParameter(param string)

UnsupportedParameter logs a given param by its string name as not supported.

func VolumeNotFound

func VolumeNotFound(w http.ResponseWriter, name string, err error)

func WaitContainerDocker

func WaitContainerDocker(w http.ResponseWriter, r *http.Request)

func WaitContainerLibpod

func WaitContainerLibpod(w http.ResponseWriter, r *http.Request)

func WriteJSON

func WriteJSON(w http.ResponseWriter, code int, value interface{})

WriteJSON writes an interface value encoded as JSON to w

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, value interface{})

WriteResponse encodes the given value as JSON or string and renders it for http client

Types

This section is empty.

Jump to

Keyboard shortcuts

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