github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/directory/deploy.go (about)

     1  package directory
     2  
     3  import (
     4  	"github.com/hashicorp/otto/helper/uuid"
     5  )
     6  
     7  // Deploy represents a deploy of an App.
     8  type Deploy struct {
     9  	// Lookup information for the Deploy. AppID, Infra, and InfraFlavor
    10  	// are required.
    11  	Lookup
    12  
    13  	// These fields should be set for Put and will be populated on Get
    14  	State  DeployState       // State of the deploy
    15  	Deploy map[string]string // Deploy information
    16  
    17  	// Private fields. These are usually set on Get or Put.
    18  	//
    19  	// DO NOT MODIFY THESE.
    20  	ID string
    21  }
    22  
    23  // IsNew reports if this deploy is freshly created and not yet run
    24  func (d *Deploy) IsNew() bool {
    25  	return d != nil && d.State == DeployStateNew
    26  }
    27  
    28  // IsDeployed reports if this deploy succeeded.
    29  func (d *Deploy) IsDeployed() bool {
    30  	return d != nil && d.State == DeployStateSuccess
    31  }
    32  
    33  // IsFailed reports if this deploy failed.
    34  func (d *Deploy) IsFailed() bool {
    35  	return d != nil && d.State == DeployStateFail
    36  }
    37  
    38  // MarkFailed sets a deploy's state to failed
    39  func (d *Deploy) MarkFailed() {
    40  	d.State = DeployStateFail
    41  }
    42  
    43  // MarkSuccess sets a deploy's state to success
    44  func (d *Deploy) MarkSuccessful() {
    45  	d.State = DeployStateSuccess
    46  }
    47  
    48  // MarkGone resets a deploy's state to the "new" state
    49  func (d *Deploy) MarkGone() {
    50  	d.State = DeployStateNew
    51  }
    52  
    53  func (d *Deploy) setId() {
    54  	d.ID = uuid.GenerateUUID()
    55  }