forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanifest.go
51 lines (43 loc) · 1.02 KB
/
manifest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package manifestparser
type Manifest struct {
Applications []Application `yaml:"applications"`
Version int `yaml:"version,omitempty"`
PathToManifest string `yaml:"-"`
}
func (m Manifest) AppNames() []string {
var names []string
for _, app := range m.Applications {
names = append(names, app.Name)
}
return names
}
func (m Manifest) ContainsMultipleApps() bool {
return len(m.Applications) > 1
}
func (m Manifest) ContainsPrivateDockerImages() bool {
for _, app := range m.Applications {
if app.Docker != nil && app.Docker.Username != "" {
return true
}
}
return false
}
func (m Manifest) GetFirstApp() *Application {
return &m.Applications[0]
}
func (m Manifest) GetFirstAppWebProcess() *Process {
for i, process := range m.Applications[0].Processes {
if process.Type == "web" {
return &m.Applications[0].Processes[i]
}
}
return nil
}
func (m Manifest) HasAppWithNoName() bool {
for _, app := range m.Applications {
if app.Name == "" {
return true
}
}
return false
}