github.com/arunkumar7540/cli@v6.45.0+incompatible/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 v2 operations. 13 type Actor struct { 14 SharedActor SharedActor 15 V2Actor V2Actor 16 V7Actor V7Actor 17 18 PreparePushPlanSequence []UpdatePushPlanFunc 19 ChangeApplicationSequence func(plan PushPlan) []ChangeApplicationFunc 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(v2Actor V2Actor, v3Actor V7Actor, sharedActor SharedActor) *Actor { 30 actor := &Actor{ 31 SharedActor: sharedActor, 32 V2Actor: v2Actor, 33 V7Actor: v3Actor, 34 35 startWithProtocol: regexp.MustCompile(ProtocolRegexp), 36 urlValidator: regexp.MustCompile(URLRegexp), 37 } 38 39 actor.PreparePushPlanSequence = []UpdatePushPlanFunc{ 40 SetupApplicationForPushPlan, 41 SetupDockerImageCredentialsForPushPlan, 42 SetupBitsPathForPushPlan, 43 SetupDropletPathForPushPlan, 44 actor.SetupAllResourcesForPushPlan, 45 SetupNoStartForPushPlan, 46 SetupSkipRouteCreationForPushPlan, 47 SetupScaleWebProcessForPushPlan, 48 SetupUpdateWebProcessForPushPlan, 49 } 50 51 actor.ChangeApplicationSequence = func(plan PushPlan) []ChangeApplicationFunc { 52 var sequence []ChangeApplicationFunc 53 sequence = append(sequence, actor.GetUpdateSequence(plan)...) 54 sequence = append(sequence, actor.GetPrepareApplicationSourceSequence(plan)...) 55 sequence = append(sequence, actor.GetRuntimeSequence(plan)...) 56 return sequence 57 } 58 59 return actor 60 }