v2action

package
v6.26.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package v2action contains the business logic for the commands/v2 package

Index

Constants

View Source
const StagingLog = "STG"

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	CloudControllerClient CloudControllerClient
	UAAClient             UAAClient
}

Actor handles all business logic for Cloud Controller v2 operations.

func NewActor

func NewActor(ccClient CloudControllerClient, uaaClient UAAClient) Actor

NewActor returns a new actor.

func (Actor) BindSecurityGroupToSpace

func (actor Actor) BindSecurityGroupToSpace(securityGroupGUID string, spaceGUID string) (Warnings, error)

func (Actor) ClearOrganizationAndSpace

func (actor Actor) ClearOrganizationAndSpace(config Config)

ClearTarget clears the targeted org and space in the config.

func (Actor) ClearTarget

func (actor Actor) ClearTarget(config Config)

ClearTarget clears target information from the actor.

func (Actor) CloudControllerAPIVersion

func (actor Actor) CloudControllerAPIVersion() string

CloudControllerAPIVersion returns the Cloud Controller API version.

func (Actor) DeleteOrganization

func (actor Actor) DeleteOrganization(orgName string) (Warnings, error)

DeleteOrganization deletes the Organization associated with the provided GUID. Once the deletion request is sent, it polls the deletion job until it's finished.

func (Actor) DeleteRoute

func (actor Actor) DeleteRoute(routeGUID string) (Warnings, error)

DeleteRoute deletes the Route associated with the provided Route GUID.

func (Actor) GetApplication

func (actor Actor) GetApplication(guid string) (Application, Warnings, error)

GetApplication returns the application

func (Actor) GetApplicationByNameAndSpace

func (actor Actor) GetApplicationByNameAndSpace(name string, spaceGUID string) (Application, Warnings, error)

GetApplicationByNameAndSpace returns an application with matching name in the space.

func (Actor) GetApplicationInstancesByApplication

func (actor Actor) GetApplicationInstancesByApplication(guid string) (map[int]ApplicationInstance, Warnings, error)

func (Actor) GetApplicationInstancesWithStatsByApplication

func (actor Actor) GetApplicationInstancesWithStatsByApplication(guid string) ([]ApplicationInstanceWithStats, Warnings, error)

func (Actor) GetApplicationRoutes

func (actor Actor) GetApplicationRoutes(applicationGUID string, query []ccv2.Query) ([]Route, Warnings, error)

GetApplicationRoutes returns a list of routes associated with the provided Application GUID

func (Actor) GetApplicationSummaryByNameAndSpace

func (actor Actor) GetApplicationSummaryByNameAndSpace(name string, spaceGUID string) (ApplicationSummary, Warnings, error)

func (Actor) GetApplicationsBySpace

func (actor Actor) GetApplicationsBySpace(spaceGUID string) ([]Application, Warnings, error)

GetApplicationsBySpace returns all applications in a space.

func (Actor) GetDomain

func (actor Actor) GetDomain(domainGUID string) (Domain, Warnings, error)

GetDomain returns the shared or private domain associated with the provided Domain GUID.

func (Actor) GetOrganization

func (actor Actor) GetOrganization(guid string) (Organization, Warnings, error)

GetOrganization returns an Organization based on the provided guid.

func (Actor) GetOrganizationByName

func (actor Actor) GetOrganizationByName(orgName string) (Organization, Warnings, error)

GetOrganizationByName returns an Organization based off of the name given.

func (Actor) GetOrganizationDomains

func (actor Actor) GetOrganizationDomains(orgGUID string) ([]Domain, Warnings, error)

GetOrganizationDomains returns the shared and private domains associated with an organization.

func (Actor) GetOrganizationQuota

func (actor Actor) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error)

func (Actor) GetOrganizationSpaces

func (actor Actor) GetOrganizationSpaces(orgGUID string) ([]Space, Warnings, error)

GetOrganizationSpaces returns a list of spaces in the specified org

func (Actor) GetOrganizationSummaryByName

