cs

package
v0.0.0-...-766f525 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CRMDefaultEndpoint is the default API endpoint of CRM services
	CSDefaultEndpoint = "https://cs.aliyuncs.com"
	CSAPIVersion      = "2015-12-15"
)
View Source
const (
	Initial      = ClusterState("initial")
	Running      = ClusterState("running")
	Updating     = ClusterState("updating")
	Scaling      = ClusterState("scaling")
	Failed       = ClusterState("failed")
	Deleting     = ClusterState("deleting")
	DeleteFailed = ClusterState("deleteFailed")
	Deleted      = ClusterState("deleted")
	InActive     = ClusterState("inactive")
)
View Source
const (
	ClassicNetwork = NetworkModeType("classic")
	VPCNetwork     = NetworkModeType("vpc")
)
View Source
const ClusterDefaultTimeout = 300
View Source
const DefaultPreSleepTime = 240
View Source
const DefaultWaitForInterval = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	AccessKeyId     string
	AccessKeySecret string

	Version string
	// contains filtered or unexported fields
}

The Client type encapsulates operations with an OSS region.

func NewClient

func NewClient(accessKeyId, accessKeySecret string) *Client

NewClient creates a new instance of CRM client

func (*Client) CreateCluster

func (client *Client) CreateCluster(region common.Region, args *ClusterCreationArgs) (cluster ClusterCreationResponse, err error)

func (*Client) DeleteCluster

func (client *Client) DeleteCluster(clusterID string) error

func (*Client) DescribeCluster

func (client *Client) DescribeCluster(id string) (cluster ClusterType, err error)

func (*Client) DescribeClusters

func (client *Client) DescribeClusters(nameFilter string) (clusters []ClusterType, err error)

func (*Client) GetClusterCerts

func (client *Client) GetClusterCerts(id string) (certs ClusterCerts, err error)

func (*Client) GetProjectClient

func (client *Client) GetProjectClient(clusterId string) (projectClient *ProjectClient, err error)

func (*Client) Invoke

func (client *Client) Invoke(region common.Region, method string, path string, query url.Values, args interface{}, response interface{}) error

Invoke sends the raw HTTP request for ECS services

func (*Client) ResizeCluster

func (client *Client) ResizeCluster(clusterID string, args *ClusterResizeArgs) error

func (*Client) SetDebug

func (client *Client) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*Client) SetUserAgent

func (client *Client) SetUserAgent(userAgent string)

SetUserAgent sets user agent to log the request/response message

func (*Client) WaitForClusterAsyn

func (client *Client) WaitForClusterAsyn(clusterId string, status ClusterState, timeout int) error

WaitForCluster waits for instance to given status when instance.NotFound wait until timeout

type ClusterCerts

type ClusterCerts struct {
	CA   string `json:"ca,omitempty"`
	Key  string `json:"key,omitempty"`
	Cert string `json:"cert,omitempty"`
}

type ClusterCreationArgs

type ClusterCreationArgs struct {
	Name             string           `json:"name"`
	Size             int64            `json:"size"`
	NetworkMode      NetworkModeType  `json:"network_mode"`
	SubnetCIDR       string           `json:"subnet_cidr,omitempty"`
	InstanceType     string           `json:"instance_type"`
	VPCID            string           `json:"vpc_id,omitempty"`
	VSwitchID        string           `json:"vswitch_id,omitempty"`
	Password         string           `json:"password"`
	DataDiskSize     int64            `json:"data_disk_size"`
	DataDiskCategory ecs.DiskCategory `json:"data_disk_category"`
	ECSImageID       string           `json:"ecs_image_id,omitempty"`
	IOOptimized      ecs.IoOptimized  `json:"io_optimized"`
}

type ClusterCreationResponse

type ClusterCreationResponse struct {
	Response
	ClusterID string `json:"cluster_id"`
}

type ClusterResizeArgs

type ClusterResizeArgs struct {
	Size             int64            `json:"size"`
	InstanceType     string           `json:"instance_type"`
	Password         string           `json:"password"`
	DataDiskSize     int64            `json:"data_disk_size"`
	DataDiskCategory ecs.DiskCategory `json:"data_disk_category"`
	ECSImageID       string           `json:"ecs_image_id,omitempty"`
	IOOptimized      ecs.IoOptimized  `json:"io_optimized"`
}

type ClusterState

type ClusterState string

type ClusterType

