github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/manifestparser/manifest.go (about)

     1  package manifestparser
     2  
     3  type Manifest struct {
     4  	Applications   []Application `yaml:"applications"`
     5  	PathToManifest string        `yaml:"-"`
     6  }
     7  
     8  func (m Manifest) AppNames() []string {
     9  	var names []string
    10  	for _, app := range m.Applications {
    11  		names = append(names, app.Name)
    12  	}
    13  	return names
    14  }
    15  
    16  func (m Manifest) ContainsMultipleApps() bool {
    17  	return len(m.Applications) > 1
    18  }
    19  
    20  func (m Manifest) ContainsPrivateDockerImages() bool {
    21  	for _, app := range m.Applications {
    22  		if app.Docker != nil && app.Docker.Username != "" {
    23  			return true
    24  		}
    25  	}
    26  	return false
    27  }
    28  
    29  func (m Manifest) GetFirstApp() *Application {
    30  	return &m.Applications[0]
    31  }
    32  
    33  func (m Manifest) GetFirstAppWebProcess() *Process {
    34  	for i, process := range m.Applications[0].Processes {
    35  		if process.Type == "web" {
    36  			return &m.Applications[0].Processes[i]
    37  		}
    38  	}
    39  
    40  	return nil
    41  }
    42  
    43  func (m Manifest) HasAppWithNoName() bool {
    44  	for _, app := range m.Applications {
    45  		if app.Name == "" {
    46  			return true
    47  		}
    48  	}
    49  	return false
    50  }