func (actor Actor) GetOrganizationSummaryByName(orgName string) (OrganizationSummary, Warnings, error)

func (Actor) GetOrphanedRoutesBySpace

func (actor Actor) GetOrphanedRoutesBySpace(spaceGUID string) ([]Route, Warnings, error)

GetOrphanedRoutesBySpace returns a list of orphaned routes associated with the provided Space GUID.

func (Actor) GetPrivateDomain

func (actor Actor) GetPrivateDomain(domainGUID string) (Domain, Warnings, error)

GetPrivateDomain returns the private domain associated with the provided Domain GUID.

func (Actor) GetRecentLogsForApplicationByNameAndSpace

func (actor Actor) GetRecentLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client NOAAClient, config Config) ([]LogMessage, Warnings, error)

func (Actor) GetRouteApplications

func (actor Actor) GetRouteApplications(routeGUID string, query []ccv2.Query) ([]Application, Warnings, error)

GetRouteApplications returns a list of apps associated with the provided Route GUID.

func (Actor) GetSecurityGroupByName

func (actor Actor) GetSecurityGroupByName(securityGroupName string) (SecurityGroup, Warnings, error)

func (Actor) GetServiceBindingByApplicationAndServiceInstance

func (actor Actor) GetServiceBindingByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (ServiceBinding, Warnings, error)

GetServiceBindingByApplicationAndServiceInstance returns a service binding given an application GUID and and service instance GUID.

func (Actor) GetServiceInstanceByNameAndSpace

func (actor Actor) GetServiceInstanceByNameAndSpace(name string, spaceGUID string) (ServiceInstance, Warnings, error)

func (Actor) GetServiceInstancesBySpace

func (actor Actor) GetServiceInstancesBySpace(spaceGUID string) ([]ServiceInstance, Warnings, error)

func (Actor) GetSharedDomain

func (actor Actor) GetSharedDomain(domainGUID string) (Domain, Warnings, error)

GetSharedDomain returns the shared domain associated with the provided Domain GUID.

func (Actor) GetSpaceByOrganizationAndName

func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error)

GetSpaceByOrganizationAndName returns an Space based on the org and name.

func (Actor) GetSpaceQuota

func (actor Actor) GetSpaceQuota(guid string) (SpaceQuota, Warnings, error)

func (Actor) GetSpaceRoutes

func (actor Actor) GetSpaceRoutes(spaceGUID string, query []ccv2.Query) ([]Route, Warnings, error)

GetSpaceRoutes returns a list of routes associated with the provided Space GUID

func (Actor) GetSpaceRunningSecurityGroupsBySpace

func (actor Actor) GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error)

GetDomain returns the shared or private domain associated with the provided Domain GUID.

func (Actor) GetSpaceStagingSecurityGroupsBySpace

func (actor Actor) GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error)

func (Actor) GetSpaceSummaryByOrganizationAndName

func (actor Actor) GetSpaceSummaryByOrganizationAndName(orgGUID string, name string, includeStagingSecurityGroupsRules bool) (SpaceSummary, Warnings, error)

func (Actor) GetStack

func (actor Actor) GetStack(guid string) (Stack, Warnings, error)

GetStack returns the stack information associated with the provided stack GUID.

func (Actor) GetStreamingLogs

func (actor Actor) GetStreamingLogs(appGUID string, client NOAAClient, config Config) (<-chan *LogMessage, <-chan error)

func (Actor) GetStreamingLogsForApplicationByNameAndSpace

func (actor Actor) GetStreamingLogsForApplicationByNameAndSpace(appName string, spaceGUID string, client NOAAClient, config Config) (<-chan *LogMessage, <-chan error, Warnings, error)

func (Actor) NewUser

func (actor Actor) NewUser(username string, password string, origin string) (User, Warnings, error)

NewUser creates a new user in UAA and registers it with cloud controller.

func (Actor) SetApplicationHealthCheckTypeByNameAndSpace

func (actor Actor) SetApplicationHealthCheckTypeByNameAndSpace(name string, spaceGUID string, healthCheckType string, httpEndpoint string) (Application, Warnings, error)

