pushaction

package
v6.45.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package pushaction contains the business logic for orchestrating a V2 app push.

Index

Constants

View Source
const ProtocolRegexp = "^https?://|^tcp://"
View Source
const PushRetries = 3
View Source
const URLRegexp = "^(?:https?://|tcp://)?(?:(?:[\\w-]+\\.)|(?:[*]\\.))+\\w+(?:\\:\\d+)?(?:/.*)*(?:\\.\\w+)?$"

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor struct {
	SharedActor   SharedActor
	V2Actor       V2Actor
	V3Actor       V3Actor
	WordGenerator RandomWordGenerator
	// contains filtered or unexported fields
}

Actor handles all business logic for Cloud Controller v2 operations.

func NewActor

func NewActor(v2Actor V2Actor, v3Actor V3Actor, sharedActor SharedActor) *Actor

NewActor returns a new actor.

func (Actor) Actualize

func (actor Actor) Actualize(state PushPlan, progressBar ProgressBar) (
	<-chan PushPlan, <-chan Event, <-chan Warnings, <-chan error,
)

func (Actor) Apply

func (actor Actor) Apply(config ApplicationConfig, progressBar ProgressBar) (<-chan ApplicationConfig, <-chan Event, <-chan Warnings, <-chan error)

Apply use the V2 API to create/update the application settings and eventually uploads the application bits.

If multiple buildpacks are being applied to the application, the V3 API is used to set those buildpacks.

func (Actor) BindServices

func (actor Actor) BindServices(config ApplicationConfig) (ApplicationConfig, bool, Warnings, error)

func (Actor) CalculateRoutes

func (actor Actor) CalculateRoutes(routes []string, orgGUID string, spaceGUID string, existingRoutes []v2action.Route) ([]v2action.Route, Warnings, error)

func (Actor) CloudControllerV2APIVersion

func (actor Actor) CloudControllerV2APIVersion() string

CloudControllerV2APIVersion returns the Cloud Controller V2 API version.

func (Actor) CloudControllerV3APIVersion

func (actor Actor) CloudControllerV3APIVersion() string

CloudControllerV3APIVersion returns the Cloud Controller V3 API version.

func (Actor) Conceptualize

func (actor Actor) Conceptualize(settings CommandLineSettings, spaceGUID string) ([]PushPlan, Warnings, error)

func (Actor) ConvertSharedResourcesToV2Resources

func (actor Actor) ConvertSharedResourcesToV2Resources(resources []sharedaction.Resource) []v2action.Resource

func (Actor) ConvertToApplicationConfigs

func (actor Actor) ConvertToApplicationConfigs(orgGUID string, spaceGUID string, noStart bool, apps []manifest.Application) ([]ApplicationConfig, Warnings, error)

ConvertToApplicationConfigs converts a set of application manifests into an application configs. These configs reflect the current and desired states of the application - providing details required by the Apply function to proceed.

The V2 Actor is primarily used to determine all but multiple buildpack information. Only then is the V3 Actor used to gather the multiple buildpacks.

func (Actor) ConvertV2ResourcesToSharedResources

func (actor Actor) ConvertV2ResourcesToSharedResources(resources []v2action.Resource) []sharedaction.Resource

func (Actor) CreateAndMapDefaultApplicationRoute

func (actor Actor) CreateAndMapDefaultApplicationRoute(orgGUID string, spaceGUID string, app v2action.Application) (Warnings, error)

func (Actor) CreateApplication

func (actor Actor) CreateApplication(config ApplicationConfig) (ApplicationConfig, Event, Warnings, error)

func (Actor) CreateArchive

func (actor Actor) CreateArchive(config ApplicationConfig) (string, error)

func (Actor) CreateRoutes

func (actor Actor) CreateRoutes(config ApplicationConfig) (ApplicationConfig, bool, Warnings, error)

func (Actor) DefaultDomain

func (actor Actor) DefaultDomain(orgGUID string) (v2action.Domain, Warnings, error)

DefaultDomain looks up the shared and then private domains and returns back the first one in the list as the default.

func (Actor) FindOrReturnPartialApp

func (actor Actor) FindOrReturnPartialApp(appName string, spaceGUID string) (bool, Application, v2action.Warnings, error)

func (Actor) GenerateRandomRoute

func (actor Actor) GenerateRandomRoute(manifestApp manifest.Application, spaceGUID string, orgGUID string) (v2action.Route, Warnings, error)

GenerateRandomRoute generates a random route with a specified or default domain If the domain is HTTP, a random hostname is generated If the domain is TCP, an empty port is used (to signify a random port should be generated)

func (Actor) GetGeneratedRoute

func (actor Actor) GetGeneratedRoute(manifestApp manifest.Application, orgGUID string, spaceGUID string, knownRoutes []v2action.Route) (v2action.Route, Warnings, error)

