github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/actor.go (about) 1 // Package v7pushaction contains the business logic for orchestrating a V2 app 2 // push. 3 package v7pushaction 4 5 import ( 6 "regexp" 7 ) 8 9 // Warnings is a list of warnings returned back from the cloud controller 10 type Warnings []string 11 12 // Actor handles all business logic for Cloud Controller operations. 13 type Actor struct { 14 SharedActor SharedActor 15 V7Actor V7Actor 16 17 PreparePushPlanSequence []UpdatePushPlanFunc 18 ChangeApplicationSequence func(plan PushPlan) []ChangeApplicationFunc 19 TransformManifestSequence []HandleFlagOverrideFunc 20 21 startWithProtocol *regexp.Regexp 22 urlValidator *regexp.Regexp 23 } 24 25 const ProtocolRegexp = "^https?://|^tcp://" 26 const URLRegexp = "^(?:https?://|tcp://)?(?:(?:[\\w-]+\\.)|(?:[*]\\.))+\\w+(?:\\:\\d+)?(?:/.*)*(?:\\.\\w+)?$" 27 28 // NewActor returns a new actor. 29 func NewActor(v3Actor V7Actor, sharedActor SharedActor) *Actor { 30 actor := &Actor{ 31 SharedActor: sharedActor, 32 V7Actor: v3Actor, 33 34 startWithProtocol: regexp.MustCompile(ProtocolRegexp), 35 urlValidator: regexp.MustCompile(URLRegexp), 36 } 37 38 actor.TransformManifestSequence = []HandleFlagOverrideFunc{ 39 // app name override must come first, so it can trim the manifest 40 // from multiple apps down to just one 41 HandleAppNameOverride, 42 43 HandleInstancesOverride, 44 HandleStartCommandOverride, 45 46 // Type must come before endpoint because endpoint validates against type 47 HandleHealthCheckTypeOverride, 48 HandleHealthCheckEndpointOverride, 49 50 HandleHealthCheckTimeoutOverride, 51 HandleMemoryOverride, 52 HandleDiskOverride, 53 HandleLogRateLimitOverride, 54 HandleNoRouteOverride, 55 HandleRandomRouteOverride, 56 HandleTaskOverride, 57 58 // this must come after all routing related transforms 59 HandleDefaultRouteOverride, 60 61 HandleDockerImageOverride, 62 HandleDockerUsernameOverride, 63 HandleStackOverride, 64 HandleBuildpacksOverride, 65 HandleStrategyOverride, 66 HandleAppPathOverride, 67 HandleDropletPathOverride, 68 } 69 70 actor.PreparePushPlanSequence = []UpdatePushPlanFunc{ 71 SetDefaultBitsPathForPushPlan, 72 SetupDropletPathForPushPlan, 73 actor.SetupAllResourcesForPushPlan, 74 SetupDeploymentStrategyForPushPlan, 75 SetupNoStartForPushPlan, 76 SetupNoWaitForPushPlan, 77 SetupTaskAppForPushPlan, 78 } 79 80 actor.ChangeApplicationSequence = func(plan PushPlan) []ChangeApplicationFunc { 81 var sequence []ChangeApplicationFunc 82 sequence = append(sequence, actor.GetPrepareApplicationSourceSequence(plan)...) 83 sequence = append(sequence, actor.GetRuntimeSequence(plan)...) 84 return sequence 85 } 86 87 return actor 88 }