add string form, extend selector with EXISTS, new tests/some old tests use table-driven style

Based on discussion in https://github.com/GoogleCloudPlatform/kubernetes/pull/715. Some of the old tests were not converted to table-driven format since the code on which they are based will probably be removed in the near term. Future work includes: changing uses of old code in other parts of the code base to use newer version of selector, removing old selector code, removing tests of old selector code, and adding number ranges to selector values.
What is wrong with commas?  That is a natural fit.

Alternatively "in(x, [y, z])"  "not_in(x, [y, z]".  We can dream up a
thousand syntaxes, let's choose something simple and obvious and extensible


On Tue, Aug 19, 2014 at 8:19 PM, meirf <notifications@github.com> wrote:

> In pkg/labels/selector_test.go:
>
> >  	}
> >  }
> >
> > -func TestRequirementMatches(t *testing.T) {
> > -	s := Set{"x": "foo", "y": "baz"}
> > -	a := Requirement{key: "x", operator: IN, strValues: util.NewStringSet("foo")}
> > -	b := Requirement{key: "x", operator: NOT_IN, strValues: util.NewStringSet("beta")}
> > -	c := Requirement{key: "y", operator: IN, strValues: nil}
> > -	d := Requirement{key: "y", strValues: util.NewStringSet("foo")}
> > -	expectMatchRequirement(t, a, s)
> > -	expectMatchRequirement(t, b, s)
> > -	expectNoMatchRequirement(t, c, s)
> > -	expectNoMatchRequirement(t, d, s)
> > +var strValidityTests = []struct {
> > +	in      string
> > +	isValid bool
> > +}{
> > +	{"abc", false},
>
> Because the empty string is a legal value, "x not in ()" would not be the
> same as "x" and so it should be allowed. On the structured message side,
> there is also only one way to express existence - using EXISTS. Please
> correct me if I'm wrong about this. I think the one way of expressing
> existence makes it much more intuitive. Regarding @thockin
> <https://github.com/thockin>'s syntax above, how would they be joined
> together into one string - what should the separator be? I was hoping it
> wouldn't be commas :)
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/951/files#r16456984>
> .
>