GetGeneratedRoute returns a route with the host and the default org domain. This may be a partial route (ie no GUID) if the route does not exist.

func (Actor) MapRoutes

func (actor Actor) MapRoutes(config ApplicationConfig) (ApplicationConfig, bool, Warnings, error)

func (Actor) MergeAndValidateSettingsAndManifests

func (actor Actor) MergeAndValidateSettingsAndManifests(cmdLineSettings CommandLineSettings, apps []manifest.Application) ([]manifest.Application, error)

MergeAndValidateSettingsAndManifests merges command line settings and manifest settings. It does this by: - Validating command line setting and their effect on the provided manifests - Override manifest settings with command line settings (when applicable) - Sanitizing the inputs - Validate merged manifest

func (*Actor) ReadManifest

func (actor *Actor) ReadManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]manifest.Application, Warnings, error)

func (Actor) SetMatchedResources

func (actor Actor) SetMatchedResources(config ApplicationConfig) (ApplicationConfig, Warnings)

func (Actor) UnmapRoutes

func (actor Actor) UnmapRoutes(config ApplicationConfig) (ApplicationConfig, Warnings, error)

func (Actor) UpdateApplication

func (actor Actor) UpdateApplication(config ApplicationConfig) (ApplicationConfig, Event, Warnings, error)

func (Actor) UploadDroplet

func (actor Actor) UploadDroplet(config ApplicationConfig, dropletPath string, progressbar ProgressBar, eventStream chan<- Event) (Warnings, error)

func (Actor) UploadPackage

func (actor Actor) UploadPackage(config ApplicationConfig) (Warnings, error)

func (Actor) UploadPackageWithArchive

func (actor Actor) UploadPackageWithArchive(config ApplicationConfig, archivePath string, progressbar ProgressBar, eventStream chan<- Event) (Warnings, error)

type Application

type Application struct {
	v2action.Application
	Buildpacks []string
	Stack      v2action.Stack
}

func (Application) CalculatedBuildpacks

func (app Application) CalculatedBuildpacks() []string

CalculatedBuildpacks will return back the buildpacks for the application.

func (*Application) SetStack

func (app *Application) SetStack(stack v2action.Stack)

func (Application) String

func (app Application) String() string

type ApplicationConfig

type ApplicationConfig struct {
	CurrentApplication Application
	DesiredApplication Application

	CurrentRoutes []v2action.Route
	DesiredRoutes []v2action.Route
	NoRoute       bool

	CurrentServices map[string]v2action.ServiceInstance
	DesiredServices map[string]v2action.ServiceInstance

	AllResources       []v2action.Resource
	MatchedResources   []v2action.Resource
	UnmatchedResources []v2action.Resource
	Archive            bool
	Path               string
	DropletPath        string
}

func (ApplicationConfig) CreatingApplication

func (config ApplicationConfig) CreatingApplication() bool

func (ApplicationConfig) HasMultipleBuildpacks

func (config ApplicationConfig) HasMultipleBuildpacks() bool

func (ApplicationConfig) UpdatingApplication

func (config ApplicationConfig) UpdatingApplication() bool

type CommandLineSettings

type CommandLineSettings struct {
	Buildpacks           []string
	Command              types.FilteredString
	CurrentDirectory     string
	DefaultRouteDomain   string
	DefaultRouteHostname string
	DiskQuota            uint64
	DockerImage          string
	DockerPassword       string
	DockerUsername       string
	DropletPath          string
	HealthCheckTimeout   uint64
	HealthCheckType      string
	Instances            types.NullInt
	Memory               uint64
	Name                 string
	NoHostname           bool
	NoRoute              bool
	ProvidedAppPath      string
	RandomRoute          bool
	RoutePath            string
	StackName            string
}

func (CommandLineSettings) OverrideManifestSettings

func (settings CommandLineSettings) OverrideManifestSettings(app manifest.Application) manifest.Application

func (CommandLineSettings) String

func (settings CommandLineSettings) String() string

type Event

type Event string
const (
	BoundRoutes                     Event = "bound routes"
	BoundServices                   Event = "bound services"
	ConfiguringServices             Event = "configuring services"
	CreatedApplication              Event = "created application"
	CreatedRoutes                   Event = "created routes"
	CreatingAndMappingRoutes        Event = "creating and mapping routes"
	CreatingArchive                 Event = "creating archive"
	CreatingPackage                 Event = "creating package"
	PollingBuild                    Event = "polling build"
	ReadingArchive                  Event = "reading archive"
	ResourceMatching                Event = "resource matching"
	RetryUpload                     Event = "retry upload"
	SettingDroplet                  Event = "setting droplet"
	SetDropletComplete              Event = "set droplet complete"
	SettingUpApplication            Event = "setting up application"
	SkippingApplicationCreation     Event = "skipping creation"
	StagingComplete                 Event = "staging complete"
	StartingStaging                 Event = "starting staging"
	UnmappingRoutes                 Event = "unmapping routes"
	UpdatedApplication              Event = "updated application"
	UploadDropletComplete           Event = "upload droplet complete"
	UploadingApplication            Event = "uploading application"
	UploadingApplicationWithArchive Event = "uploading application with archive"
	UploadingDroplet                Event = "uploading droplet"
	UploadWithArchiveComplete       Event = "upload complete"
	Complete                        Event = "complete"
)

