v7pushaction

package
v8.7.8-mod Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package v7pushaction 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+)?$"
View Source
const UploadRetries = 3

Variables

This section is empty.

Functions

func HandleAppNameOverride

func HandleAppNameOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleAppPathOverride

func HandleAppPathOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

Overrides the path if path is given. Changes empty paths to pwd. Validates paths

func HandleBuildpacksOverride

func HandleBuildpacksOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleDefaultRouteOverride

func HandleDefaultRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleDiskOverride

func HandleDiskOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleDockerImageOverride

func HandleDockerImageOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleDockerUsernameOverride

func HandleDockerUsernameOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleDropletPathOverride

func HandleDropletPathOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleHealthCheckEndpointOverride

func HandleHealthCheckEndpointOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleHealthCheckTimeoutOverride

func HandleHealthCheckTimeoutOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleHealthCheckTypeOverride

func HandleHealthCheckTypeOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleInstancesOverride

func HandleInstancesOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleLogRateLimitOverride

func HandleLogRateLimitOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleMemoryOverride

func HandleMemoryOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleNoRouteOverride

func HandleNoRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleRandomRouteOverride

func HandleRandomRouteOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleStackOverride

func HandleStackOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleStartCommandOverride

func HandleStartCommandOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleStrategyOverride

func HandleStrategyOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func HandleTaskOverride

func HandleTaskOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

func ShouldCreateBitsPackage

func ShouldCreateBitsPackage(plan PushPlan) bool

func ShouldCreateDeployment

func ShouldCreateDeployment(plan PushPlan) bool

func ShouldCreateDockerPackage

func ShouldCreateDockerPackage(plan PushPlan) bool

func ShouldCreateDroplet

func ShouldCreateDroplet(plan PushPlan) bool

func ShouldRestart

func ShouldRestart(plan PushPlan) bool

func ShouldSetDroplet

func ShouldSetDroplet(plan PushPlan) bool

func ShouldStagePackage

func ShouldStagePackage(plan PushPlan) bool

func ShouldStopApplication

func ShouldStopApplication(plan PushPlan) bool

Types

type Actor

type Actor struct {
	SharedActor SharedActor
	V7Actor     V7Actor

	PreparePushPlanSequence   []UpdatePushPlanFunc
	ChangeApplicationSequence func(plan PushPlan) []ChangeApplicationFunc
	TransformManifestSequence []HandleFlagOverrideFunc
	// contains filtered or unexported fields
}

Actor handles all business logic for Cloud Controller operations.

func NewActor

func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor

NewActor returns a new actor.

func (Actor) Actualize

func (actor Actor) Actualize(plan PushPlan, progressBar ProgressBar) <-chan *PushEvent

func (Actor) CreateAndReturnArchivePath

func (actor Actor) CreateAndReturnArchivePath(pushPlan PushPlan, unmatchedResources []sharedaction.V3Resource) (string, error)

func (Actor) CreateAndUploadApplicationBits

func (actor Actor) CreateAndUploadApplicationBits(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (resources.Package, Warnings, error)

func (Actor) CreateBitsPackageForApplication

func (actor Actor) CreateBitsPackageForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) CreateDeploymentForApplication

func (actor Actor) CreateDeploymentForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) CreateDockerPackageForApplication

func (actor Actor) CreateDockerPackageForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) CreateDropletForApplication

func (actor Actor) CreateDropletForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) CreatePushPlans

func (actor Actor) CreatePushPlans(
	spaceGUID string,
	orgGUID string,
	manifest manifestparser.Manifest,
	overrides FlagOverrides,
) ([]PushPlan, v7action.Warnings, error)

CreatePushPlans returns a set of PushPlan objects based off the inputs provided. It's assumed that all flag and argument and manifest combinations have been validated prior to calling this function.

func (Actor) GetPrepareApplicationSourceSequence

func (actor Actor) GetPrepareApplicationSourceSequence(plan PushPlan) []ChangeApplicationFunc

func (Actor) GetRuntimeSequence

func (actor Actor) GetRuntimeSequence(plan PushPlan) []ChangeApplicationFunc