type ClusterType struct {
	AgentVersion           string           `json:"agent_version"`
	ClusterID              string           `json:"cluster_id"`
	Name                   string           `json:"name"`
	Created                util.ISO6801Time `json:"created"`
	ExternalLoadbalancerID string           `json:"external_loadbalancer_id"`
	MasterURL              string           `json:"master_url"`
	NetworkMode            NetworkModeType  `json:"network_mode"`
	RegionID               common.Region    `json:"region_id"`
	SecurityGroupID        string           `json:"security_group_id"`
	Size                   int64            `json:"size"`
	State                  ClusterState     `json:"state"`
	Updated                util.ISO6801Time `json:"updated"`
	VPCID                  string           `json:"vpc_id"`
	VSwitchID              string           `json:"vswitch_id"`
	NodeStatus             string           `json:"node_status"`
	DockerVersion          string           `json:"docker_version"`
}

https://help.aliyun.com/document_detail/26053.html

type Container

type Container struct {
	Name      string            `json:"name"`
	Node      string            `json:"node"`
	VMID      string            `json:"vm_id"`
	IP        string            `json:"ip"`
	Running   bool              `json:"running"`
	Status    string            `json:"status"`
	Health    string            `json:"health"`
	StatusExt string            `json:"status_ext"`
	FailCount int               `json:"fail_count"`
	Ports     map[string][]Port `json:"ports"`
}

type Definition

type Definition struct {
	Environment        []string `json:"environment"`
	Image              string   `json:"image"`
	KernelMemory       int      `json:"kernel_memory"`
	Labels             Labels   `json:"labels"`
	MemLimit           int      `json:"mem_limit"`
	MemswapLimit       int      `json:"memswap_limit"`
	MemswapReservation int      `json:"memswap_reservation"`
	OomKillDisable     bool     `json:"oom_kill_disable"`
	Restart            string   `json:"restart"`
	ShmSize            int      `json:"shm_size"`
	Volumes            []string `json:"volumes"`
}

type DriverOptions

type DriverOptions interface {
	// contains filtered or unexported methods
}

type GetProjectResponse

type GetProjectResponse Project

type GetProjectsResponse

type GetProjectsResponse []Project

type GetServiceResponse

type GetServiceResponse Service

type GetServicesResponse

type GetServicesResponse []Service

type GetVolumeResponse

type GetVolumeResponse struct {
	Name       string            `json:"Name"`
	Driver     string            `json:"Driver"`
	Mountpoint string            `json:"Mountpoint"`
	Labels     map[string]string `json:"Labels"`
	Scope      string            `json:"Scope"`
	Node       string            `json:"Node"`
	Refs       []VolumeRef       `json:"Refs"`
}

type GetVolumesResponse

type GetVolumesResponse struct {
	Volumes []GetVolumeResponse `json:"Volumes"`
}

type Labels

type Labels map[string]string

type NASOpts

type NASOpts struct {
	DiskId string `json:"disk_id"`
	Host   string `json:"host"`
	Path   string `json:"path"`
	Mode   string `json:"mode"`
}

type NetworkModeType

type NetworkModeType string

type NodeStatus

type NodeStatus struct {
	Health   int64 `json:"health"`
	Unhealth int64 `json:"unhealth"`
}

type OSSOpts

type OSSOpts struct {
	Bucket          string `json:"bucket"`
	AccessKeyId     string `json:"ak_id"`
	AccessKeySecret string `json:"ak_secret"`
	URL             string `json:"url"`
	NoStatCache     string `json:"no_stat_cache"`
	OtherOpts       string `json:"other_opts"`
}

type Port

type Port struct {
	HostIP   string `json:"host_ip"`
	HostPort string `json:"host_port"`
}

type Project

type Project struct {
	Name         string            `json:"name"`
	Description  string            `json:"description"`
	Template     string            `json:"template"`
	Version      string            `json:"version"`
	Created      string            `json:"created"`
	Updated      string            `json:"updated"`
	DesiredState string            `json:"desired_state"`
	CurrentState string            `json:"current_state"`
	Environment  map[string]string `json:"environment"`
	Services     []Service         `json:"services"`
}

type ProjectClient

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

func NewProjectClient

func NewProjectClient(clusterId, endpoint string, clusterCerts ClusterCerts) (client *ProjectClient, err error)

func (*ProjectClient) ClusterId

func (client *ProjectClient) ClusterId() string

func (*ProjectClient) CreateProject

func (client *ProjectClient) CreateProject(args *ProjectCreationArgs) (err error)

func (*ProjectClient) CreateVolume

func (client *ProjectClient) CreateVolume(args *VolumeCreationArgs) (err error)

func (*ProjectClient) DeleteProject

func (client *ProjectClient) DeleteProject(name string, forceDelete, deleteVolume bool) (err error)

func (*ProjectClient) DeleteVolume

func (client *ProjectClient) DeleteVolume(name string) (err error)

func (*ProjectClient) Endpoint

func (client *ProjectClient) Endpoint() string

func (*ProjectClient) GetProject

func (client *ProjectClient) GetProject(name string) (project GetProjectResponse, err error)