type ProgressBar

type ProgressBar interface {
	NewProgressBarWrapper(reader io.Reader, sizeOfFile int64) io.Reader
}

type PushPlan

type PushPlan struct {
	Application        v3action.Application
	SpaceGUID          string
	BitsPath           string
	AllResources       []sharedaction.Resource
	MatchedResources   []sharedaction.Resource
	UnmatchedResources []sharedaction.Resource
	Archive            bool
}

type RandomWordGenerator

type RandomWordGenerator interface {
	RandomAdjective() string
	RandomNoun() string
}

RandomWordGenerator returns random words.

type SharedActor

type SharedActor interface {
	GatherArchiveResources(archivePath string) ([]sharedaction.Resource, error)
	GatherDirectoryResources(sourceDir string) ([]sharedaction.Resource, error)
	ReadArchive(archivePath string) (io.ReadCloser, int64, error)
	ZipArchiveResources(sourceArchivePath string, filesToInclude []sharedaction.Resource) (string, error)
	ZipDirectoryResources(sourceDir string, filesToInclude []sharedaction.Resource) (string, error)
}

type V2Actor

type V2Actor interface {
	MapRouteToApplication(routeGUID string, appGUID string) (v2action.Warnings, error)
	BindServiceByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (v2action.Warnings, error)
	CloudControllerAPIVersion() string
	CreateApplication(application v2action.Application) (v2action.Application, v2action.Warnings, error)
	CreateRoute(route v2action.Route, generatePort bool) (v2action.Route, v2action.Warnings, error)
	FindRouteBoundToSpaceWithSettings(route v2action.Route) (v2action.Route, v2action.Warnings, error)
	GetApplicationByNameAndSpace(name string, spaceGUID string) (v2action.Application, v2action.Warnings, error)
	GetApplicationRoutes(applicationGUID string) (v2action.Routes, v2action.Warnings, error)
	GetDomainsByNameAndOrganization(domainNames []string, orgGUID string) ([]v2action.Domain, v2action.Warnings, error)
	GetOrganizationDomains(orgGUID string) ([]v2action.Domain, v2action.Warnings, error)
	GetServiceInstanceByNameAndSpace(name string, spaceGUID string) (v2action.ServiceInstance, v2action.Warnings, error)
	GetServiceInstancesByApplication(appGUID string) ([]v2action.ServiceInstance, v2action.Warnings, error)
	GetStack(guid string) (v2action.Stack, v2action.Warnings, error)
	GetStackByName(stackName string) (v2action.Stack, v2action.Warnings, error)
	PollJob(job v2action.Job) (v2action.Warnings, error)
	ResourceMatch(allResources []v2action.Resource) ([]v2action.Resource, []v2action.Resource, v2action.Warnings, error)
	UnmapRouteFromApplication(routeGUID string, appGUID string) (v2action.Warnings, error)
	UpdateApplication(application v2action.Application) (v2action.Application, v2action.Warnings, error)
	UploadApplicationPackage(appGUID string, existingResources []v2action.Resource, newResources io.Reader, newResourcesLength int64) (v2action.Job, v2action.Warnings, error)
	UploadDroplet(appGUID string, droplet io.Reader, dropletLength int64) (v2action.Job, v2action.Warnings, error)
}

type V3Actor

type V3Actor interface {
	CloudControllerAPIVersion() string
	CreateApplicationInSpace(app v3action.Application, spaceGUID string) (v3action.Application, v3action.Warnings, error)
	CreateBitsPackageByApplication(appGUID string) (v3action.Package, v3action.Warnings, error)
	GetApplicationByNameAndSpace(appName string, spaceGUID string) (v3action.Application, v3action.Warnings, error)
	PollPackage(pkg v3action.Package) (v3action.Package, v3action.Warnings, error)
	SetApplicationDroplet(appGUID string, dropletGUID string) (v3action.Warnings, error)
	StageApplicationPackage(pkgGUID string) (v3action.Build, v3action.Warnings, error)
	PollBuild(buildGUID string, appName string) (v3action.Droplet, v3action.Warnings, error)
	UpdateApplication(v3action.Application) (v3action.Application, v3action.Warnings, error)
	UploadBitsPackage(v3action.Package, []sharedaction.Resource, io.Reader, int64) (v3action.Package, v3action.Warnings, error)
}

type Warnings

type Warnings []string

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

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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