SetApplicationHealthCheckTypeByNameAndSpace updates an application's health check type if it is not already the desired type.

func (Actor) SetTarget

func (actor Actor) SetTarget(config Config, settings TargetSettings) (Warnings, error)

SetTarget targets the Cloud Controller using the client and sets target information in the actor based on the response.

func (Actor) StartApplication

func (actor Actor) StartApplication(app Application, client NOAAClient, config Config) (<-chan *LogMessage, <-chan error, <-chan bool, <-chan string, <-chan error)

StartApplication starts a given application.

func (Actor) UnbindServiceBySpace

func (actor Actor) UnbindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string) (Warnings, error)

UnbindServiceBySpace deletes the service binding between an application and service instance for a given space.

type Application

type Application ccv2.Application

Application represents an application.

func (Application) CalculatedBuildpack

func (application Application) CalculatedBuildpack() string

CalculatedBuildpack returns the buildpack that will be used.

func (Application) CalculatedHealthCheckEndpoint

func (application Application) CalculatedHealthCheckEndpoint() string

CalculatedHealthCheckEndpoint returns the health check endpoint. If the health check type is not http it will return the empty string.

func (Application) StagingCompleted

func (application Application) StagingCompleted() bool

StagingCompleted returns true if the application has been staged.

func (Application) StagingFailed

func (application Application) StagingFailed() bool

StagingFailed returns true if staging the application failed.

func (Application) StagingFailedMessage

func (application Application) StagingFailedMessage() string

StagingFailedMessage returns the verbose description of the failure or the reason if the verbose description is empty.

func (Application) StagingFailedNoAppDetected

func (application Application) StagingFailedNoAppDetected() bool

StagingFailedNoAppDetected returns true when the staging failed due to a NoAppDetectedError.

func (Application) Started

func (application Application) Started() bool

Started returns true when the application is started.

type ApplicationInstance

type ApplicationInstance ccv2.ApplicationInstance

func (ApplicationInstance) Crashed

func (instance ApplicationInstance) Crashed() bool

func (ApplicationInstance) Flapping

func (instance ApplicationInstance) Flapping() bool

func (ApplicationInstance) Running

func (instance ApplicationInstance) Running() bool

type ApplicationInstanceCrashedError

type ApplicationInstanceCrashedError struct {
	Name string
}

ApplicationInstanceCrashedError is returned when an instance crashes.

func (ApplicationInstanceCrashedError) Error

type ApplicationInstanceFlappingError

type ApplicationInstanceFlappingError struct {
	Name string
}

ApplicationInstanceFlappingError is returned when an instance crashes.

func (ApplicationInstanceFlappingError) Error

type ApplicationInstanceState

type ApplicationInstanceState ccv2.ApplicationInstanceState

type ApplicationInstanceWithStats

type ApplicationInstanceWithStats struct {
	// CPU is the instance's CPU utilization percentage.
	CPU float64

	// Details are arbitrary information about the instance.
	Details string

	// Disk is the instance's disk usage in bytes.
	Disk int

	// DiskQuota is the instance's allowed disk usage in bytes.
	DiskQuota int

	// ID is the instance ID.
	ID int

	// IsolationSegment that the app instance is currently running on.
	IsolationSegment string

	// Memory is the instance's memory usage in bytes.
	Memory int

	// MemoryQuota is the instance's allowed memory usage in bytes.
	MemoryQuota int

	// Since is the Unix time stamp that represents the time the instance was
	// created.
	Since float64

	// State is the instance's state.
	State ApplicationInstanceState
}

func (ApplicationInstanceWithStats) TimeSinceCreation

func (instance ApplicationInstanceWithStats) TimeSinceCreation() time.Time

type ApplicationInstancesNotFoundError

type ApplicationInstancesNotFoundError struct {
	ApplicationGUID string
}

ApplicationInstancesNotFoundError is returned when the application does not have running instances.

func (ApplicationInstancesNotFoundError) Error

type ApplicationNotFoundError

