utils

package
v5.7.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLinkNotSupport = errors.New("link is not supported")
)

Functions

func ArtifactNotFound added in v5.6.0

func ArtifactNotFound(w http.ResponseWriter, _ string, err error)

func BadRequest

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

func CompatPull

func CompatPull(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runtime, reference string, pullPolicy config.PullPolicy, pullOptions *libimage.PullOptions)

func ContainerNotFound

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

func Error

func Error(w http.ResponseWriter, 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 GetDecoder

func GetDecoder(r *http.Request) *schema.Decoder

func GetImage

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

func GetName

func GetName(r *http.Request) string

GetName extracts the name from the mux

func GetVar

func GetVar(r *http.Request, k string) string

func ImageNotFound

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

func InternalServerError

func InternalServerError(w http.ResponseWriter, err error)

func IsLibpodLocalRequest

func IsLibpodLocalRequest(r *http.Request) bool

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

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

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(ptr 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(ptr unsafe.Pointer) bool

func NetworkNotFound

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

func NormalizeToDockerHub

func NormalizeToDockerHub(r *http.Request, nameOrID string) (string, error)

NormalizeToDockerHub normalizes the specified nameOrID to Docker Hub if the request is for the compat API and if containers.conf set the specific mode. If nameOrID is a (short) ID for a local image, the full ID will be returned.

func PSTitles

func PSTitles(output string) []string

PSTitles merges CAPS headers from ps output. All PS headers are single words, except for CAPS. Function compines CAP Headers into single field separated by a space.

func ParseJSONOptionalSlice

func ParseJSONOptionalSlice(value string, query url.Values, paramName string) ([]string, error)

ParseJSONOptionalSlice parses a JSON array string into a slice if the parameter exists. Returns nil if the parameter is not found.

func ParseOptionalBool

func ParseOptionalBool(value bool, fieldName string, queryValues url.Values) (types.OptionalBool, bool)

ParseOptionalBool creates a types.OptionalBool if the field exists in query values. Returns the OptionalBool and whether the field was found.

func ParseOptionalJSONField

func ParseOptionalJSONField[T any](jsonStr, fieldName string, queryValues url.Values, target *T) error

ParseOptionalJSONField unmarshals a JSON string only if the field exists in query values.

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, _ string, err error)

func PossiblyEnforceDockerHub

func PossiblyEnforceDockerHub(r *http.Request, sys *types.SystemContext) error

PossiblyEnforceDockerHub sets fields in the system context to enforce resolving short names to Docker Hub if the request is for the compat API and if containers.conf set the specific mode.

func ProcessBuildError

func ProcessBuildError(w http.ResponseWriter, err error)

func SecretNotFound

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

func SessionNotFound

func SessionNotFound(w http.ResponseWriter, _ 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 UnSupportedParameter

func UnSupportedParameter(param string)

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

func VolumeNotFound

func VolumeNotFound(w http.ResponseWriter, _ 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 any)

WriteJSON writes an interface value encoded as JSON to w

func WriteResponse

func WriteResponse(w http.ResponseWriter, code int, value any)

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

Types

type BuildError

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

func GetBadRequestError

func GetBadRequestError(key, value string, err error) *BuildError

func GetFileNotFoundError

func GetFileNotFoundError(err error) *BuildError

func GetGenericBadRequestError

func GetGenericBadRequestError(err error) *BuildError

func GetInternalServerError

func GetInternalServerError(err error) *BuildError

func (*BuildError) Error

func (e *BuildError) Error() string

type ResponseSender

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

ResponseSender provides streaming JSON responses with automatic flushing.

func NewBuildResponseSender

func NewBuildResponseSender(w http.ResponseWriter) *ResponseSender

NewBuildResponseSender creates a ResponseSender for streaming build responses. Optionally writes to a debug file if PODMAN_RETAIN_BUILD_ARTIFACT is set.

func (*ResponseSender) Send

func (b *ResponseSender) Send(response any)

Send encodes and sends a response object as JSON with automatic flushing.

func (*ResponseSender) SendBuildAux

func (b *ResponseSender) SendBuildAux(aux []byte)

SendBuildAux sends auxiliary data as part of a build response.

func (*ResponseSender) SendBuildError

func (b *ResponseSender) SendBuildError(message string)

SendBuildError sends an error message as a build response.

func (*ResponseSender) SendBuildStream

func (b *ResponseSender) SendBuildStream(message string)

SendBuildStream sends a build stream message to the client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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