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

     1  package appfile
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"github.com/hashicorp/otto/appfile/detect"
     7  )
     8  
     9  // Default will generate a default Appfile for the given directory.
    10  //
    11  // The path to the directory must be absolute, since the path is used
    12  // as a way to determine the name of the application.
    13  func Default(dir string, det *detect.Config) (*File, error) {
    14  	var appType string
    15  	appName := filepath.Base(dir)
    16  	if det != nil {
    17  		t, err := detect.App(dir, det)
    18  		if err != nil {
    19  			return nil, err
    20  		}
    21  
    22  		appType = t
    23  	}
    24  
    25  	return &File{
    26  		Path: filepath.Join(dir, "Appfile"),
    27  
    28  		Application: &Application{
    29  			Name:   appName,
    30  			Type:   appType,
    31  			Detect: true,
    32  		},
    33  
    34  		Project: &Project{
    35  			Name:           appName,
    36  			Infrastructure: appName,
    37  		},
    38  
    39  		Infrastructure: []*Infrastructure{
    40  			&Infrastructure{
    41  				Name:   appName,
    42  				Type:   "aws",
    43  				Flavor: "simple",
    44  
    45  				Foundations: []*Foundation{
    46  					&Foundation{
    47  						Name: "consul",
    48  					},
    49  				},
    50  			},
    51  		},
    52  	}, nil
    53  }