type ApplicationNotFoundError struct {
	GUID string
	Name string
}

ApplicationNotFoundError is returned when a requested application is not found.

func (ApplicationNotFoundError) Error

func (e ApplicationNotFoundError) Error() string

type ApplicationSummary

type ApplicationSummary struct {
	Application
	Stack            Stack
	IsolationSegment string
	RunningInstances []ApplicationInstanceWithStats
	Routes           []Route
}

func (ApplicationSummary) StartingOrRunningInstanceCount

func (app ApplicationSummary) StartingOrRunningInstanceCount() int

type CloudControllerClient

type CloudControllerClient interface {
	AssociateSpaceWithSecurityGroup(securityGroupGUID string, spaceGUID string) (ccv2.Warnings, error)
	DeleteOrganization(orgGUID string) (ccv2.Job, ccv2.Warnings, error)
	DeleteRoute(routeGUID string) (ccv2.Warnings, error)
	DeleteServiceBinding(serviceBindingGUID string) (ccv2.Warnings, error)
	GetApplicationInstanceStatusesByApplication(guid string) (map[int]ccv2.ApplicationInstanceStatus, ccv2.Warnings, error)
	GetApplicationInstancesByApplication(guid string) (map[int]ccv2.ApplicationInstance, ccv2.Warnings, error)
	GetApplicationRoutes(appGUID string, queries []ccv2.Query) ([]ccv2.Route, ccv2.Warnings, error)
	GetApplication(guid string) (ccv2.Application, ccv2.Warnings, error)
	GetApplications(queries []ccv2.Query) ([]ccv2.Application, ccv2.Warnings, error)
	GetJob(jobGUID string) (ccv2.Job, ccv2.Warnings, error)
	GetOrganization(guid string) (ccv2.Organization, ccv2.Warnings, error)
	GetOrganizations(queries []ccv2.Query) ([]ccv2.Organization, ccv2.Warnings, error)
	GetOrganizationPrivateDomains(orgGUID string, queries []ccv2.Query) ([]ccv2.Domain, ccv2.Warnings, error)
	GetOrganizationQuota(guid string) (ccv2.OrganizationQuota, ccv2.Warnings, error)
	GetPrivateDomain(domainGUID string) (ccv2.Domain, ccv2.Warnings, error)
	GetRouteApplications(routeGUID string, queries []ccv2.Query) ([]ccv2.Application, ccv2.Warnings, error)
	GetSecurityGroups(queries []ccv2.Query) ([]ccv2.SecurityGroup, ccv2.Warnings, error)
	GetServiceBindings(queries []ccv2.Query) ([]ccv2.ServiceBinding, ccv2.Warnings, error)
	GetServiceInstances(queries []ccv2.Query) ([]ccv2.ServiceInstance, ccv2.Warnings, error)
	GetSharedDomain(domainGUID string) (ccv2.Domain, ccv2.Warnings, error)
	GetSharedDomains() ([]ccv2.Domain, ccv2.Warnings, error)
	GetSpaceQuota(guid string) (ccv2.SpaceQuota, ccv2.Warnings, error)
	GetSpaceRoutes(spaceGUID string, queries []ccv2.Query) ([]ccv2.Route, ccv2.Warnings, error)
	GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]ccv2.SecurityGroup, ccv2.Warnings, error)
	GetSpaces(queries []ccv2.Query) ([]ccv2.Space, ccv2.Warnings, error)
	GetSpaceServiceInstances(spaceGUID string, includeUserProvidedServices bool, queries []ccv2.Query) ([]ccv2.ServiceInstance, ccv2.Warnings, error)
	GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]ccv2.SecurityGroup, ccv2.Warnings, error)
	GetStack(guid string) (ccv2.Stack, ccv2.Warnings, error)
	CreateUser(uaaUserID string) (ccv2.User, ccv2.Warnings, error)
	PollJob(job ccv2.Job) (ccv2.Warnings, error)
	TargetCF(settings ccv2.TargetSettings) (ccv2.Warnings, error)
	UpdateApplication(app ccv2.Application) (ccv2.Application, ccv2.Warnings, error)

	API() string
	APIVersion() string
	AuthorizationEndpoint() string
	DopplerEndpoint() string
	MinCLIVersion() string
	RoutingEndpoint() string
	TokenEndpoint() string
}

