Documentation
¶
Index ¶
- Constants
- type APIMetadata
- type APIVersion
- type CarinaClient
- func (c *CarinaClient) Create(clusterOpts *CreateClusterOpts) (*Cluster, error)
- func (c *CarinaClient) Delete(token string) (*Cluster, error)
- func (c *CarinaClient) Get(token string) (*Cluster, error)
- func (c *CarinaClient) GetCredentials(token string) (*CredentialsBundle, error)
- func (c *CarinaClient) List() ([]*Cluster, error)
- func (c *CarinaClient) ListClusterTypes() ([]*ClusterType, error)
- func (c *CarinaClient) NewRequest(method string, uri string, body io.Reader) (*http.Response, error)
- func (c *CarinaClient) Resize(token string, nodes int) (*Cluster, error)
- type CarinaError
- type CarinaGenericErrorResponse
- type CarinaUnacceptableError
- type CarinaUnacceptableErrorResonse
- type Cluster
- type ClusterType
- type CreateClusterOpts
- type CredentialsBundle
- func (creds *CredentialsBundle) GetCA() []byte
- func (creds *CredentialsBundle) GetCert() []byte
- func (creds *CredentialsBundle) GetKey() []byte
- func (creds *CredentialsBundle) GetTLSConfig() (*tls.Config, error)
- func (creds *CredentialsBundle) ParseHost() (string, error)
- func (creds *CredentialsBundle) Verify() error
- type HTTPErr
Constants ¶
const CarinaEndpointType = "rax:container"
CarinaEndpointType is the endpoint type in the service catalog
const LibVersion = "2.0.0"
LibVersion is the version of this library, and should be keep synchronized with the git tag
const SupportedAPIVersion = "1.0"
SupportedAPIVersion is the version of the API against which this library was developed
const UserAgentPrefix = "libcarina/" + LibVersion
UserAgentPrefix is the default user agent string, consumers should append their application version to `CarinaClient.UserAgent`.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIMetadata ¶
type APIMetadata struct {
// Versions is a list of supported API versions
Versions []*APIVersion
}
APIMetadata contains information about the API
type APIVersion ¶
type APIVersion struct {
ID string `json:"id"`
Status string `json:"current"`
Minimum string `json:"min_version"`
Maximum string `json:"max_version"`
}
APIVersion defines a version of the API
type CarinaClient ¶
type CarinaClient struct {
Client *http.Client
Username string
Token string
Endpoint string
UserAgent string
}
CarinaClient accesses Carina directly
func NewClient ¶
func NewClient(username string, apikey string, region string, authEndpointOverride string, cachedToken string, cachedEndpoint string) (*CarinaClient, error)
NewClient create an authenticated CarinaClient
func (*CarinaClient) Create ¶
func (c *CarinaClient) Create(clusterOpts *CreateClusterOpts) (*Cluster, error)
Create a new cluster with cluster options
func (*CarinaClient) Delete ¶
func (c *CarinaClient) Delete(token string) (*Cluster, error)
Delete nukes a cluster out of existence
func (*CarinaClient) Get ¶
func (c *CarinaClient) Get(token string) (*Cluster, error)
Get a cluster by cluster by its name or id
func (*CarinaClient) GetCredentials ¶
func (c *CarinaClient) GetCredentials(token string) (*CredentialsBundle, error)
GetCredentials returns a Credentials struct for the given cluster name
func (*CarinaClient) List ¶
func (c *CarinaClient) List() ([]*Cluster, error)
List the current clusters
func (*CarinaClient) ListClusterTypes ¶
func (c *CarinaClient) ListClusterTypes() ([]*ClusterType, error)
ListClusterTypes returns a list of cluster types
func (*CarinaClient) NewRequest ¶
func (c *CarinaClient) NewRequest(method string, uri string, body io.Reader) (*http.Response, error)
NewRequest handles a request using auth used by Carina
type CarinaError ¶
type CarinaError struct {
Code string `json:"code"`
Detail string `json:"detail"`
RequestID string `json:"request_id"`
Status int `json:"status"`
Title string `json:"title"`
}
CarinaError represents an error message from the Carina API
type CarinaGenericErrorResponse ¶
type CarinaGenericErrorResponse struct {
Errors []CarinaError `json:"errors"`
}
CarinaGenericErrorResponse represents the response returned by Carina when a request fails
type CarinaUnacceptableError ¶
type CarinaUnacceptableError struct {
CarinaError
MaxVersion string `json:"max_version"`
MinVersion string `json:"min_version"`
}
CarinaUnacceptableError represents a 406 response from the Carina API
type CarinaUnacceptableErrorResonse ¶
type CarinaUnacceptableErrorResonse struct {
Errors []CarinaUnacceptableError `json:"errors"`
}
CarinaUnacceptableErrorResonse represents the response returned by Carina when the StatusCode is 406
type Cluster ¶
type Cluster struct {
// ID of the cluster
ID string `json:"id"`
// Name of the cluster
Name string `json:"name"`
// Type of cluster
Type *ClusterType `json:"cluster_type"`
// Nodes in the cluster
Nodes int `json:"node_count,omitempty"`
// Status of the cluster
Status string `json:"status,omitempty"`
}
Cluster is a cluster of Docker nodes
type ClusterType ¶
type ClusterType struct {
// ID of the cluster type
ID int `json:"id"`
// Name of the cluster type
Name string `json:"name"`
// Specifies if the cluster type is available to be used for new clusters
IsActive bool `json:"active"`
// COE (container orchestration engine) used by the cluster
COE string `json:"coe"`
// Underlying type of the host nodes, such as lxc or vm
HostType string `json:"host_type"`
}
ClusterType defines a type of cluster Essentially the template used to create a new cluster
type CreateClusterOpts ¶
type CreateClusterOpts struct {
// Name of the cluster
Name string `json:"name"`
// Type of cluster
ClusterTypeID int `json:"cluster_type_id"`
// Nodes in the cluster
Nodes int `json:"node_count,omitempty"`
}
CreateClusterOpts defines the set of parameters when creating a cluster
type CredentialsBundle ¶
CredentialsBundle is a set of certificates and environment information necessary to connect to a cluster
func LoadCredentialsBundle ¶
func LoadCredentialsBundle(credentialsPath string) *CredentialsBundle
LoadCredentialsBundle loads a credentials bundle from the filesystem
func NewCredentialsBundle ¶
func NewCredentialsBundle() *CredentialsBundle
NewCredentialsBundle initializes an empty credentials bundle
func (*CredentialsBundle) GetCA ¶
func (creds *CredentialsBundle) GetCA() []byte
GetCA returns the contents of ca.pem
func (*CredentialsBundle) GetCert ¶
func (creds *CredentialsBundle) GetCert() []byte
GetCert returns the contents of cert.pem
func (*CredentialsBundle) GetKey ¶
func (creds *CredentialsBundle) GetKey() []byte
GetKey returns the contents of key.pem
func (*CredentialsBundle) GetTLSConfig ¶
func (creds *CredentialsBundle) GetTLSConfig() (*tls.Config, error)
GetTLSConfig puts together the necessary TLS configuration to connect to the COE Endpoint returned by ParseHost
func (*CredentialsBundle) ParseHost ¶
func (creds *CredentialsBundle) ParseHost() (string, error)
ParseHost finds the COE Endpoint, e.g. the swarm or kubernetes ip and port
func (*CredentialsBundle) Verify ¶
func (creds *CredentialsBundle) Verify() error
Verify validates that we can connect to the Docker host specified in the credentials bundle

