func (c *EqualsConstraint) Match(offer *mesos.Offer) bool { for _, a := range offer.GetAttributes() { if c.Attribute == a.GetName() { if a.GetType() == mesos.Value_TEXT { return c.Value == a.GetText().GetValue() } else if a.GetType() == mesos.Value_SCALAR { return c.Value == fmt.Sprintf("%.f", a.GetScalar().GetValue()) } else { return false } } } return false }
func OfferAttributes(offer *mesos.Offer) map[string]string { offerAttributes := map[string]string{ "hostname": offer.GetHostname(), } for _, attribute := range offer.GetAttributes() { text := attribute.GetText().GetValue() if text != "" { offerAttributes[attribute.GetName()] = text } } return offerAttributes }
func Offer(offer *mesos.Offer) string { var buffer bytes.Buffer buffer.WriteString(offer.GetHostname()) buffer.WriteString(ID(offer.GetId().GetValue())) resources := Resources(offer.GetResources()) if resources != "" { buffer.WriteString(" ") buffer.WriteString(resources) } attributes := Attributes(offer.GetAttributes()) if attributes != "" { buffer.WriteString(" ") buffer.WriteString(attributes) } return buffer.String() }
func offerString(offer *mesos.Offer) string { return fmt.Sprintf("\n%s%s %s %s", offer.GetHostname(), idString(offer.GetId().GetValue()), resourcesString(offer.GetResources()), attributesString(offer.GetAttributes())) }