common

package
v0.0.0-...-1806480 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APICreateVersion is the API for version creation.
	APICreateVersion = "create-version"
	// LogServerOrigin is the host of log server.
	LogServerOrigin = "http://localhost/"
	// LogServerURL is the URL of log server.
	LogServerURL = "ws://localhost:8000/ws"
	// StartOperation is the operation name for starting.
	StartOperation = "start"
	// StopOperation is the operation name for stoping.
	StopOperation = "stop"
	// TimeOutPushLog is the timeout for log pusing.
	TimeOutPushLog = 5
	// TimeOutResponse is the timeout for response.
	TimeOutResponse = 10
	// ReadMsgBufferSize is the default size of buffer for reading messages.
	ReadMsgBufferSize = 32768
)
View Source
const (

	// AdminUser is used to run normal test cases, it has all access rights
	// to docker repositories.
	AdminUser = "admin"
	// AdminUID is the UID of AdminUser.
	AdminUID = "adminUID"
	// AdminPassword is the password of AdminUser.
	AdminPassword = "admin_password"

	// ListUser is used solely for listing services.
	ListUser = "list"
	// ListUID is the UID of ListUser.
	ListUID = "listUID"
	// ListPassword is the password of ListUser.
	ListPassword = "list_password"

	// AliceUser is a normal user, we use it to test different cases, e.g. build
	// from user1 should fail to push to user2.
	AliceUser = "alice"
	// AliceUID is the UID of AliceUser.
	AliceUID = "aliceUID"
	// AlicePassword is the password of AliceUser.
	AlicePassword = "alice_password"

	// BobUser is a normal user, we use it to test different cases, e.g. build
	// from user1 should fail to push to user2.
	BobUser = "bobo"
	// BobUID is the UID of BobUser.
	BobUID = "boboUID"
	// BobPassword is the password of BobUser.
	BobPassword = "bobo_password"

	// DefaultRegistryAddress is the default docker registry, it would start a local registry.
	DefaultRegistryAddress = "cargo.caicloud.io"
	// DefaultDockerHost is the default docker host used in e2e test.
	DefaultDockerHost = "unix:///var/run/docker.sock"

	// DefaultAuthAddress is the default address to access caicloud auth. Right now, we've disabled
	// caicloud auth in e2e test.
	DefaultAuthAddress = "https://auth-canary.caicloud.io"
)

Variables

View Source
var (
	// BaseURL defines the url to cyclone.
	BaseURL = fmt.Sprintf("http://localhost:%s/api/%s", cyclonePort, apiVersion)
)
View Source
var (
	// ErrUnfoundLog is the error type for "log not found."
	ErrUnfoundLog = fmt.Errorf("log not found")
)

Functions

func CallUpdateImageAPI

func CallUpdateImageAPI(userID, applicationName, clusterName, partitionName, containerName, imageName string) error

CallUpdateImageAPI invokes update image API.

func CreateProject

func CreateProject(userID string, project *api.Project, response *api.ProjectCreationResponse) error

CreateProject creates a project with given configurations.

func CreateProjectVersion

func CreateProjectVersion(userID string, projectVersion *api.ProjectVersion,
	response *api.ProjectVersionCreationResponse) error

CreateProjectVersion creates a project version with given configurations.

func CreateService

func CreateService(userID string, service *api.Service, response *api.ServiceCreationResponse) error

CreateService creates a service with given configurations.

func CreateVersion

func CreateVersion(userID string, version *api.Version, response *api.VersionCreationResponse) error

CreateVersion creates a version and streams response from server to stdout.

func DeleteProject

func DeleteProject(userID, projectID string, response *api.ProjectDelResponse) error

DeleteProject delete a project from user ID and project ID.

func DeleteService

func DeleteService(userID, serviceID string, response *api.ServiceDelResponse) error

DeleteService deletes a service from service ID and user ID.

func DialLogServer

func DialLogServer() (ws *gwebsocket.Conn, err error)

DialLogServer dials LogServerURL for connection.

func GetProject

func GetProject(userID, projectID string, response *api.ProjectGetResponse) error

GetProject retrieves a project from user ID and project ID.

func GetProjectVersion

func GetProjectVersion(userID, projectVersionID string, response *api.ProjectVersionGetResponse) error

GetProjectVersion retrieves a project version from user ID and project version ID.

func GetService

func GetService(userID, serviceID string, response *api.ServiceGetResponse) error

GetService retrieves a service from user ID and service ID.

func GetToken

func GetToken(username string, request TokenRequest, response *TokenResponse) error

GetToken returns the token from ${DefaultAuthAddress}/api/v0.1/users/{username}/authenticate

func GetVersion

func GetVersion(userID, versionID string, response *api.VersionGetResponse) error

GetVersion retrieves a version from user ID and service ID.

func GetVersionLogs

func GetVersionLogs(userID, versionID string) (int, error)

GetVersionLogs gets a version's log.

func IsAvailable

func IsAvailable() bool

IsAvailable returns whether the cyclone is running.

func ListProjectVersions

func ListProjectVersions(userID, projectID string, response *api.ProjectVersionListResponse) error

ListProjectVersions list project versions by user ID.

func ListProjects

func ListProjects(userID string, response *api.ProjectListResponse) error

ListProjects list projects by user ID.

func ListServices

func ListServices(userID string, response *api.ServiceListResponse) error

ListServices lists all services of a user.

func ListVersions

func ListVersions(userID, serviceID string, response *api.VersionListResponse) error

ListVersions lists all versions of a user.

func PushImageToLocalRegistry

func PushImageToLocalRegistry(dm *docker.Manager, image string) error

PushImageToLocalRegistry pushes the image to local registry.

func ReadMsgFromLogServer

func ReadMsgFromLogServer(ws *gwebsocket.Conn, timeout int) ([]byte, error)

ReadMsgFromLogServer reads messages from log server.

func RegisterResource

func RegisterResource() error

RegisterResource register resources to mongo.

func SendMsgToLogServer

func SendMsgToLogServer(ws *gwebsocket.Conn, msg []byte) error

SendMsgToLogServer sends messages to log server directly.

func SetProject

func SetProject(userID string, projectID string, project *api.Project, response *api.ProjectSetResponse) error

SetProject set a project with given configurations.

func SetupTokenUID

func SetupTokenUID(username, password string) (string, string)

SetupTokenUID will get the token and uid from auth server. This won't be called if authserver is disabled.

func StopWatchLog

func StopWatchLog(ws *gwebsocket.Conn, apiName string, userID string,
	serviceID string, versionID string)

StopWatchLog stop watching log.

func WaitComponents

func WaitComponents()

WaitComponents waits cyclone instance to be up.

func WatchLog

func WatchLog(ws *gwebsocket.Conn, apiName string, userID string,
	serviceID string, versionID string) (err error)

WatchLog begins to watch the log.

Types

type Profile

type Profile struct {
	Email     string `json:"email,omitempty"`
	Cellphone int    `json:"cellphone,omitempty"`
}

Profile is the profile object of a user.

type TokenRequest

type TokenRequest struct {
	Password string `json:"password,omitempty"`
}

TokenRequest is the request to get the token.

type TokenResponse

type TokenResponse struct {
	StatusMessage string  `json:"statusMessage,omitempty"`
	Token         string  `json:"token,omitempty"`
	UID           string  `json:"uid,omitempty"`
	Error         string  `json:"error,omitempty"`
	Profile       Profile `json:"profile,omitempty"`
}

TokenResponse is the response to get the token.

Jump to

Keyboard shortcuts

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