func (Actor) HandleFlagOverrides

func (actor Actor) HandleFlagOverrides(
	baseManifest manifestparser.Manifest,
	flagOverrides FlagOverrides,
) (manifestparser.Manifest, error)

func (Actor) MatchResources

func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error)

MatchResources returns back a list of matched and unmatched resources for the provided resources.

func (Actor) RestartApplication

func (actor Actor) RestartApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) SetDropletForApplication

func (actor Actor) SetDropletForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) SetupAllResourcesForPushPlan

func (actor Actor) SetupAllResourcesForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func (Actor) StagePackageForApplication

func (actor Actor) StagePackageForApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

func (Actor) StopApplication

func (actor Actor) StopApplication(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

type ChangeApplicationFunc

type ChangeApplicationFunc func(pushPlan PushPlan, eventStream chan<- *PushEvent, progressBar ProgressBar) (PushPlan, Warnings, error)

ChangeApplicationFunc is a function that is used by Actualize to setup application for staging, droplet creation, etc.

type Event

type Event string
const (
	ApplyManifest                   Event = "Applying manifest"
	ApplyManifestComplete           Event = "Applying manifest Complete"
	CreatingArchive                 Event = "creating archive"
	CreatingDroplet                 Event = "creating droplet"
	CreatingPackage                 Event = "creating package"
	InstanceDetails                 Event = "instance details"
	PollingBuild                    Event = "polling build"
	ReadingArchive                  Event = "reading archive"
	ResourceMatching                Event = "resource matching"
	RestartingApplication           Event = "restarting application"
	RestartingApplicationComplete   Event = "restarting application complete"
	RetryUpload                     Event = "retry upload"
	SetDockerImage                  Event = "setting docker properties"
	SetDockerImageComplete          Event = "completed setting docker properties"
	SetDropletComplete              Event = "set droplet complete"
	SettingDroplet                  Event = "setting droplet"
	StagingComplete                 Event = "staging complete"
	StartingDeployment              Event = "starting deployment"
	StartingStaging                 Event = "starting staging"
	StoppingApplication             Event = "stopping application"
	StoppingApplicationComplete     Event = "stopping application complete"
	UploadDropletComplete           Event = "upload droplet complete"
	UploadingApplication            Event = "uploading application"
	UploadingApplicationWithArchive Event = "uploading application with archive"
	UploadingDroplet                Event = "uploading droplet"
	UploadWithArchiveComplete       Event = "upload complete"
	WaitingForDeployment            Event = "waiting for deployment"
)

type FlagOverrides

type FlagOverrides struct {
	AppName             string
	Buildpacks          []string
	Stack               string
	Disk                string
	DropletPath         string
	DockerImage         string
	DockerPassword      string
	DockerUsername      string
	HealthCheckEndpoint string
	HealthCheckTimeout  int64
	HealthCheckType     constant.HealthCheckType
	Instances           types.NullInt
	Memory              string
	NoStart             bool
	NoWait              bool
	ProvidedAppPath     string
	NoRoute             bool
	RandomRoute         bool
	StartCommand        types.FilteredString
	Strategy            constant.DeploymentStrategy
	ManifestPath        string
	PathsToVarsFiles    []string
	Vars                []template.VarKV
	NoManifest          bool
	Task                bool
	LogRateLimit        string
}

type HandleFlagOverrideFunc

type HandleFlagOverrideFunc func(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error)

type ProgressBar

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

type PushEvent

type PushEvent struct {
	Event    Event
	Plan     PushPlan
	Err      error
	Warnings Warnings
}

type PushPlan

type PushPlan struct {
	SpaceGUID string
	OrgGUID   string

	Application resources.Application

	NoStart             bool
	NoWait              bool
	Strategy            constant.DeploymentStrategy
	TaskTypeApplication bool

	DockerImageCredentials v7action.DockerImageCredentials

	Archive      bool
	BitsPath     string
	DropletPath  string
	AllResources []sharedaction.V3Resource

	PackageGUID string
	DropletGUID string
}

func SetDefaultBitsPathForPushPlan

func SetDefaultBitsPathForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func SetupDeploymentStrategyForPushPlan

func SetupDeploymentStrategyForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func SetupDropletPathForPushPlan

func SetupDropletPathForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func SetupNoStartForPushPlan

func SetupNoStartForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func SetupNoWaitForPushPlan

func SetupNoWaitForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func SetupTaskAppForPushPlan

func SetupTaskAppForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

func (PushPlan) String

func (state PushPlan) String() string

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 UpdatePushPlanFunc

type UpdatePushPlanFunc func(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error)

UpdatePushPlanFunc is a function that is used by CreatePushPlans to setup push plans for the push command.

type V7Actor

type V7Actor interface {
	CreateApplicationDroplet(appGUID string) (resources.Droplet, v7action.Warnings, error)
	CreateApplicationInSpace(app resources.Application, spaceGUID string) (resources.Application, v7action.Warnings, error)
	CreateBitsPackageByApplication(appGUID string) (resources.Package, v7action.Warnings, error)
	CreateDeploymentByApplicationAndDroplet(appGUID string, dropletGUID string) (string, v7action.Warnings, error)
	CreateDockerPackageByApplication(appGUID string, dockerImageCredentials v7action.DockerImageCredentials) (resources.Package, v7action.Warnings, error)
	CreateRoute(spaceGUID, domainName, hostname, path string, port int) (resources.Route, v7action.Warnings, error)
	GetApplicationByNameAndSpace(appName string, spaceGUID string) (resources.Application, v7action.Warnings, error)
	GetApplicationDroplets(appName string, spaceGUID string) ([]resources.Droplet, v7action.Warnings, error)
	GetApplicationRoutes(appGUID string) ([]resources.Route, v7action.Warnings, error)
	GetApplicationsByNamesAndSpace(appNames []string, spaceGUID string) ([]resources.Application, v7action.Warnings, error)
	GetDefaultDomain(orgGUID string) (resources.Domain, v7action.Warnings, error)
	GetDomain(domainGUID string) (resources.Domain, v7action.Warnings, error)
	GetRouteByAttributes(domain resources.Domain, hostname, path string, port int) (resources.Route, v7action.Warnings, error)
	GetRouteDestinationByAppGUID(route resources.Route, appGUID string) (resources.RouteDestination, error)
	MapRoute(routeGUID string, appGUID string, destinationProtocol string) (v7action.Warnings, error)
	PollBuild(buildGUID string, appName string) (resources.Droplet, v7action.Warnings, error)
	PollPackage(pkg resources.Package) (resources.Package, v7action.Warnings, error)
	PollStart(app resources.Application, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error)
	PollStartForRolling(app resources.Application, deploymentGUID string, noWait bool, handleProcessStats func(string)) (v7action.Warnings, error)
	ResourceMatch(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, v7action.Warnings, error)
	RestartApplication(appGUID string, noWait bool) (v7action.Warnings, error)
	ScaleProcessByApplication(appGUID string, process resources.Process) (v7action.Warnings, error)
	SetApplicationDroplet(appGUID string, dropletGUID string) (v7action.Warnings, error)
	SetApplicationManifest(appGUID string, rawManifest []byte) (v7action.Warnings, error)
	SetSpaceManifest(spaceGUID string, rawManifest []byte) (v7action.Warnings, error)
	StageApplicationPackage(pkgGUID string) (resources.Build, v7action.Warnings, error)
	StopApplication(appGUID string) (v7action.Warnings, error)
	UnmapRoute(routeGUID string, destinationGUID string) (v7action.Warnings, error)
	UpdateApplication(app resources.Application) (resources.Application, v7action.Warnings, error)
	UpdateProcessByTypeAndApplication(processType string, appGUID string, updatedProcess resources.Process) (v7action.Warnings, error)
	UploadBitsPackage(pkg resources.Package, matchedResources []sharedaction.V3Resource, newResources io.Reader, newResourcesLength int64) (resources.Package, v7action.Warnings, error)
	UploadDroplet(dropletGUID string, dropletPath string, progressReader io.Reader, fileSize int64) (v7action.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