func (*ProjectClient) GetProjects

func (client *ProjectClient) GetProjects(q string, services, containers bool) (projects GetProjectsResponse, err error)

func (*ProjectClient) GetService

func (client *ProjectClient) GetService(serviceId string) (service GetServiceResponse, err error)

func (*ProjectClient) GetServices

func (client *ProjectClient) GetServices(q string, containers bool) (services GetServicesResponse, err error)

func (*ProjectClient) GetVolume

func (client *ProjectClient) GetVolume(name string) (volume GetVolumeResponse, err error)

func (*ProjectClient) GetVolumes

func (client *ProjectClient) GetVolumes() (volumes GetVolumesResponse, err error)

func (*ProjectClient) Invoke

func (client *ProjectClient) Invoke(method string, path string, query url.Values, args interface{}, response interface{}) error

func (*ProjectClient) KillProject

func (client *ProjectClient) KillProject(name string, signal ...string) (err error)

func (*ProjectClient) KillService

func (client *ProjectClient) KillService(serviceId string, signal ...string) (err error)

func (*ProjectClient) ScaleService

func (client *ProjectClient) ScaleService(args *ScaleServiceArgs) (err error)

func (*ProjectClient) SetDebug

func (client *ProjectClient) SetDebug(debug bool)

SetDebug sets debug mode to log the request/response message

func (*ProjectClient) SetUserAgent

func (client *ProjectClient) SetUserAgent(userAgent string)

SetUserAgent sets user agent to log the request/response message

func (*ProjectClient) StartProject

func (client *ProjectClient) StartProject(name string) (err error)

func (*ProjectClient) StartService

func (client *ProjectClient) StartService(serviceId string) (err error)

func (*ProjectClient) StopProject

func (client *ProjectClient) StopProject(name string, timeout ...time.Duration) (err error)

func (*ProjectClient) StopService

func (client *ProjectClient) StopService(serviceId string, timeout ...time.Duration) (err error)

func (*ProjectClient) UpdateProject

func (client *ProjectClient) UpdateProject(args *ProjectUpdationArgs) (err error)

type ProjectCreationArgs

type ProjectCreationArgs struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Template    string            `json:"template"`
	Version     string            `json:"version"`
	Environment map[string]string `json:"environment"`
	LatestImage bool              `json:"latest_image"`
}

type ProjectUpdationArgs

type ProjectUpdationArgs struct {
	Name        string            `json:"-"`
	Description string            `json:"description"`
	Template    string            `json:"template"`
	Version     string            `json:"version"`
	Environment map[string]string `json:"environment"`
	LatestImage bool              `json:"latest_image"`
}

type Request

type Request struct {
	Method          string
	URL             string
	Version         string
	Region          common.Region
	Signature       string
	SignatureMethod string
	SignatureNonce  string
	Timestamp       util.ISO6801Time
	Body            []byte
}

type Response

type Response struct {
	RequestId string `json:"request_id"`
}

type ScaleServiceArgs

type ScaleServiceArgs struct {
	ServiceId string    `json:"-"`
	Type      ScaleType `json:"type"`
	Value     int       `json:"value"`
}

type ScaleType

type ScaleType string
const (
	ScaleTo ScaleType = "scale_to"
)

type Service

type Service struct {
	ID             string                 `json:"id"`
	Name           string                 `json:"name"`
	Project        string                 `json:"project"`
	ComposeVersion string                 `json:"compose_version"`
	Containers     map[string]Container   `json:"containers"`
	Created        time.Time              `json:"created"`
	CurrentState   string                 `json:"current_state"`
	Definition     Definition             `json:"definition"`
	DesiredState   string                 `json:"desired_state"`
	Extensions     map[string]interface{} `json:"extensions"`
	Hash           string                 `json:"hash"`
	Updated        time.Time              `json:"updated"`
	Version        string                 `json:"version"`
}

type VolumeCreationArgs

type VolumeCreationArgs struct {
	Name       string           `json:"name"`
	Driver     VolumeDriverType `json:"driver"`
	DriverOpts DriverOptions    `json:"driverOpts"`
}

type VolumeCreationResponse

type VolumeCreationResponse struct {
	Name       string            `json:"Name"`
	Driver     string            `json:"Driver"`
	Mountpoint string            `json:"Mountpoint"`
	Labels     map[string]string `json:"Labels"`
	Scope      string            `json:"Scope"`
}

type VolumeDriverType

type VolumeDriverType string
const (
	OSSFSDriver VolumeDriverType = "ossfs"
	NASDriver   VolumeDriverType = "nas"
)

type VolumeRef

type VolumeRef struct {
	Name string `json:"Name"`
	ID   string `json:"ID"`
}

Jump to

Keyboard shortcuts

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