client

package
v0.0.0-...-4d7c681 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2016 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPTimeout is the default HTTP timeout.
	DefaultHTTPTimeout = time.Second * 10
	// DefaultHTTPProtocol is the default HTTP Protocol (http, https).
	DefaultHTTPProtocol = "http"
)
View Source
const InstallYAML = `` /* 3208-byte string literal not displayed */

InstallYAML is the installation YAML for DM.

Variables

This section is empty.

Functions

func DefaultServerURL

func DefaultServerURL(host string) (*url.URL, error)

DefaultServerURL converts a host, host:port, or URL string to the default base server API path to use with a Client

func IsInstalled

func IsInstalled(runner kubectl.Runner) bool

IsInstalled checks whether DM has been installed.

func NewDebugTransport

func NewDebugTransport(rt http.RoundTripper) http.RoundTripper

NewDebugTransport returns a debugging implementation of a RoundTripper.

func Uninstall

func Uninstall(runner kubectl.Runner) (string, error)

Uninstall uses kubectl to uninstall the base DM.

Returns the string output received from the operation, and an error if the command failed.

Types

type Client

type Client struct {
	// Timeout on HTTP connections.
	HTTPTimeout time.Duration
	// Transport
	Transport http.RoundTripper
	// Debug enables http logging
	Debug bool
	// contains filtered or unexported fields
}

Client is a DM client.

func NewClient

func NewClient(host string) *Client

NewClient creates a new DM client. Host name is required.

func (*Client) Delete

func (c *Client) Delete(endpoint string, v interface{}) (*Response, error)

Delete calls DELETE on an endpoint and decodes the response

func (*Client) DeleteDeployment

func (c *Client) DeleteDeployment(name string) (*common.Deployment, error)

DeleteDeployment deletes the supplied deployment

func (*Client) DescribeDeployment

func (c *Client) DescribeDeployment(name string) (*common.Manifest, error)

DescribeDeployment describes the kubernetes resources of the supplied deployment by fetching the latest manifest.

func (*Client) Do

func (c *Client) Do(req *Request) *Response

Do send a request and returns a response

func (*Client) Exec

func (c *Client) Exec(req *Request, v interface{}) (*Response, error)

Exec sends a request and decodes the response

func (*Client) Get

func (c *Client) Get(endpoint string, v interface{}) (*Response, error)

Get calls GET on an endpoint and decodes the response

func (*Client) GetDeployment

func (c *Client) GetDeployment(name string) (*common.Deployment, error)

GetDeployment retrieves the supplied deployment

func (*Client) ListDeployments

func (c *Client) ListDeployments() ([]string, error)

ListDeployments lists the deployments in DM.

func (*Client) NewRequest

func (c *Client) NewRequest(method, endpoint string, payload interface{}) *Request

NewRequest creates a new client request

func (*Client) Post

func (c *Client) Post(endpoint string, payload, v interface{}) (*Response, error)

Post calls POST on an endpoint and decodes the response

func (*Client) PostChart

func (c *Client) PostChart(filename, deployname string) (string, error)

PostChart sends a chart to DM for deploying.

This returns the location for the new chart, typically of the form `helm:repo/bucket/name-version.tgz`.

func (*Client) PostDeployment

func (c *Client) PostDeployment(res *common.Resource) error

PostDeployment posts a deployment object to the manager service.

func (*Client) Result

func (c *Client) Result(resp *Response, v interface{}) (*Response, error)

Result checks status code and decodes a response body

func (*Client) SetDebug

func (c *Client) SetDebug(enable bool) *Client

SetDebug enables debug mode which logs http

func (*Client) SetTimeout

func (c *Client) SetTimeout(seconds int) *Client

SetTimeout sets a timeout for http connections

func (*Client) SetTransport

func (c *Client) SetTransport(tr http.RoundTripper) *Client

SetTransport sets a custom Transport. Defaults to http.DefaultTransport

type HTTPError

type HTTPError struct {
	StatusCode int
	Message    string
	URL        *url.URL
}

HTTPError is an error caused by an unexpected HTTP status code.

The StatusCode will not necessarily be a 4xx or 5xx. Any unexpected code may be returned.

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error implements the error interface.

func (*HTTPError) String

func (e *HTTPError) String() string

String implmenets the io.Stringer interface.

type Installer

type Installer struct {

	// Expandybird params are used to render the expandybird manifest.
	Expandybird map[string]interface{}
	// Resourcifier params are used to render the resourcifier manifest.
	Resourcifier map[string]interface{}
	// Manager params are used to render the manager manifest.
	Manager map[string]interface{}
}

Installer is capable of installing DM into Kubernetes.

See InstallYAML.

func NewInstaller

func NewInstaller() *Installer

NewInstaller creates a new Installer.

func (*Installer) Install

func (i *Installer) Install(runner kubectl.Runner) (string, error)

Install uses kubectl to install the base DM.

Returns the string output received from the operation, and an error if the command failed.

type Request

type Request struct {
	*http.Request
	// contains filtered or unexported fields
}

Request wraps http.Request to include error

type Response

type Response struct {
	*http.Response
	// contains filtered or unexported fields
}

Response wraps http.Response to include error

func (*Response) HTTPError

func (r *Response) HTTPError() error

HTTPError creates a new HTTPError from response

func (*Response) Success

func (r *Response) Success() bool

Success returns true if the status code is 2xx

Jump to

Keyboard shortcuts

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