cpapi

package
v0.0.0-...-0f323ce Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorFailedToGetEnvironmentsList = "failed to get the environments list"
View Source
const RemoteEnvironmentRunning = "Running"

RemoteEnvironmentRunning is the status for a running remove environment

View Source
const RemoteEnvironmentTideFailed = "TideFailed"

RemoteEnvironmentTideFailed is the status for a tide that failed

View Source
const RemoteEnvironmentTideNotStarted = "NotStarted"

RemoteEnvironmentTideNotStarted is the status for at tide that has not been started yet

View Source
const RemoteEnvironmentTideRunning = "TideRunning"

RemoteEnvironmentTideRunning is the status for a tide that is running

View Source
const TideRunning = "running"

TideRunning is the status of a running tide

Variables

This section is empty.

Functions

func GetAuthenticatorURL

func GetAuthenticatorURL() (*url.URL, error)

func GetRiverURL

func GetRiverURL() (*url.URL, error)

func PrintPublicEndpoints

func PrintPublicEndpoints(writer io.Writer, endpoints []APIPublicEndpoint)

PrintPublicEndpoints given a list of public api endpoints it prints them on the given writer

Types

type APICluster

type APICluster struct {
	Identifier string `json:"identifier"`
	Address    string `json:"address"`
	Version    string `json:"version"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	Type       string `json:"type"`
}

APICluster holds the data expected from the cp api for this entity

type APICodeReference

type APICodeReference struct {
	Branch         string      `json:"branch"`
	CodeRepository interface{} `json:"code_repository"`
	Sha1           string      `json:"sha1"`
}

APICodeReference holds the data expected from the cp api for this entity

type APIComponent

type APIComponent struct {
	DeploymentStrategy interface{}   `json:"deployment_strategy"`
	Endpoints          []interface{} `json:"endpoints"`
	Extensions         []interface{} `json:"extensions"`
	Identifier         string        `json:"identifier"`
	Labels             interface{}   `json:"labels"`
	Name               string        `json:"name"`
	Specification      interface{}   `json:"specification"`
	Status             interface{}   `json:"status"`
}

APIComponent holds the data expected from the cp api for this entity

type APIEnvironment

type APIEnvironment struct {
	Cluster    string         `json:"cluster"`
	Components []APIComponent `json:"components"`
	Identifier string         `json:"identifier"`
}

APIEnvironment holds the data expected from the cp api for this entity

type APIFlow

type APIFlow struct {
	UUID          string        `json:"uuid"`
	Configuration interface{}   `json:"configuration"`
	Pipelines     interface{}   `json:"pipelines"`
	Repository    APIRepository `json:"repository"`
	Team          APITeam       `json:"team"`
	Tides         []APITide     `json:"tides"`
	User          APIUser       `json:"user"`
}

APIFlow holds the data expected from the cp api for this entity

type APIMembership

type APIMembership struct {
	Team        APITeam  `json:"team"`
	User        APIUser  `json:"user"`
	Permissions []string `json:"permissions"`
}

APIMembership holds the data expected from the cp api for this entity

type APIPublicEndpoint

type APIPublicEndpoint struct {
	Address string                  `json:"address"`
	Name    string                  `json:"name"`
	Ports   []APIPublicEndpointPort `json:"ports"`
}

APIPublicEndpoint holds the data expected from the cp api for this entity

type APIPublicEndpointPort

type APIPublicEndpointPort struct {
	Number   int    `json:"number"`
	Protocol string `json:"protocol"`
}

APIPublicEndpointPort holds the data expected from the cp api for this entity

type APIRemoteEnvironmentStatus

type APIRemoteEnvironmentStatus struct {
	Status              string              `json:"status"`
	KubeEnvironmentName string              `json:"environment_name"`
	ClusterIdentifier   string              `json:"cluster_identifier"`
	PublicEndpoints     []APIPublicEndpoint `json:"public_endpoints"`
	LastTide            APITide             `json:"last_tide"`
}

APIRemoteEnvironmentStatus holds the data expected from the cp api for this entity

type APIRepository

type APIRepository struct {
	Address      string `json:"address"`
	Identifier   string `json:"identifier"`
	Name         string `json:"name"`
	Organisation string `json:"organisation"`
	Private      bool   `json:"private"`
	Type         string `json:"type"`
}

APIRepository holds the data expected from the cp api for this entity

type APITeam

type APITeam struct {
	Slug       string `json:"slug"`
	Name       string `json:"name"`
	BucketUUID string `json:"bucket_uuid"`

	//Should be []APIMembership although there is a bug on the api where a list of object with keys "1", "2" is returned
	//instead of being a json array
	Memberships []interface{} `json:"memberships"`
}

APITeam holds the data expected from the cp api for this entity

type APITide

type APITide struct {
	CodeReference  APICodeReference `json:"code_reference"`
	Configuration  interface{}      `json:"configuration"`
	CreationDate   string           `json:"creation_date"`
	FinishDate     string           `json:"finish_date"`
	FlowUUID       string           `json:"flow_uuid"`
	GenerationUUID string           `json:"generation_uuid"`
	LogID          string           `json:"log_id"`
	StartDate      string           `json:"start_date"`
	Status         string           `json:"status"`
	Tasks          []interface{}    `json:"tasks"`
	Team           APITideTeam      `json:"team"`
	User           interface{}      `json:"user"`
	UUID           string           `json:"uuid"`
}

APITide holds the data expected from the cp api for this entity

type APITideTeam

type APITideTeam struct {
	Slug       string `json:"slug"`
	Name       string `json:"name"`
	BucketUUID string `json:"bucket_uuid"`
}

APITideTeam holds the data expected from the cp api for this entity

type APIUser

type APIUser struct {
	Username   string   `json:"username"`
	Email      string   `json:"email"`
	BucketUUID string   `json:"bucket_uuid"`
	Roles      []string `json:"roles"`
}

APIUser holds the data expected from the cp api for this entity

type CpAPI

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

CpAPI holds the dependencies required to do the api calls

func NewCpAPI

func NewCpAPI() *CpAPI

NewCpAPI ctor for the CpAPI

func (CpAPI) CancelRunningTide

func (c CpAPI) CancelRunningTide(flowID string, remoteEnvironmentID string) error

CancelRunningTide find the tide id associated with the branch and cancel the tide

func (CpAPI) CancelTide

func (c CpAPI) CancelTide(tideID string) error

CancelTide send a request to the cp api to cancel the tide specified

func (CpAPI) GetAPIEnvironments

func (c CpAPI) GetAPIEnvironments(flowID string) ([]APIEnvironment, error)

GetAPIEnvironments sends a request to the cp api to fetch the cp environments list for the user

func (CpAPI) GetAPIFlows

func (c CpAPI) GetAPIFlows(project string) ([]APIFlow, error)

GetAPIFlows sends a request to the cp api to fetch the list of flows

func (CpAPI) GetAPITeams

func (c CpAPI) GetAPITeams() ([]APITeam, error)

GetAPITeams sends a request to the cp api to fetch the list of teams for the user

func (CpAPI) GetAPIUser

func (c CpAPI) GetAPIUser(user string) (*APIUser, error)

GetAPIUser sends a request to the cp api to fetch the cp user information

func (CpAPI) GetRemoteEnvironmentStatus

func (c CpAPI) GetRemoteEnvironmentStatus(flowID string, environmentID string) (*APIRemoteEnvironmentStatus, error)

GetRemoteEnvironmentStatus sends a request to the cp api to retrieve information about the remote environment

func (CpAPI) RemoteDevelopmentEnvironmentDestroy

func (c CpAPI) RemoteDevelopmentEnvironmentDestroy(flowID string, remoteEnvironmentID string) error

RemoteDevelopmentEnvironmentDestroy send a request to the cp api to destroy the environment

func (CpAPI) RemoteEnvironmentBuild

func (c CpAPI) RemoteEnvironmentBuild(remoteEnvironmentFlowID string, gitBranch string) error

RemoteEnvironmentBuild sends a request to the cp api to request to build a new remote environment

func (CpAPI) RemoteEnvironmentDestroy

func (c CpAPI) RemoteEnvironmentDestroy(flowID string, environment string, cluster string) error

RemoteEnvironmentDestroy sends a request to the cp api to request to destroy the remote environment

func (CpAPI) RemoteEnvironmentRunningAndExists

func (c CpAPI) RemoteEnvironmentRunningAndExists(flowID string, environmentID string) (bool, error)

RemoteEnvironmentRunningAndExists get the remote environment status and the list of all environments to ensure that the environment actually exists

func (*CpAPI) SetAPIKey

func (c *CpAPI) SetAPIKey(apiKey string)

SetAPIKey sets the cp api key

type DataProvider

type DataProvider interface {
	SetAPIKey(apiKey string)
	GetAPITeams() ([]APITeam, error)
	GetAPIFlows(project string) ([]APIFlow, error)
	GetAPIUser(user string) (*APIUser, error)
	GetAPIEnvironments(flowID string) ([]APIEnvironment, error)
	GetRemoteEnvironmentStatus(flowID string, environmentID string) (*APIRemoteEnvironmentStatus, error)
	RemoteEnvironmentBuild(remoteEnvironmentFlowID string, gitBranch string) error
	CancelRunningTide(flowID string, remoteEnvironmentID string) error
	RemoteEnvironmentRunningAndExists(flowID string, environmentID string) (bool, error)
	RemoteEnvironmentDestroy(flowID string, environment string, cluster string) error
	RemoteDevelopmentEnvironmentDestroy(flowID string, remoteEnvironmentID string) error
	CancelTide(tideID string) error
}

DataProvider collects all cp api methods

type MultipleChoiceCpEntityAnswer

type MultipleChoiceCpEntityAnswer struct {
	Project     MultipleChoiceCpEntityOption
	Flow        MultipleChoiceCpEntityOption
	Environment MultipleChoiceCpEntityOption
	Pod         MultipleChoiceCpEntityOption
}

MultipleChoiceCpEntityAnswer for each entity holds the option selected by the user

type MultipleChoiceCpEntityOption

type MultipleChoiceCpEntityOption struct {
	Value  string
	Name   string
	Object interface{}
}

MultipleChoiceCpEntityOption holds an option that will be presented to the user

type MultipleChoiceCpEntityQuestioner

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

MultipleChoiceCpEntityQuestioner presents the user with a list of option for cp entities (project, flows, environments, pods) to choose from and requests to select a single one

func NewMultipleChoiceCpEntityQuestioner

func NewMultipleChoiceCpEntityQuestioner() *MultipleChoiceCpEntityQuestioner

NewMultipleChoiceCpEntityQuestioner returns a *MultipleChoiceCpEntityQuestioner struct

func (*MultipleChoiceCpEntityQuestioner) SetAPIKey

func (q *MultipleChoiceCpEntityQuestioner) SetAPIKey(apiKey string)

SetAPIKey sets the cp api key

func (*MultipleChoiceCpEntityQuestioner) WhichEntities

func (q *MultipleChoiceCpEntityQuestioner) WhichEntities() (project APITeam, flow APIFlow, environment APIEnvironment, pod APIComponent, suggestion string, err error)

WhichEntities triggers an api request to the cp api based on the arguments and presents to the user a list of options to choose from, it then stores the user response

Jump to

Keyboard shortcuts

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