common

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 13 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 Cleanup

func Cleanup() error

Cleanup database

func CreateProject

func CreateProject(project *api.Project, response *api.Project, errResp *api.ErrorResponse) (int, error)

CreateProject creates a project with given configurations.

func DeleteProject

func DeleteProject(name string, response *api.Project, errResp *api.ErrorResponse) (int, error)

DeleteProject delete a project from user ID and project ID.

func DialLogServer

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

DialLogServer dials LogServerURL for connection.

func GetProject

func GetProject(name string, response *api.Project, errResp *api.ErrorResponse) (int, error)

GetProject retrieves a project from user ID and project 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 IsRunning

func IsRunning() bool

IsRunning returns whether the cyclone is running.

func ListProjects

func ListProjects(response *ListResponse, errResp *api.ErrorResponse) (int, error)

// ListProjects list projects by user ID.

func ReadMsgFromLogServer

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

ReadMsgFromLogServer reads messages from log server.

func SendMsgToLogServer

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

SendMsgToLogServer sends messages to log server directly.

func SetProject

func SetProject(project *api.Project, response *api.Project, errResp *api.ErrorResponse) (int, 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 WaitComponents

func WaitComponents()

WaitComponents waits cyclone instance to be up.

Types

type ListResponse added in v0.7.1

type ListResponse struct {
	Metadata Metadata      `bson:"metadata,omitempty" json:"metadata,omitempty"`
	Items    []api.Project `bson:"items,omitempty" json:"items,omitempty"`
}

type Metadata added in v0.7.1

type Metadata struct {
	Total int `bson:"total,omitempty" json:"total,omitempty"`
}

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