Merge pull request #34 from luxas/k8s_io

Various improvements
pull/36/head
dlorenc 2016-05-01 11:47:46 -07:00
commit 1ac17baea6
17 changed files with 109 additions and 54 deletions

View File

@ -7,4 +7,4 @@ install:
- echo "Don't run anything."
# Don't test vendored code.
script: go test $(go list ./... | grep -v /vendor/)
script: ./test.sh

2
Godeps/Godeps.json generated
View File

@ -1,5 +1,5 @@
{
"ImportPath": "github.com/kubernetes/minikube",
"ImportPath": "k8s.io/minikube",
"GoVersion": "go1.6",
"GodepVersion": "v62",
"Packages": [

View File

@ -34,28 +34,32 @@ For more information about minikube, see the [proposal](https://github.com/kuber
## Build Instructions
go build -o minikube cli/main.go
```shell
./build.sh
```
## Run Instructions
Start the cluster with:
./minikube start
Starting local Kubernetes cluster...
2016/04/19 11:41:26 Machine exists!
2016/04/19 11:41:27 Kubernetes is available at http://192.168.99.100:8080.
2016/04/19 11:41:27 Run this command to use the cluster:
2016/04/19 11:41:27 kubectl config set-cluster minikube --insecure-skip-tls-verify=true --server=http://192.168.99.100:8080
```console
$ ./minikube start
Starting local Kubernetes cluster...
2016/04/19 11:41:26 Machine exists!
2016/04/19 11:41:27 Kubernetes is available at http://192.168.99.100:8080.
2016/04/19 11:41:27 Run this command to use the cluster:
2016/04/19 11:41:27 kubectl config set-cluster minikube --insecure-skip-tls-verify=true --server=http://192.168.99.100:8080
```
Access the cluster with:
Access the cluster by adding `-s=http://192.168.x.x:8080` to every `kubectl` command, or run the commands below:
First run the command from above:
```shell
kubectl config set-cluster minikube --insecure-skip-tls-verify=true --server=http://192.168.99.100:8080
kubectl config set-context minikube --cluster=minikube
kubectl config use-context minikube
```
kubectl config set-cluster minikube --insecure-skip-tls-verify=true --server=http://192.168.99.100:8080
Then use kubectl normally:
kubectl get pods --cluster=minikube
by running those commands, you may use `kubectl` normally
## Development
@ -67,15 +71,16 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for an overview of how to send pull reque
Unit tests are run on Travis before code is merged. To run as part of a development cycle:
go test $(go list ./... | grep -v /vendor/)
```shell
./test.sh
```
#### Integration Tests
Integration tests are currently run manually. To run them, first build the binary:
go build -o minikube cli/main.go
Then test it:
go test ./integration --tags=integration
Integration tests are currently run manually.
To run them, build the binary and run the tests:
```shell
./build.sh
go test ./integration --tags=integration
```

29
build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cd "$( dirname "${BASH_SOURCE[0]}" )"
REPO_PATH="k8s.io/minikube"
export GOPATH=${PWD}/.gopath
export GO15VENDOREXPERIMENT=1
export OS=${OS:-$(go env GOOS)}
export ARCH=${ARCH:-$(go env GOARCH)}
rm -f ${GOPATH}/src/${REPO_PATH}
mkdir -p $(dirname ${GOPATH}/src/${REPO_PATH})
ln -s ${PWD} $GOPATH/src/${REPO_PATH}
CGO_ENABLED=0 GOARCH=${ARCH} GOOS=${OS} go build --installsuffix cgo -a -o minikube cli/main.go

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -24,7 +24,7 @@ import (
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/state"
"github.com/kubernetes/minikube/cli/constants"
"k8s.io/minikube/cli/constants"
)
// StartHost starts a host VM.

View File

@ -7,8 +7,8 @@ import (
"github.com/docker/machine/libmachine/host"
"github.com/docker/machine/libmachine/state"
"github.com/kubernetes/minikube/cli/constants"
"github.com/kubernetes/minikube/cli/tests"
"k8s.io/minikube/cli/constants"
"k8s.io/minikube/cli/tests"
)
func TestCreateHost(t *testing.T) {

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -18,9 +18,9 @@ import (
"os"
"github.com/docker/machine/libmachine"
"github.com/kubernetes/minikube/cli/cluster"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/cluster"
"k8s.io/minikube/cli/constants"
)
// deleteCmd represents the delete command

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -18,8 +18,8 @@ import (
"log"
"os"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/constants"
)
var dirs = [...]string{
@ -29,11 +29,9 @@ var dirs = [...]string{
// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "cli",
Use: "minikube",
Short: "Minikube is a tool for managing local Kubernetes clusters.",
Long: `Minikube is a CLI tool that provisions and manages single-node Kubernetes
clusters optimized for development workflows.
`,
Long: `Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for development workflows.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
for _, path := range dirs {
if err := os.MkdirAll(path, 0777); err != nil {

View File

@ -6,8 +6,8 @@ import (
"os"
"testing"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/constants"
)
func makeTempDir() string {

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -20,9 +20,9 @@ import (
"strings"
"github.com/docker/machine/libmachine"
"github.com/kubernetes/minikube/cli/cluster"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/cluster"
"k8s.io/minikube/cli/constants"
)
// startCmd represents the start command

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -19,9 +19,9 @@ import (
"os"
"github.com/docker/machine/libmachine"
"github.com/kubernetes/minikube/cli/cluster"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/cluster"
"k8s.io/minikube/cli/constants"
)
// statusCmd represents the status command

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -18,9 +18,9 @@ import (
"os"
"github.com/docker/machine/libmachine"
"github.com/kubernetes/minikube/cli/cluster"
"github.com/kubernetes/minikube/cli/constants"
"github.com/spf13/cobra"
"k8s.io/minikube/cli/cluster"
"k8s.io/minikube/cli/constants"
)
// stopCmd represents the stop command

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/docker/machine/libmachine/drivers/plugin/localbinary"
"github.com/kubernetes/minikube/cli/constants"
"k8s.io/minikube/cli/constants"
)
func makeTempDir() string {

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -14,12 +14,11 @@ limitations under the License.
package main
import (
"github.com/kubernetes/minikube/cli/cmd"
"github.com/kubernetes/minikube/cli/machine"
"k8s.io/minikube/cli/cmd"
"k8s.io/minikube/cli/machine"
)
func main() {
machine.StartDriver()
cmd.Execute()
}

View File

@ -1,7 +1,7 @@
// +build integration
/*
Copyright 2015 The Kubernetes Authors All rights reserved.
Copyright 2016 The Kubernetes Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

24
test.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# First, build the binary
source ./build.sh
# Then run all test files
for TEST in $(find -name "*.go" | grep -v vendor | grep -v integration | grep _test.go | cut -d/ -f2- | sed 's|/\w*.go||g' | uniq); do
echo $TEST
go test -v ${REPO_PATH}/${TEST}
done