Exemple #1
0
func NewStemcell(s bhstemsrepo.Stemcell) Stemcell {
	stemcell := &Stemcell{
		ManifestName: s.Name(),
		Version:      s.Version(),

		OSName:    s.OSName(),
		OSVersion: s.OSVersion(),
	}

	stemcell.AddAsSource(s)

	return *stemcell
}
Exemple #2
0
func (m StemcellOSMatch) Matches(s bhstemsrepo.Stemcell) bool {
	return s.OSName() == m.OSName && s.OSVersion() == m.OSVersion
}
Exemple #3
0
func (s *Stemcell) AddAsSource(s_ bhstemsrepo.Stemcell) {
	infName, ok := prettyInfNames[s_.InfName()]
	if !ok {
		infName = s_.InfName()
	}

	hvName, ok := prettyHvNames[s_.HvName()]
	if !ok {
		hvName = s_.HvName()
	}

	optionalDiskFormat := ""
	if len(s_.DiskFormat()) > 0 {
		optionalDiskFormat = fmt.Sprintf(" (%s)", s_.DiskFormat())
	}

	optionalLight := ""
	if s_.IsLight() {
		if s_.IsForChina() {
			optionalLight = " Light China"
		} else {
			optionalLight = " Light"
		}
	}

	source := &StemcellSource{
		friendlyName: fmt.Sprintf("%s %s%s%s", infName, hvName, optionalDiskFormat, optionalLight),

		URL:  s_.URL(),
		Size: s_.Size(),
		MD5:  s_.MD5(),

		UpdatedAt: s_.UpdatedAt(),
	}

	if s_.IsLight() {
		source.isLight = true

		if s_.IsForChina() {
			source.isForChina = true
			s.LightChinaSource = source
		} else {
			s.LightSource = source
		}
	} else {
		s.RegularSource = source
	}
}