github.com/technosophos/deis@v1.7.1-0.20150915173815-f9005256004b/client/cmd/builds.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"gopkg.in/yaml.v2"
     7  
     8  	"github.com/deis/deis/client/controller/models/builds"
     9  )
    10  
    11  // BuildsList lists an app's builds.
    12  func BuildsList(appID string, results int) error {
    13  	c, appID, err := load(appID)
    14  
    15  	if err != nil {
    16  		return err
    17  	}
    18  
    19  	if results == defaultLimit {
    20  		results = c.ResponseLimit
    21  	}
    22  
    23  	builds, count, err := builds.List(c, appID, results)
    24  
    25  	if err != nil {
    26  		return err
    27  	}
    28  
    29  	fmt.Printf("=== %s Builds%s", appID, limitCount(len(builds), count))
    30  
    31  	for _, build := range builds {
    32  		fmt.Println(build.UUID, build.Created)
    33  	}
    34  	return nil
    35  }
    36  
    37  // BuildsCreate creates a build for an app.
    38  func BuildsCreate(appID, image, procfile string) error {
    39  	c, appID, err := load(appID)
    40  
    41  	if err != nil {
    42  		return err
    43  	}
    44  
    45  	var procfileMap map[string]string
    46  
    47  	if procfile != "" {
    48  		err = yaml.Unmarshal([]byte(procfile), &procfileMap)
    49  
    50  		if err != nil {
    51  			return err
    52  		}
    53  	}
    54  
    55  	fmt.Print("Creating build... ")
    56  	quit := progress()
    57  	_, err = builds.New(c, appID, image, procfileMap)
    58  	quit <- true
    59  	<-quit
    60  
    61  	if err != nil {
    62  		return err
    63  	}
    64  
    65  	fmt.Println("done")
    66  
    67  	return nil
    68  }