github.com/leowmjw/otto@v0.2.1-0.20160126165905-6400716cf085/otto/status.go (about) 1 package otto 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/go-multierror" 7 "github.com/hashicorp/otto/directory" 8 ) 9 10 // statusInfo holds the complete status information for the Core.Status 11 // function. 12 type statusInfo struct { 13 Err error 14 Dev *directory.Dev 15 Build *directory.Build 16 Deploy *directory.Deploy 17 Infra *directory.Infra 18 } 19 20 // statusInfo gets the information for the Status call. 21 // 22 // This is meant to be called in a goroutine. 23 func (c *Core) statusInfo(resultCh chan<- *statusInfo) { 24 infra := c.appfile.ActiveInfrastructure() 25 if infra == nil { 26 panic("infra not found") 27 } 28 29 var err error 30 var result statusInfo 31 32 // Dev 33 result.Dev, err = c.dir.GetDev(&directory.Dev{Lookup: directory.Lookup{ 34 AppID: c.appfile.ID}}) 35 if err != nil { 36 result.Err = multierror.Append(result.Err, fmt.Errorf( 37 "Error loading development status: %s", err)) 38 } 39 40 // Build 41 result.Build, err = c.dir.GetBuild(&directory.Build{Lookup: directory.Lookup{ 42 AppID: c.appfile.ID, Infra: infra.Type, InfraFlavor: infra.Flavor}}) 43 if err != nil { 44 result.Err = multierror.Append(result.Err, fmt.Errorf( 45 "Error loading build status: %s", err)) 46 } 47 48 // Deploy 49 result.Deploy, err = c.dir.GetDeploy(&directory.Deploy{Lookup: directory.Lookup{ 50 AppID: c.appfile.ID, Infra: infra.Type, InfraFlavor: infra.Flavor}}) 51 if err != nil { 52 result.Err = multierror.Append(result.Err, fmt.Errorf( 53 "Error loading deploy status: %s", err)) 54 } 55 56 // Infra 57 result.Infra, err = c.dir.GetInfra(&directory.Infra{Lookup: directory.Lookup{ 58 Infra: infra.Name}}) 59 if err != nil { 60 result.Err = multierror.Append(result.Err, fmt.Errorf( 61 "Error loading infra status: %s", err)) 62 } 63 64 resultCh <- &result 65 }