WIP: First cut at input validation for Kubelet

* Add some util functions for basic validation
* Spec api fields more tightly
* Break a dep from util -> api, so I can do the reverse
* Add functions to validate structures
* Call those functions when running manifests

This does not validate as it unmarshals YAML or JSON because I want to be able
to validate structures that come from other inputs without forcing them to be
YAML.

This does not handle all api structures - I am not familiar wnough with the
rest to spec them this tightly - I hope someone else can do that.

There are a number of open questions, marked "FIXME".  Please offer feedback
or opinions.
That's great as long as all input will be JSON or YAML forever.  I wasn't
confident in that - it has a funny smell to it.  Unfortunately I don't know
of any way to capture the assignment operation or to define a new type that
can convert automatically.

To quote r@ in some doc or other: C++ is about programming with TYPES, Go
is about programming with algorithms.  Go just does not have the powerful
type system that C++ does.  I'm a big proponent of programming with types,
but it isn't Goan.


On Fri, Jun 27, 2014 at 10:13 PM, Daniel Smith <notifications@github.com>
wrote:

> In pkg/api/types.go:
>
> >  }
> >
> >  // Volume represents a named volume in a pod that may be accessed by any containers in the pod.
> >  type Volume struct {
> > +	// Required: This must be a DNS_LABEL, 63 characters or less.  Each volume in a
> > +	// pod must have a unique name.
> >  	Name string `yaml:"name" json:"name"`
>
> I would love it if you could make a "type DNSLabel string", and implement
> SetJSON and SetYAML, such that it will return errors at the parsing stage
> if it's incorrect. What you have here works, but doing it that way you have
> to only write the validation one place and you automatically get the checks
> every time you unmarshal.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/280/files#r14322615>
> .
>