extend selector with EXISTS, new tests/some old tests use table-driven style; add Has to Labels interface; enforce Requirement restrictions in constructor

This commit is contained in:
Meir Fischer
2014-08-18 23:41:20 -04:00
parent eb24c997e4
commit 89a9e5e672
4 changed files with 243 additions and 59 deletions

View File

@@ -23,6 +23,9 @@ import (
// Labels allows you to present labels independently from their storage.
type Labels interface {
// Has returns whether the provided label exists.
Has(label string) (exists bool)
// Get returns the value for the provided label.
Get(label string) (value string)
}
@@ -42,6 +45,12 @@ func (ls Set) String() string {
return strings.Join(selector, ",")
}
// Has returns whether the provided label exists in the map.
func (ls Set) Has(label string) bool {
_, exists := ls[label]
return exists
}
// Get returns the value in the map for the provided label.
func (ls Set) Get(label string) string {
return ls[label]