Ejemplo n.º 1
0
func (h *Host) fetchImage(name types.ACIdentifier, labels types.Labels) (*Image, error) {
	if aci, asc, err := fetch.DiscoverACI(discovery.App{Name: name, Labels: labels.ToMap()}); err != nil {
		return nil, errors.Trace(err)
	} else if aci == nil {
		return nil, ErrNotFound
	} else {
		return h.ImportImage(name, aci, asc)
	}
}
Ejemplo n.º 2
0
// True if all labels in `labels` are present in `candidate` and have
// the same value
func MatchLabels(labels, candidate types.Labels) bool {
	if len(labels) == 0 {
		return true
	}
	cmap := candidate.ToMap()
	for _, label := range labels {
		if v, ok := cmap[label.Name]; !ok || v != label.Value {
			return false
		}
	}
	return true
}