github.com/randomtask1155/cli@v6.41.1-0.20181227003417-a98eed78cbde+incompatible/actor/pushaction/actor.go (about)

     1  // Package pushaction contains the business logic for orchestrating a V2 app
     2  // push.
     3  package pushaction
     4  
     5  import (
     6  	"regexp"
     7  
     8  	"code.cloudfoundry.org/cli/util/randomword"
     9  )
    10  
    11  // Warnings is a list of warnings returned back from the cloud controller
    12  type Warnings []string
    13  
    14  // Actor handles all business logic for Cloud Controller v2 operations.
    15  type Actor struct {
    16  	SharedActor   SharedActor
    17  	V2Actor       V2Actor
    18  	V3Actor       V3Actor
    19  	WordGenerator RandomWordGenerator
    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 V3Actor, sharedActor SharedActor) *Actor {
    30  	return &Actor{
    31  		SharedActor:   sharedActor,
    32  		V2Actor:       v2Actor,
    33  		V3Actor:       v3Actor,
    34  		WordGenerator: new(randomword.Generator),
    35  
    36  		startWithProtocol: regexp.MustCompile(ProtocolRegexp),
    37  		urlValidator:      regexp.MustCompile(URLRegexp),
    38  	}
    39  }