Commit ea3be9e3 authored by Adam Reese's avatar Adam Reese

feat(*): migrate to kubernetes 1.5

parent 649396e8
...@@ -28,18 +28,18 @@ import ( ...@@ -28,18 +28,18 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/restclient" "k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/helm/cmd/helm/helmpath" "k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/tiller/environment"
) )
const ( const (
localRepoIndexFilePath = "index.yaml" localRepoIndexFilePath = "index.yaml"
homeEnvVar = "HELM_HOME" homeEnvVar = "HELM_HOME"
hostEnvVar = "HELM_HOST" hostEnvVar = "HELM_HOST"
tillerNamespace = "kube-system"
) )
var ( var (
...@@ -145,7 +145,7 @@ func main() { ...@@ -145,7 +145,7 @@ func main() {
func setupConnection(c *cobra.Command, args []string) error { func setupConnection(c *cobra.Command, args []string) error {
if tillerHost == "" { if tillerHost == "" {
tunnel, err := newTillerPortForwarder(tillerNamespace, kubeContext) tunnel, err := newTillerPortForwarder(environment.TillerNamespace, kubeContext)
if err != nil { if err != nil {
return err return err
} }
...@@ -199,12 +199,12 @@ func homePath() string { ...@@ -199,12 +199,12 @@ func homePath() string {
// getKubeClient is a convenience method for creating kubernetes config and client // getKubeClient is a convenience method for creating kubernetes config and client
// for a given kubeconfig context // for a given kubeconfig context
func getKubeClient(context string) (*restclient.Config, *unversioned.Client, error) { func getKubeClient(context string) (*restclient.Config, *internalclientset.Clientset, error) {
config, err := kube.GetConfig(context).ClientConfig() config, err := kube.GetConfig(context).ClientConfig()
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("could not get kubernetes config for context '%s': %s", context, err) return nil, nil, fmt.Errorf("could not get kubernetes config for context '%s': %s", context, err)
} }
client, err := unversioned.New(config) client, err := internalclientset.NewForConfig(config)
if err != nil { if err != nil {
return nil, nil, fmt.Errorf("could not get kubernetes client: %s", err) return nil, nil, fmt.Errorf("could not get kubernetes client: %s", err)
} }
......
...@@ -24,11 +24,12 @@ import ( ...@@ -24,11 +24,12 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
kerrors "k8s.io/kubernetes/pkg/api/errors" kerrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned" extensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion"
"k8s.io/helm/cmd/helm/helmpath" "k8s.io/helm/cmd/helm/helmpath"
"k8s.io/helm/cmd/helm/installer" "k8s.io/helm/cmd/helm/installer"
"k8s.io/helm/pkg/repo" "k8s.io/helm/pkg/repo"
"k8s.io/helm/pkg/tiller/environment"
) )
const initDesc = ` const initDesc = `
...@@ -65,15 +66,17 @@ type initCmd struct { ...@@ -65,15 +66,17 @@ type initCmd struct {
image string image string
clientOnly bool clientOnly bool
canary bool canary bool
namespace string
dryRun bool dryRun bool
out io.Writer out io.Writer
home helmpath.Home home helmpath.Home
kubeClient unversioned.DeploymentsNamespacer kubeClient extensionsclient.DeploymentsGetter
} }
func newInitCmd(out io.Writer) *cobra.Command { func newInitCmd(out io.Writer) *cobra.Command {
i := &initCmd{ i := &initCmd{
out: out, out: out,
namespace: environment.TillerNamespace,
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
...@@ -102,7 +105,7 @@ func newInitCmd(out io.Writer) *cobra.Command { ...@@ -102,7 +105,7 @@ func newInitCmd(out io.Writer) *cobra.Command {
func (i *initCmd) run() error { func (i *initCmd) run() error {
if flagDebug { if flagDebug {
m, err := installer.DeploymentManifest(i.image, i.canary) m, err := installer.DeploymentManifest(i.namespace, i.image, i.canary)
if err != nil { if err != nil {
return err return err
} }
...@@ -124,7 +127,7 @@ func (i *initCmd) run() error { ...@@ -124,7 +127,7 @@ func (i *initCmd) run() error {
} }
i.kubeClient = c i.kubeClient = c
} }
if err := installer.Install(i.kubeClient, tillerNamespace, i.image, i.canary, flagDebug); err != nil { if err := installer.Install(i.kubeClient, i.namespace, i.image, i.canary, flagDebug); err != nil {
if !kerrors.IsAlreadyExists(err) { if !kerrors.IsAlreadyExists(err) {
return fmt.Errorf("error installing: %s", err) return fmt.Errorf("error installing: %s", err)
} }
......
...@@ -27,7 +27,9 @@ import ( ...@@ -27,7 +27,9 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned/testclient" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
testcore "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/helm/cmd/helm/helmpath" "k8s.io/helm/cmd/helm/helmpath"
...@@ -41,14 +43,19 @@ func TestInitCmd(t *testing.T) { ...@@ -41,14 +43,19 @@ func TestInitCmd(t *testing.T) {
defer os.Remove(home) defer os.Remove(home)
var buf bytes.Buffer var buf bytes.Buffer
fake := testclient.Fake{} fc := fake.NewSimpleClientset()
cmd := &initCmd{out: &buf, home: helmpath.Home(home), kubeClient: fake.Extensions()} cmd := &initCmd{
out: &buf,
home: helmpath.Home(home),
kubeClient: fc.Extensions(),
namespace: api.NamespaceDefault,
}
if err := cmd.run(); err != nil { if err := cmd.run(); err != nil {
t.Errorf("expected error: %v", err) t.Errorf("expected error: %v", err)
} }
actions := fake.Actions() action := fc.Actions()[0]
if action, ok := actions[0].(testclient.CreateAction); !ok || action.GetResource() != "deployments" { if !action.Matches("create", "deployments") {
t.Errorf("unexpected action: %v, expected create deployment", actions[0]) t.Errorf("unexpected action: %v, expected create deployment", action)
} }
expected := "Tiller (the helm server side component) has been installed into your Kubernetes Cluster." expected := "Tiller (the helm server side component) has been installed into your Kubernetes Cluster."
if !strings.Contains(buf.String(), expected) { if !strings.Contains(buf.String(), expected) {
...@@ -64,11 +71,21 @@ func TestInitCmd_exsits(t *testing.T) { ...@@ -64,11 +71,21 @@ func TestInitCmd_exsits(t *testing.T) {
defer os.Remove(home) defer os.Remove(home)
var buf bytes.Buffer var buf bytes.Buffer
fake := testclient.Fake{} fc := fake.NewSimpleClientset(&extensions.Deployment{
fake.AddReactor("*", "*", func(action testclient.Action) (bool, runtime.Object, error) { ObjectMeta: api.ObjectMeta{
Namespace: api.NamespaceDefault,
Name: "tiller-deploy",
},
})
fc.AddReactor("*", "*", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, errors.NewAlreadyExists(api.Resource("deployments"), "1") return true, nil, errors.NewAlreadyExists(api.Resource("deployments"), "1")
}) })
cmd := &initCmd{out: &buf, home: helmpath.Home(home), kubeClient: fake.Extensions()} cmd := &initCmd{
out: &buf,
home: helmpath.Home(home),
kubeClient: fc.Extensions(),
namespace: api.NamespaceDefault,
}
if err := cmd.run(); err != nil { if err := cmd.run(); err != nil {
t.Errorf("expected error: %v", err) t.Errorf("expected error: %v", err)
} }
...@@ -86,12 +103,18 @@ func TestInitCmd_clientOnly(t *testing.T) { ...@@ -86,12 +103,18 @@ func TestInitCmd_clientOnly(t *testing.T) {
defer os.Remove(home) defer os.Remove(home)
var buf bytes.Buffer var buf bytes.Buffer
fake := testclient.Fake{} fc := fake.NewSimpleClientset()
cmd := &initCmd{out: &buf, home: helmpath.Home(home), kubeClient: fake.Extensions(), clientOnly: true} cmd := &initCmd{
out: &buf,
home: helmpath.Home(home),
kubeClient: fc.Extensions(),
clientOnly: true,
namespace: api.NamespaceDefault,
}
if err := cmd.run(); err != nil { if err := cmd.run(); err != nil {
t.Errorf("unexpected error: %v", err) t.Errorf("unexpected error: %v", err)
} }
if len(fake.Actions()) != 0 { if len(fc.Actions()) != 0 {
t.Error("expected client call") t.Error("expected client call")
} }
expected := "Not installing tiller due to 'client-only' flag having been set" expected := "Not installing tiller due to 'client-only' flag having been set"
...@@ -114,18 +137,19 @@ func TestInitCmd_dryRun(t *testing.T) { ...@@ -114,18 +137,19 @@ func TestInitCmd_dryRun(t *testing.T) {
}() }()
var buf bytes.Buffer var buf bytes.Buffer
fake := testclient.Fake{} fc := fake.NewSimpleClientset()
cmd := &initCmd{ cmd := &initCmd{
out: &buf, out: &buf,
home: helmpath.Home(home), home: helmpath.Home(home),
kubeClient: fake.Extensions(), kubeClient: fc.Extensions(),
clientOnly: true, clientOnly: true,
dryRun: true, dryRun: true,
namespace: api.NamespaceDefault,
} }
if err := cmd.run(); err != nil { if err := cmd.run(); err != nil {
t.Fatal(err) t.Fatal(err)
} }
if len(fake.Actions()) != 0 { if len(fc.Actions()) != 0 {
t.Error("expected no server calls") t.Error("expected no server calls")
} }
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned" extensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/helm/pkg/version" "k8s.io/helm/pkg/version"
...@@ -37,27 +37,27 @@ const defaultImage = "gcr.io/kubernetes-helm/tiller" ...@@ -37,27 +37,27 @@ const defaultImage = "gcr.io/kubernetes-helm/tiller"
// command failed. // command failed.
// //
// If verbose is true, this will print the manifest to stdout. // If verbose is true, this will print the manifest to stdout.
func Install(client unversioned.DeploymentsNamespacer, namespace, image string, canary, verbose bool) error { func Install(client extensionsclient.DeploymentsGetter, namespace, image string, canary, verbose bool) error {
obj := deployment(image, canary) obj := deployment(namespace, image, canary)
_, err := client.Deployments(namespace).Create(obj) _, err := client.Deployments(obj.Namespace).Create(obj)
return err return err
} }
// deployment gets the deployment object that installs Tiller. // deployment gets the deployment object that installs Tiller.
func deployment(image string, canary bool) *extensions.Deployment { func deployment(namespace, image string, canary bool) *extensions.Deployment {
switch { switch {
case canary: case canary:
image = defaultImage + ":canary" image = defaultImage + ":canary"
case image == "": case image == "":
image = fmt.Sprintf("%s:%s", defaultImage, version.Version) image = fmt.Sprintf("%s:%s", defaultImage, version.Version)
} }
return generateDeployment(image) return generateDeployment(namespace, image)
} }
// DeploymentManifest gets the manifest (as a string) that describes the Tiller Deployment // DeploymentManifest gets the manifest (as a string) that describes the Tiller Deployment
// resource. // resource.
func DeploymentManifest(image string, canary bool) (string, error) { func DeploymentManifest(namespace, image string, canary bool) (string, error) {
obj := deployment(image, canary) obj := deployment(namespace, image, canary)
buf, err := yaml.Marshal(obj) buf, err := yaml.Marshal(obj)
return string(buf), err return string(buf), err
...@@ -68,12 +68,13 @@ func generateLabels(labels map[string]string) map[string]string { ...@@ -68,12 +68,13 @@ func generateLabels(labels map[string]string) map[string]string {
return labels return labels
} }
func generateDeployment(image string) *extensions.Deployment { func generateDeployment(namespace, image string) *extensions.Deployment {
labels := generateLabels(map[string]string{"name": "tiller"}) labels := generateLabels(map[string]string{"name": "tiller"})
d := &extensions.Deployment{ d := &extensions.Deployment{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "tiller-deploy", Namespace: namespace,
Labels: labels, Name: "tiller-deploy",
Labels: labels,
}, },
Spec: extensions.DeploymentSpec{ Spec: extensions.DeploymentSpec{
Replicas: 1, Replicas: 1,
......
...@@ -21,12 +21,13 @@ import ( ...@@ -21,12 +21,13 @@ import (
"testing" "testing"
"github.com/ghodss/yaml" "github.com/ghodss/yaml"
"k8s.io/kubernetes/pkg/api"
"k8s.io/helm/pkg/version"
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/unversioned/testclient" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
testcore "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
"k8s.io/helm/pkg/version"
) )
func TestDeploymentManifest(t *testing.T) { func TestDeploymentManifest(t *testing.T) {
...@@ -44,7 +45,7 @@ func TestDeploymentManifest(t *testing.T) { ...@@ -44,7 +45,7 @@ func TestDeploymentManifest(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
o, err := DeploymentManifest(tt.image, tt.canary) o, err := DeploymentManifest(api.NamespaceDefault, tt.image, tt.canary)
if err != nil { if err != nil {
t.Fatalf("%s: error %q", tt.name, err) t.Fatalf("%s: error %q", tt.name, err)
} }
...@@ -62,9 +63,9 @@ func TestDeploymentManifest(t *testing.T) { ...@@ -62,9 +63,9 @@ func TestDeploymentManifest(t *testing.T) {
func TestInstall(t *testing.T) { func TestInstall(t *testing.T) {
image := "gcr.io/kubernetes-helm/tiller:v2.0.0" image := "gcr.io/kubernetes-helm/tiller:v2.0.0"
fake := testclient.Fake{} fake := fake.NewSimpleClientset()
fake.AddReactor("create", "deployments", func(action testclient.Action) (bool, runtime.Object, error) { fake.AddReactor("create", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
obj := action.(testclient.CreateAction).GetObject().(*extensions.Deployment) obj := action.(testcore.CreateAction).GetObject().(*extensions.Deployment)
l := obj.GetLabels() l := obj.GetLabels()
if reflect.DeepEqual(l, map[string]string{"app": "helm"}) { if reflect.DeepEqual(l, map[string]string{"app": "helm"}) {
t.Errorf("expected labels = '', got '%s'", l) t.Errorf("expected labels = '', got '%s'", l)
...@@ -76,16 +77,16 @@ func TestInstall(t *testing.T) { ...@@ -76,16 +77,16 @@ func TestInstall(t *testing.T) {
return true, obj, nil return true, obj, nil
}) })
err := Install(fake.Extensions(), "default", image, false, false) err := Install(fake.Extensions(), api.NamespaceDefault, image, false, false)
if err != nil { if err != nil {
t.Errorf("unexpected error: %#+v", err) t.Errorf("unexpected error: %#+v", err)
} }
} }
func TestInstall_canary(t *testing.T) { func TestInstall_canary(t *testing.T) {
fake := testclient.Fake{} fake := fake.NewSimpleClientset()
fake.AddReactor("create", "deployments", func(action testclient.Action) (bool, runtime.Object, error) { fake.AddReactor("create", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
obj := action.(testclient.CreateAction).GetObject().(*extensions.Deployment) obj := action.(testcore.CreateAction).GetObject().(*extensions.Deployment)
i := obj.Spec.Template.Spec.Containers[0].Image i := obj.Spec.Template.Spec.Containers[0].Image
if i != "gcr.io/kubernetes-helm/tiller:canary" { if i != "gcr.io/kubernetes-helm/tiller:canary" {
t.Errorf("expected canary image, got '%s'", i) t.Errorf("expected canary image, got '%s'", i)
...@@ -93,7 +94,7 @@ func TestInstall_canary(t *testing.T) { ...@@ -93,7 +94,7 @@ func TestInstall_canary(t *testing.T) {
return true, obj, nil return true, obj, nil
}) })
err := Install(fake.Extensions(), "default", "", true, false) err := Install(fake.Extensions(), api.NamespaceDefault, "", true, false)
if err != nil { if err != nil {
t.Errorf("unexpected error: %#+v", err) t.Errorf("unexpected error: %#+v", err)
} }
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/labels"
"k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/kube"
...@@ -35,16 +35,16 @@ func newTillerPortForwarder(namespace, context string) (*kube.Tunnel, error) { ...@@ -35,16 +35,16 @@ func newTillerPortForwarder(namespace, context string) (*kube.Tunnel, error) {
return nil, err return nil, err
} }
podName, err := getTillerPodName(client, namespace) podName, err := getTillerPodName(client.Core(), namespace)
if err != nil { if err != nil {
return nil, err return nil, err
} }
const tillerPort = 44134 const tillerPort = 44134
t := kube.NewTunnel(client.RESTClient, config, namespace, podName, tillerPort) t := kube.NewTunnel(client.Core().RESTClient(), config, namespace, podName, tillerPort)
return t, t.ForwardPort() return t, t.ForwardPort()
} }
func getTillerPodName(client unversioned.PodsNamespacer, namespace string) (string, error) { func getTillerPodName(client internalversion.PodsGetter, namespace string) (string, error) {
// TODO use a const for labels // TODO use a const for labels
selector := labels.Set{"app": "helm", "name": "tiller"}.AsSelector() selector := labels.Set{"app": "helm", "name": "tiller"}.AsSelector()
pod, err := getFirstRunningPod(client, namespace, selector) pod, err := getFirstRunningPod(client, namespace, selector)
...@@ -54,7 +54,7 @@ func getTillerPodName(client unversioned.PodsNamespacer, namespace string) (stri ...@@ -54,7 +54,7 @@ func getTillerPodName(client unversioned.PodsNamespacer, namespace string) (stri
return pod.ObjectMeta.GetName(), nil return pod.ObjectMeta.GetName(), nil
} }
func getFirstRunningPod(client unversioned.PodsNamespacer, namespace string, selector labels.Selector) (*api.Pod, error) { func getFirstRunningPod(client internalversion.PodsGetter, namespace string, selector labels.Selector) (*api.Pod, error) {
options := api.ListOptions{LabelSelector: selector} options := api.ListOptions{LabelSelector: selector}
pods, err := client.Pods(namespace).List(options) pods, err := client.Pods(namespace).List(options)
if err != nil { if err != nil {
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"testing" "testing"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/unversioned/testclient" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
) )
func mockTillerPod() api.Pod { func mockTillerPod() api.Pod {
...@@ -74,8 +74,8 @@ func TestGetFirstPod(t *testing.T) { ...@@ -74,8 +74,8 @@ func TestGetFirstPod(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
client := testclient.NewSimpleFake(&api.PodList{Items: tt.pods}) client := fake.NewSimpleClientset(&api.PodList{Items: tt.pods})
name, err := getTillerPodName(client, api.NamespaceDefault) name, err := getTillerPodName(client.Core(), api.NamespaceDefault)
if (err != nil) != tt.err { if (err != nil) != tt.err {
t.Errorf("%q. expected error: %v, got %v", tt.name, tt.err, err) t.Errorf("%q. expected error: %v, got %v", tt.name, tt.err, err)
} }
......
...@@ -84,11 +84,11 @@ func start(c *cobra.Command, args []string) { ...@@ -84,11 +84,11 @@ func start(c *cobra.Command, args []string) {
case storageMemory: case storageMemory:
env.Releases = storage.Init(driver.NewMemory()) env.Releases = storage.Init(driver.NewMemory())
case storageConfigMap: case storageConfigMap:
c, err := env.KubeClient.APIClient() c, err := env.KubeClient.ClientSet()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "Cannot initialize Kubernetes connection: %s", err) fmt.Fprintf(os.Stderr, "Cannot initialize Kubernetes connection: %s", err)
} }
env.Releases = storage.Init(driver.NewConfigMaps(c.ConfigMaps(environment.TillerNamespace))) env.Releases = storage.Init(driver.NewConfigMaps(c.Core().ConfigMaps(environment.TillerNamespace)))
} }
lstn, err := net.Listen("tcp", grpcAddr) lstn, err := net.Listen("tcp", grpcAddr)
......
This diff is collapsed.
...@@ -5,6 +5,9 @@ import: ...@@ -5,6 +5,9 @@ import:
subpackages: subpackages:
- context - context
- package: github.com/spf13/cobra - package: github.com/spf13/cobra
version: f62e98d28ab7ad31d707ba837a966378465c7b57
- package: github.com/spf13/pflag
version: 5ccb023bc27df288a957c5e994cd44fd19619465
- package: github.com/Masterminds/sprig - package: github.com/Masterminds/sprig
version: ^2.7 version: ^2.7
- package: github.com/ghodss/yaml - package: github.com/ghodss/yaml
...@@ -20,29 +23,7 @@ import: ...@@ -20,29 +23,7 @@ import:
- package: google.golang.org/grpc - package: google.golang.org/grpc
version: 1.0.3 version: 1.0.3
- package: k8s.io/kubernetes - package: k8s.io/kubernetes
version: ~1.4.1 version: 1.5.0-beta.2
subpackages:
- pkg/api
- pkg/api/errors
- pkg/api/unversioned
- pkg/apimachinery/registered
- pkg/apis/batch
- pkg/apis/extensions
- pkg/client/restclient
- pkg/client/unversioned
- pkg/client/unversioned/clientcmd
- pkg/client/unversioned/portforward
- pkg/client/unversioned/remotecommand
- pkg/client/unversioned/testclient
- pkg/kubectl
- pkg/kubectl/cmd/util
- pkg/kubectl/resource
- pkg/labels
- pkg/runtime
- pkg/util/intstr
- pkg/util/strategicpatch
- pkg/util/yaml
- pkg/watch
- package: github.com/gosuri/uitable - package: github.com/gosuri/uitable
- package: github.com/asaskevich/govalidator - package: github.com/asaskevich/govalidator
version: ^4.0.0 version: ^4.0.0
......
...@@ -30,7 +30,6 @@ import ( ...@@ -30,7 +30,6 @@ import (
"k8s.io/kubernetes/pkg/api/errors" "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/apimachinery/registered" "k8s.io/kubernetes/pkg/apimachinery/registered"
"k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd" "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
...@@ -46,7 +45,7 @@ var ErrNoObjectsVisited = goerrors.New("no objects visited") ...@@ -46,7 +45,7 @@ var ErrNoObjectsVisited = goerrors.New("no objects visited")
// Client represents a client capable of communicating with the Kubernetes API. // Client represents a client capable of communicating with the Kubernetes API.
type Client struct { type Client struct {
*cmdutil.Factory cmdutil.Factory
// IncludeThirdPartyAPIs indicates whether to load "dynamic" APIs. // IncludeThirdPartyAPIs indicates whether to load "dynamic" APIs.
// //
// This requires additional calls to the Kubernetes API server, and these calls // This requires additional calls to the Kubernetes API server, and these calls
...@@ -82,16 +81,6 @@ func (e ErrAlreadyExists) Error() string { ...@@ -82,16 +81,6 @@ func (e ErrAlreadyExists) Error() string {
return fmt.Sprintf("Looks like there are no changes for %s", e.errorMsg) return fmt.Sprintf("Looks like there are no changes for %s", e.errorMsg)
} }
// APIClient returns a Kubernetes API client.
//
// This is necessary because cmdutil.Client is a field, not a method, which
// means it can't satisfy an interface's method requirement. In order to ensure
// that an implementation of environment.KubeClient can access the raw API client,
// it is necessary to add this method.
func (c *Client) APIClient() (unversioned.Interface, error) {
return c.Client()
}
// Create creates kubernetes resources from an io.reader // Create creates kubernetes resources from an io.reader
// //
// Namespace will set the namespace // Namespace will set the namespace
...@@ -107,7 +96,7 @@ func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Builde ...@@ -107,7 +96,7 @@ func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Builde
if err != nil { if err != nil {
log.Printf("warning: failed to load schema: %s", err) log.Printf("warning: failed to load schema: %s", err)
} }
return c.NewBuilder(c.IncludeThirdPartyAPIs). return c.NewBuilder().
ContinueOnError(). ContinueOnError().
Schema(schema). Schema(schema).
NamespaceParam(namespace). NamespaceParam(namespace).
...@@ -414,7 +403,7 @@ func waitForJob(e watch.Event, name string) (bool, error) { ...@@ -414,7 +403,7 @@ func waitForJob(e watch.Event, name string) (bool, error) {
} }
func (c *Client) ensureNamespace(namespace string) error { func (c *Client) ensureNamespace(namespace string) error {
client, err := c.Client() client, err := c.ClientSet()
if err != nil { if err != nil {
return err return err
} }
......
...@@ -30,7 +30,8 @@ import ( ...@@ -30,7 +30,8 @@ import (
"k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/api/unversioned"
api "k8s.io/kubernetes/pkg/api/v1" api "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/api/validation" "k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/client/unversioned/fake" "k8s.io/kubernetes/pkg/client/restclient/fake"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
"k8s.io/kubernetes/pkg/kubectl/resource" "k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime" "k8s.io/kubernetes/pkg/runtime"
) )
...@@ -110,20 +111,18 @@ func TestPerform(t *testing.T) { ...@@ -110,20 +111,18 @@ func TestPerform(t *testing.T) {
return nil return nil
} }
c := New(nil) f, tf, _, _ := cmdtesting.NewAPIFactory()
c.IncludeThirdPartyAPIs = false c := &Client{Factory: f}
c.ClientForMapping = func(mapping *meta.RESTMapping) (resource.RESTClient, error) { if tt.swaggerFile != "" {
return &fake.RESTClient{}, nil
}
c.Validator = func(validate bool, cacheDir string) (validation.Schema, error) {
if tt.swaggerFile == "" {
return validation.NullSchema{}, nil
}
data, err := ioutil.ReadFile(tt.swaggerFile) data, err := ioutil.ReadFile(tt.swaggerFile)
if err != nil {
t.Fatalf("could not read swagger spec: %s", err)
}
validator, err := validation.NewSwaggerSchemaFromBytes(data, nil)
if err != nil { if err != nil {
t.Fatalf("could not load swagger spec: %s", err) t.Fatalf("could not load swagger spec: %s", err)
} }
return validation.NewSwaggerSchemaFromBytes(data, nil) tf.Validator = validator
} }
err := perform(c, tt.namespace, tt.reader, fn) err := perform(c, tt.namespace, tt.reader, fn)
......
...@@ -38,11 +38,11 @@ type Tunnel struct { ...@@ -38,11 +38,11 @@ type Tunnel struct {
stopChan chan struct{} stopChan chan struct{}
readyChan chan struct{} readyChan chan struct{}
config *restclient.Config config *restclient.Config
client *restclient.RESTClient client restclient.Interface
} }
// NewTunnel creates a new tunnel // NewTunnel creates a new tunnel
func NewTunnel(client *restclient.RESTClient, config *restclient.Config, namespace, podName string, remote int) *Tunnel { func NewTunnel(client restclient.Interface, config *restclient.Config, namespace, podName string, remote int) *Tunnel {
return &Tunnel{ return &Tunnel{
config: config, config: config,
client: client, client: client,
......
...@@ -27,13 +27,12 @@ import ( ...@@ -27,13 +27,12 @@ import (
"time" "time"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
kberrs "k8s.io/kubernetes/pkg/api/errors" kberrs "k8s.io/kubernetes/pkg/api/errors"
client "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
kblabels "k8s.io/kubernetes/pkg/labels" kblabels "k8s.io/kubernetes/pkg/labels"
rspb "k8s.io/helm/pkg/proto/hapi/release"
) )
var _ Driver = (*ConfigMaps)(nil) var _ Driver = (*ConfigMaps)(nil)
...@@ -48,12 +47,12 @@ var magicGzip = []byte{0x1f, 0x8b, 0x08} ...@@ -48,12 +47,12 @@ var magicGzip = []byte{0x1f, 0x8b, 0x08}
// ConfigMaps is a wrapper around an implementation of a kubernetes // ConfigMaps is a wrapper around an implementation of a kubernetes
// ConfigMapsInterface. // ConfigMapsInterface.
type ConfigMaps struct { type ConfigMaps struct {
impl client.ConfigMapsInterface impl internalversion.ConfigMapInterface
} }
// NewConfigMaps initializes a new ConfigMaps wrapping an implmenetation of // NewConfigMaps initializes a new ConfigMaps wrapping an implmenetation of
// the kubernetes ConfigMapsInterface. // the kubernetes ConfigMapsInterface.
func NewConfigMaps(impl client.ConfigMapsInterface) *ConfigMaps { func NewConfigMaps(impl internalversion.ConfigMapInterface) *ConfigMaps {
return &ConfigMaps{impl: impl} return &ConfigMaps{impl: impl}
} }
...@@ -210,7 +209,7 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) { ...@@ -210,7 +209,7 @@ func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) {
return nil, err return nil, err
} }
// delete the release // delete the release
if err = cfgmaps.impl.Delete(key); err != nil { if err = cfgmaps.impl.Delete(key, &api.DeleteOptions{}); err != nil {
return rls, err return rls, err
} }
return rls, nil return rls, nil
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
rspb "k8s.io/helm/pkg/proto/hapi/release" rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/api"
kberrs "k8s.io/kubernetes/pkg/api/errors" kberrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
) )
func releaseStub(name string, vers int32, code rspb.Status_Code) *rspb.Release { func releaseStub(name string, vers int32, code rspb.Status_Code) *rspb.Release {
...@@ -73,7 +73,7 @@ func newTestFixtureCfgMaps(t *testing.T, releases ...*rspb.Release) *ConfigMaps ...@@ -73,7 +73,7 @@ func newTestFixtureCfgMaps(t *testing.T, releases ...*rspb.Release) *ConfigMaps
// MockConfigMapsInterface mocks a kubernetes ConfigMapsInterface // MockConfigMapsInterface mocks a kubernetes ConfigMapsInterface
type MockConfigMapsInterface struct { type MockConfigMapsInterface struct {
unversioned.ConfigMapsInterface internalversion.ConfigMapInterface
objects map[string]*api.ConfigMap objects map[string]*api.ConfigMap
} }
...@@ -132,7 +132,7 @@ func (mock *MockConfigMapsInterface) Update(cfgmap *api.ConfigMap) (*api.ConfigM ...@@ -132,7 +132,7 @@ func (mock *MockConfigMapsInterface) Update(cfgmap *api.ConfigMap) (*api.ConfigM
} }
// Delete deletes a ConfigMap by name. // Delete deletes a ConfigMap by name.
func (mock *MockConfigMapsInterface) Delete(name string) error { func (mock *MockConfigMapsInterface) Delete(name string, opts *api.DeleteOptions) error {
if _, ok := mock.objects[name]; !ok { if _, ok := mock.objects[name]; !ok {
return kberrs.NewNotFound(api.Resource("tests"), name) return kberrs.NewNotFound(api.Resource("tests"), name)
} }
......
...@@ -25,14 +25,14 @@ package environment ...@@ -25,14 +25,14 @@ package environment
import ( import (
"io" "io"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/engine" "k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/kube" "k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/storage" "k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver" "k8s.io/helm/pkg/storage/driver"
"k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
) )
// TillerNamespace is the namespace tiller is running in. // TillerNamespace is the namespace tiller is running in.
...@@ -135,8 +135,8 @@ type KubeClient interface { ...@@ -135,8 +135,8 @@ type KubeClient interface {
// by "\n---\n"). // by "\n---\n").
Update(namespace string, originalReader, modifiedReader io.Reader) error Update(namespace string, originalReader, modifiedReader io.Reader) error
// APIClient gets a raw API client for Kubernetes. // Client gets a raw API client for Kubernetes.
APIClient() (unversioned.Interface, error) ClientSet() (*internalclientset.Clientset, error)
} }
// PrintingKubeClient implements KubeClient, but simply prints the reader to // PrintingKubeClient implements KubeClient, but simply prints the reader to
...@@ -145,12 +145,12 @@ type PrintingKubeClient struct { ...@@ -145,12 +145,12 @@ type PrintingKubeClient struct {
Out io.Writer Out io.Writer
} }
// APIClient always returns an error. // ClientSet always returns an error.
// //
// The printing client does not have access to a Kubernetes client at all. So it // The printing client does not have access to a Kubernetes client at all. So it
// will always return an error if the client is accessed. // will always return an error if the client is accessed.
func (p *PrintingKubeClient) APIClient() (unversioned.Interface, error) { func (p *PrintingKubeClient) ClientSet() (*internalclientset.Clientset, error) {
return testclient.NewSimpleFake(), nil return new(internalclientset.Clientset), nil
} }
// Create prints the values of what would be created with a real KubeClient. // Create prints the values of what would be created with a real KubeClient.
......
...@@ -23,8 +23,7 @@ import ( ...@@ -23,8 +23,7 @@ import (
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
unversionedclient "k8s.io/kubernetes/pkg/client/unversioned" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/unversioned/testclient"
) )
type mockEngine struct { type mockEngine struct {
...@@ -35,11 +34,10 @@ func (e *mockEngine) Render(chrt *chart.Chart, v chartutil.Values) (map[string]s ...@@ -35,11 +34,10 @@ func (e *mockEngine) Render(chrt *chart.Chart, v chartutil.Values) (map[string]s
return e.out, nil return e.out, nil
} }
type mockKubeClient struct { type mockKubeClient struct{}
}
func (k *mockKubeClient) APIClient() (unversionedclient.Interface, error) { func (k *mockKubeClient) ClientSet() (*internalclientset.Clientset, error) {
return testclient.NewSimpleFake(), nil return &internalclientset.Clientset{}, nil
} }
func (k *mockKubeClient) Create(ns string, r io.Reader) error { func (k *mockKubeClient) Create(ns string, r io.Reader) error {
......
...@@ -695,13 +695,18 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re ...@@ -695,13 +695,18 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re
func (s *ReleaseServer) getVersionSet() (versionSet, error) { func (s *ReleaseServer) getVersionSet() (versionSet, error) {
defVersions := newVersionSet("v1") defVersions := newVersionSet("v1")
cli, err := s.env.KubeClient.APIClient() cli, err := s.env.KubeClient.ClientSet()
if err != nil { if err != nil {
log.Printf("API Client for Kubernetes is missing: %s.", err) log.Printf("discovery client for Kubernetes is missing: %s.", err)
return defVersions, err return defVersions, err
} }
groups, err := cli.Discovery().ServerGroups() dc := cli.Discovery()
if dc.RESTClient() == nil {
return defVersions, nil
}
groups, err := dc.ServerGroups()
if err != nil { if err != nil {
return defVersions, err return defVersions, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment