2017-04-20 02:04:09 +02:00
|
|
|
package discovery
|
|
|
|
|
|
|
|
// PluginRequirements describes a set of plugins (assumed to be of a consistent
|
|
|
|
// kind) that are required to exist and have versions within the given
|
|
|
|
// corresponding sets.
|
|
|
|
//
|
2017-05-03 23:31:46 +02:00
|
|
|
// PluginRequirements is a map from plugin name to Constraints.
|
|
|
|
type PluginRequirements map[string]Constraints
|
2017-04-20 02:04:09 +02:00
|
|
|
|
|
|
|
// Merge takes the contents of the receiver and the other given requirements
|
|
|
|
// object and merges them together into a single requirements structure
|
|
|
|
// that satisfies both sets of requirements.
|
|
|
|
func (r PluginRequirements) Merge(other PluginRequirements) PluginRequirements {
|
|
|
|
ret := make(PluginRequirements)
|
|
|
|
for n, vs := range r {
|
|
|
|
ret[n] = vs
|
|
|
|
}
|
|
|
|
for n, vs := range other {
|
|
|
|
if existing, exists := ret[n]; exists {
|
2017-05-05 00:53:02 +02:00
|
|
|
ret[n] = existing.Append(vs)
|
2017-04-20 02:04:09 +02:00
|
|
|
} else {
|
|
|
|
ret[n] = vs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|