mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-29 19:41:15 +02:00
* Worker: introduce automatic "org.cirruslabs.orchard.worker-name" label * TestLabelsCopy: use constants to fix linter error
36 lines
515 B
Go
36 lines
515 B
Go
package v1
|
|
|
|
import "maps"
|
|
|
|
const (
|
|
LabelWorkerName = "org.cirruslabs.orchard.worker-name"
|
|
)
|
|
|
|
type Labels map[string]string
|
|
|
|
func (labels Labels) Contains(other Labels) bool {
|
|
for label, value := range other {
|
|
if labels[label] != value {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func (labels Labels) Copy() Labels {
|
|
if labels == nil {
|
|
return make(Labels)
|
|
}
|
|
|
|
return maps.Clone(labels)
|
|
}
|
|
|
|
func (labels Labels) Merged(other Labels) Labels {
|
|
result := labels.Copy()
|
|
|
|
maps.Copy(result, other)
|
|
|
|
return result
|
|
}
|