common

package
v0.0.0-...-964918b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ApiCreateVersion  = "create-version"
	LogServerOrigin   = "http://localhost/"
	LogServerUrl      = "ws://localhost:8000/ws"
	StartOperation    = "start"
	StopOperation     = "stop"
	TimeOutPushLog    = 5
	TimeOutResponse   = 10
	ReadMsgBufferSize = 32768
)
View Source
const (
	// Defines the usernames and pwds in docker registry server.
	// - AdminUser is used to run normal test cases, it has all access rights
	//   to docker repositories.
	// - ListUser is used solely for listing services.
	// - Others are normal users, we use them to test different cases, e.g. build
	//   from user1 should fail to push to user2.
	AdminUser     = "admin"
	AdminUID      = "adminUID"
	AdminPassword = "admin_password"

	ListUser     = "list"
	ListUID      = "listUID"
	ListPassword = "list_password"

	AliceUser     = "alice"
	AliceUID      = "aliceUID"
	AlicePassword = "alice_password"

	BobUser     = "bob"
	BobUID      = "bobUID"
	BobPassword = "bob_password"

	// Default registry address and docker host in e2e test.
	DefaultRegistryAddress = "localhost:5000"
	DefaultDockerHost      = "unix:///var/run/docker.sock"

	// Define the 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 = fmt.Errorf("unfound log")
)

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)

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)

func RegisterResource

func RegisterResource() error

RegisterResource register resources to mongo.

func SendMsgToLogServer

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

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)

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)

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