CloudControllerClient is a Cloud Controller V2 client.

type Config

type Config interface {
	PollingInterval() time.Duration
	SetTargetInformation(api string, apiVersion string, auth string, minCLIVersion string, doppler string, uaa string, routing string, skipSSLValidation bool)
	SetTokenInformation(accessToken string, refreshToken string, sshOAuthClient string)
	SkipSSLValidation() bool
	StagingTimeout() time.Duration
	StartupTimeout() time.Duration
	Target() string
	UnsetOrganizationInformation()
	UnsetSpaceInformation()
}

type Domain

type Domain ccv2.Domain

Domain represents a CLI Domain.

type DomainNotFoundError

type DomainNotFoundError struct{}

DomainNotFoundError is an error wrapper that represents the case when the domain is not found.

func (DomainNotFoundError) Error

func (e DomainNotFoundError) Error() string

Error method to display the error message.

type HTTPHealthCheckInvalidError

type HTTPHealthCheckInvalidError struct {
}

HTTPHealthCheckInvalidError is returned when an HTTP endpoint is used with a health check type that is not HTTP.

func (HTTPHealthCheckInvalidError) Error

type LogMessage

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

func NewLogMessage

func NewLogMessage(message string, messageType int, timestamp time.Time, sourceType string, sourceInstance string) *LogMessage

func (LogMessage) Message

func (log LogMessage) Message() string

func (LogMessage) SourceInstance

func (log LogMessage) SourceInstance() string

func (LogMessage) SourceType

func (log LogMessage) SourceType() string

func (LogMessage) Staging

func (log LogMessage) Staging() bool

func (LogMessage) Timestamp

func (log LogMessage) Timestamp() time.Time

func (LogMessage) Type

func (log LogMessage) Type() string

type MultipleOrganizationsFoundError

type MultipleOrganizationsFoundError struct {
	Name  string
	GUIDs []string
}

MultipleOrganizationsFoundError represents the scenario when the cloud controller returns multiple organizations when filtering by name. This is a far out edge case and should not happen.

func (MultipleOrganizationsFoundError) Error

type MultipleSpacesFoundError

type MultipleSpacesFoundError struct {
	Name    string
	OrgGUID string
}

MultipleSpacesFoundError represents the scenario when the cloud controller returns multiple spaces when filtering by name. This is a far out edge case and should not happen.

func (MultipleSpacesFoundError) Error

func (e MultipleSpacesFoundError) Error() string

type NOAAClient

type NOAAClient interface {
	Close() error
	RecentLogs(appGuid string, authToken string) ([]*events.LogMessage, error)
	TailingLogs(appGuid, authToken string) (<-chan *events.LogMessage, <-chan error)
}

NOAAClient is a client for getting logs.

type NOAATimeoutError

type NOAATimeoutError struct{}

func (NOAATimeoutError) Error

func (e NOAATimeoutError) Error() string

type Organization

type Organization ccv2.Organization

Organization represents a CLI Organization.

type OrganizationNotFoundError

type OrganizationNotFoundError struct {
	GUID string
	Name string
}

OrganizationNotFoundError represents the scenario when the organization searched for could not be found.

func (OrganizationNotFoundError) Error

type OrganizationQuota

type OrganizationQuota ccv2.OrganizationQuota

type OrganizationQuotaNotFoundError

type OrganizationQuotaNotFoundError struct {
	GUID string
}

func (OrganizationQuotaNotFoundError) Error

type OrganizationSummary

type OrganizationSummary struct {
	Name        string
	GUID        string
	QuotaName   string
	DomainNames []string
	SpaceNames  []string
}

type OrphanedRoutesNotFoundError

type OrphanedRoutesNotFoundError struct{}

OrphanedRoutesNotFoundError is an error wrapper that represents the case when no orphaned routes are found.

