bindings

package
v0.7.0-dev.12 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("function not implemented")
)

Functions

func CheckResponseCode

func CheckResponseCode(inError error) (int, error)

func JoinURL

func JoinURL(elements ...string) string

JoinURL elements with '/'

func NewConnection

func NewConnection(ctx context.Context, uri string) (context.Context, error)

NewConnection creates a new service connection without an identity

func NewConnectionWithIdentity

func NewConnectionWithIdentity(ctx context.Context, uri string, identity string, machine bool) (context.Context, error)

NewConnectionWithIdentity takes a URI as a string and returns a context with the Connection embedded as a value. This context needs to be passed to each endpoint to work correctly.

A valid URI connection should be scheme:// For example tcp://localhost:<port> or unix:///run/podman/podman.sock or ssh://<user>@<host>[:port]/run/podman/podman.sock

func ServiceVersion

func ServiceVersion(ctx context.Context) *semver.Version

ServiceVersion from context build by NewConnection()

Types

type APIResponse

type APIResponse struct {
	*http.Response
	Request *http.Request
}

func (*APIResponse) IsClientError

func (h *APIResponse) IsClientError() bool

IsClientError returns true if the response code is 4xx

func (*APIResponse) IsConflictError

func (h *APIResponse) IsConflictError() bool

IsConflictError returns true if the response code is 409

func (*APIResponse) IsInformational

func (h *APIResponse) IsInformational() bool

IsInformational returns true if the response code is 1xx

func (*APIResponse) IsRedirection

func (h *APIResponse) IsRedirection() bool

IsRedirection returns true if the response code is 3xx

func (*APIResponse) IsServerError

func (h *APIResponse) IsServerError() bool

IsServerError returns true if the response code is 5xx

func (*APIResponse) IsSuccess

func (h *APIResponse) IsSuccess() bool

IsSuccess returns true if the response code is 2xx

func (*APIResponse) Process

func (h *APIResponse) Process(unmarshalInto interface{}) error

Process drains the response body, and processes the HTTP status code Note: Closing the response.Body is left to the caller

func (*APIResponse) ProcessWithError

func (h *APIResponse) ProcessWithError(unmarshalInto interface{}, unmarshalErrorInto interface{}) error

ProcessWithError drains the response body, and processes the HTTP status code Note: Closing the response.Body is left to the caller

type APIVersionError

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

func NewAPIVersionError

func NewAPIVersionError(endpoint string, version *semver.Version, requiredVersion string) *APIVersionError

NewAPIVersionError create bindings error when the endpoint on the server is not supported because the version is to old.

  • endpoint is the name for the endpoint (e.g. /containers/json)
  • version is the server API version
  • requiredVersion is the server version need to use said endpoint

func (*APIVersionError) Error

func (e *APIVersionError) Error() string

type ConnectError

type ConnectError struct {
	Err error
}

func (ConnectError) Error

func (c ConnectError) Error() string

func (ConnectError) Unwrap

func (c ConnectError) Unwrap() error

type Connection

type Connection struct {
	URI    *url.URL
	Client *http.Client
}

func GetClient

func GetClient(ctx context.Context) (*Connection, error)

GetClient from context build by NewConnection()

func (*Connection) DoRequest

func (c *Connection) DoRequest(ctx context.Context, httpBody io.Reader, httpMethod, endpoint string, queryParams url.Values, headers http.Header, pathValues ...string) (*APIResponse, error)

DoRequest assembles the http request and returns the response. The caller must close the response body.

func (*Connection) GetDialer

func (c *Connection) GetDialer(ctx context.Context) (net.Conn, error)

GetDialer returns raw Transport.DialContext from client

Jump to

Keyboard shortcuts

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