github.com/fibonacci1729/draft@v0.3.0/pkg/draft/manifest/manifest.go (about) 1 package manifest 2 3 import "github.com/technosophos/moniker" 4 5 const ( 6 // DefaultEnvironmentName is the name invoked from draft.toml on `draft up` when 7 // --environment is not supplied. 8 DefaultEnvironmentName = "development" 9 // DefaultNamespace specifies the namespace apps should be deployed to by default. 10 DefaultNamespace = "default" 11 // DefaultWatchDelaySeconds is the time delay between files being changed and when a 12 // new draft up` invocation is called when --watch is supplied. 13 DefaultWatchDelaySeconds = 2 14 ) 15 16 // Manifest represents a draft.yaml 17 type Manifest struct { 18 Environments map[string]*Environment `toml:"environments"` 19 } 20 21 // Environment represents the environment for a given app at build time 22 type Environment struct { 23 Name string `toml:"name,omitempty"` 24 BuildTarPath string `toml:"build_tar,omitempty"` 25 ChartTarPath string `toml:"chart_tar,omitempty"` 26 Namespace string `toml:"namespace,omitempty"` 27 Values []string `toml:"set,omitempty"` 28 Wait bool `toml:"wait,omitempty"` 29 Watch bool `toml:"watch,omitempty"` 30 WatchDelay int `toml:"watch_delay,omitempty"` 31 } 32 33 // New creates a new manifest with the Environments intialized. 34 func New() *Manifest { 35 m := Manifest{ 36 Environments: make(map[string]*Environment), 37 } 38 m.Environments[DefaultEnvironmentName] = &Environment{ 39 Name: generateName(), 40 Namespace: DefaultNamespace, 41 Watch: true, 42 WatchDelay: DefaultWatchDelaySeconds, 43 } 44 return &m 45 } 46 47 // generateName generates a random name 48 func generateName() string { 49 namer := moniker.New() 50 return namer.NameSep("-") 51 }