func (OrphanedRoutesNotFoundError) Error

Error method to display the error message.

type Route

type Route struct {
	GUID   string
	Host   string
	Domain string
	Path   string
	Port   int
}

Route represents a CLI Route.

func (Route) String

func (r Route) String() string

String formats the route in a human readable format.

type SecurityGroup

type SecurityGroup ccv2.SecurityGroup

Domain represents a CLI Domain.

type SecurityGroupNotFoundError

type SecurityGroupNotFoundError struct {
	Name string
}

SecurityGroupNotFoundError is returned when a requested security group is not found.

func (SecurityGroupNotFoundError) Error

type SecurityGroupRule

type SecurityGroupRule struct {
	Name        string
	Description string
	Destination string
	Lifecycle   string
	Ports       string
	Protocol    string
}

type ServiceBinding

type ServiceBinding ccv2.ServiceBinding

ServiceBinding represents the link between a service instance and an application.

type ServiceBindingNotFoundError

type ServiceBindingNotFoundError struct {
	AppGUID             string
	ServiceInstanceGUID string
}

ServiceBindingNotFoundError is returned when a service binding cannot be found.

func (ServiceBindingNotFoundError) Error

type ServiceInstance

type ServiceInstance ccv2.ServiceInstance

ServiceInstance represents an instance of a service.

type ServiceInstanceNotFoundError

type ServiceInstanceNotFoundError struct {
	Name string
}

func (ServiceInstanceNotFoundError) Error

type Space

type Space ccv2.Space

Space represents a CLI Space

type SpaceNotFoundError

type SpaceNotFoundError struct {
	GUID string
	Name string
}

SpaceFoundError represents the scenario when the space searched for could not be found.

func (SpaceNotFoundError) Error

func (e SpaceNotFoundError) Error() string

type SpaceQuota

type SpaceQuota ccv2.SpaceQuota

type SpaceQuotaNotFoundError

type SpaceQuotaNotFoundError struct {
	GUID string
}

func (SpaceQuotaNotFoundError) Error

func (e SpaceQuotaNotFoundError) Error() string

type SpaceSummary

type SpaceSummary struct {
	SpaceName                      string
	SpaceGUID                      string
	OrgName                        string
	OrgDefaultIsolationSegmentGUID string
	AppNames                       []string
	ServiceInstanceNames           []string
	SpaceQuotaName                 string
	SecurityGroupNames             []string
	SecurityGroupRules             []SecurityGroupRule
}

type Stack

type Stack ccv2.Stack

type StackNotFoundError

type StackNotFoundError struct {
	GUID string
}

StackNotFoundError is returned when a requested stack is not found.

func (StackNotFoundError) Error

func (e StackNotFoundError) Error() string

type StagingFailedError

type StagingFailedError struct {
	Reason string
}

StagingFailedError is returned when staging an application fails.

func (StagingFailedError) Error

func (e StagingFailedError) Error() string

type StagingFailedNoAppDetectedError

type StagingFailedNoAppDetectedError struct {
	Reason string
}

StagingFailedNoAppDetectedError is returned when staging an application fails.

func (StagingFailedNoAppDetectedError) Error

type StagingTimeoutError

type StagingTimeoutError struct {
	Name    string
	Timeout time.Duration
}

StagingTimeoutError is returned when staging timeout is reached waiting for an application to stage.

func (StagingTimeoutError) Error

func (e StagingTimeoutError) Error() string

type StartupTimeoutError

type StartupTimeoutError struct {
	Name string
}

StartupTimeoutError is returned when startup timeout is reached waiting for an application to start.

func (StartupTimeoutError) Error

func (e StartupTimeoutError) Error() string

type TargetSettings

type TargetSettings ccv2.TargetSettings

type UAAClient

type UAAClient interface {
	NewUser(username string, password string, origin string) (uaa.User, error)
}

type User

type User ccv2.User

User represents a CLI user.

type Warnings

type Warnings []string

Warnings is a list of warnings returned back from the cloud controller

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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