Namespace bash functions under build
Add the dependency to gcfg

This patch adds the dependency to gcfg in order to parse configuration
files.

Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
Refactor GCS parts of new release process
Added scheduler binaries plus other misc fixes

* Support cleaning out built docker images
* Use bash arrays in places
* Lock etcd version we are testing against
Add support for versions in dockerized build.
Add third_party/etcd to .gitignore

Otherwise the tree looks "dirty" after hack/install-etcd.sh is executed.

Tested:
- Ran `git status` after running `hack/install-etcd.sh`.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Add option to enable a simple CORS implementation for the api server
Move CORS handler wrapping into cmd/apiserver and switch config flag to a list of allowed origins
Move RecoverPanics to be the top level wrapped handler.  Add new method to be sure a logger has been generated instead of assuming one has.  Move regexp list compilation into a utility and pass regexp list into CORS.
Switch LogOf from panicking when logger is missing to creating logger with the defaults.
Update CORS tests to a table-based test and cover more cases.
Rebased and fixed test cases
Add support to fetch config file from network
Insert the current state of a replica controller.
Uniformize handling of -server_version flag of kubecfg to match -version.

In particular, add support for -server_version=raw and use matching
format for the output of -version and -server_version.

The "normal" format is essentially defined by (version.Info) String()
method, so future updates to that method will be reflected on both.

Full version information is still available by using the "raw" flag.

Tested:
- Used cluster/kubecfg.sh to query local build and the server.

    $ cluster/kubecfg.sh -version
    Kubernetes version 0.2+, build 9316edfc0d2b28923fbb6eafa38458350859f926
    $ cluster/kubecfg.sh -server_version
    Server: Kubernetes version 0.2, build a0abb3815755d6a77eed2d07bb0aa7d255e4e769
    $ cluster/kubecfg.sh -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-25-g9316edfc0d2b28", GitCommit:"9316edfc0d2b28923fbb6eafa38458350859f926", GitTreeState:"clean"}
    $ cluster/kubecfg.sh -server_version=raw
    version.Info{Major:"0", Minor:"2", GitVersion:"v0.2", GitCommit:"a0abb3815755d6a77eed2d07bb0aa7d255e4e769", GitTreeState:"clean"}

Fixes: #1092

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Update version to use -dev suffix

According to the plan listed in docs/releasing.md.

The gitMinor will keep using a "+" suffix instead for now.

Added a //TODO to deprecate gitMajor and gitMinor in a follow up.

Tested:
- Built it from the git tree:

    $ make
    $ _output/go/bin/kubecfg -version
    Kubernetes version 0.2+, build 8d31eb03c11d4db64ae26809eef7f73070efd811
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-29-g8d31eb03c11d4d", GitCommit:"8d31eb03c11d4db64ae26809eef7f73070efd811", GitTreeState:"clean"}

- Built it with a direct `go install` (same as tarball):

    $ GOPATH=${PWD}/_output/go:${PWD}/Godeps/_workspace go install $KUBE_GO_PACKAGE/cmd/kubecfg
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-dev", GitCommit:"", GitTreeState:"not a git tree"}
    $ _output/go/bin/kubecfg -version
    Kubernetes version 0.2+, build (unknown)

A follow up commit will address the output of the -version (without "raw") command to use gitVersion instead of Major + Minor.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Merge pull request #1245 from filbranden/server_version1

Uniformize handling of -server_version flag of kubecfg to match -version
Merge pull request #1247 from filbranden/version_dev

Update version to use -dev suffix
Match shell style guide.

Looking at https://google-styleguide.googlecode.com/svn/trunk/shell.xml
Small clean up in validation. errs is used as import path alias in validation.go, but it is reused
as a variable for validateVolume.
Use just GitVersion for the -version output

It turns out that that's simply the most useful information about the version
that was built.

For a git tree, it includes information about the closest release, number of
commits since the release, enough of the SHA1 to find the exact commit and
whether the tree was clean or dirty at build time.

For a build from tarball, it will include information of which release was built
and, when using a tarball from a not released commit (e.g. downloading
"master.tar.gz" from GitHub, not recommended!) it will include the -dev prefix
to indicate that was not an official release. (That's as good as we can get with
it.)

If additional information is required, it can be found with -version=raw.

Tested:

- Built from the git tree:

    $ _output/go/bin/kubecfg -version
    Kubernetes v0.2-29-gd916051e9db865
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-29-gd916051e9db865", GitCommit:"d916051e9db8650899acb9415a4e285e3e3a1f87", GitTreeState:"clean"}

- Built it from a dirty git tree:

    $ { echo 'package version'; echo 'var X = 1'; } >pkg/version/sillyvar.go
    $ make
    $ _output/go/bin/kubecfg -version
    Kubernetes v0.2-29-gd916051e9db865-dirty
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-29-gd916051e9db865-dirty", GitCommit:"d916051e9db8650899acb9415a4e285e3e3a1f87", GitTreeState:"dirty"}

- Tag it v0.3 and build it:

    $ git tag -a v0.3 -m 'Release Kubernetes v0.3'
    $ make
    $ _output/go/bin/kubecfg -version
    Kubernetes v0.3
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"3", GitVersion:"v0.3", GitCommit:"d916051e9db8650899acb9415a4e285e3e3a1f87", GitTreeState:"clean"}

- Built it from a tarball:

    $ wget -O kubernetes.tgz https://api.github.com/repos/filbranden/kubernetes/tarball/version_string1
    $ tar xvf kubernetes.tgz
    $ cd filbranden-kubernetes-*/
    $ make
    $ _output/go/bin/kubecfg -version
    Kubernetes v0.2-dev
    $ _output/go/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-dev", GitCommit:"", GitTreeState:"not a git tree"}

- Built it with `go get`:

    # I need to prefetch the tree to replace the official tree with mine:
    $ mkdir -p ${TMPDIR}/gopath/src/github.com/
    $ ln -sf filbranden ${TMPDIR}/gopath/src/github.com/GoogleCloudPlatform

    # Now run `go get` to build kubecfg:
    $ GOPATH=${TMPDIR}/gopath go get github.com/filbranden/kubernetes/cmd/kubecfg

    # Check the version:
    $ ${TMPDIR}/gopath/bin/kubecfg -version
    Kubernetes v0.2-dev
    $ ${TMPDIR}/gopath/bin/kubecfg -version=raw
    version.Info{Major:"0", Minor:"2+", GitVersion:"v0.2-dev", GitCommit:"", GitTreeState:"not a git tree"}

Signed-off-by: Filipe Brandenburger <filbranden@google.com>