bindings

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package bindings provides golang-based access to the Podman REST API. Users can then interact with API endpoints to manage containers, images, pods, etc.

This package exposes a series of methods that allow users to firstly create their connection with the API endpoints. Once the connection is established, users can then manage the Podman container runtime.

Index

Constants

This section is empty.

Variables

View Source
var (
	PTrue = &pTrue

	PFalse = &pFalse

	// APIVersion - podman will fail to run if this value is wrong
	APIVersion = semver.MustParse("1.0.0")
)
View Source
var (
	BasePath = &url.URL{
		Scheme: "http",
		Host:   "d",
		Path:   "/v" + APIVersion.String() + "/libpod",
	}
)
View Source
var (
	ErrNotImplemented = errors.New("function not implemented")
)

Functions

func CheckResponseCode

func CheckResponseCode(inError error) (int, error)

func FiltersToString

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

FiltersToString converts our typical filter format of a map[string][]string to a query/html safe string.

func JoinURL

func JoinURL(elements ...string) string

JoinURL elements with '/'

func NewConnection

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

func NewConnectionWithIdentity

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

NewConnection 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?secure=True

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) IsInformational

func (h *APIResponse) IsInformational() bool

IsInformation 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 (a APIResponse) Process(unmarshalInto interface{}) 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(httpBody io.Reader, httpMethod, endpoint string, queryParams url.Values, header map[string]string, pathValues ...string) (*APIResponse, error)

DoRequest assembles the http request and returns the response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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