Commit 85c41ef1 authored by Adam Reese's avatar Adam Reese

ref(*): kubernetes v1.6

Rebase on kubernetes v1.6
parent e89e6af0
......@@ -119,5 +119,6 @@ ifndef HAS_GIT
endif
glide install --strip-vendor
go build -o bin/protoc-gen-go ./vendor/github.com/golang/protobuf/protoc-gen-go
scripts/setup-apimachinery.sh
include versioning.mk
......@@ -29,8 +29,8 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/helmpath"
......@@ -258,7 +258,7 @@ func defaultTillerNamespace() string {
// getKubeClient is a convenience method for creating kubernetes config and client
// for a given kubeconfig context
func getKubeClient(context string) (*restclient.Config, *internalclientset.Clientset, error) {
func getKubeClient(context string) (*rest.Config, *internalclientset.Clientset, error) {
config, err := kube.GetConfig(context).ClientConfig()
if err != nil {
return nil, nil, fmt.Errorf("could not get kubernetes config for context '%s': %s", context, err)
......@@ -270,12 +270,6 @@ func getKubeClient(context string) (*restclient.Config, *internalclientset.Clien
return config, client, nil
}
// getKubeCmd is a convenience method for creating kubernetes cmd client
// for a given kubeconfig context
func getKubeCmd(context string) *kube.Client {
return kube.New(kube.GetConfig(context))
}
// ensureHelmClient returns a new helm client impl. if h is not nil.
func ensureHelmClient(h helm.Interface) helm.Interface {
if h != nil {
......
......@@ -23,7 +23,7 @@ import (
"os"
"github.com/spf13/cobra"
kerrors "k8s.io/kubernetes/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/helm/cmd/helm/installer"
......@@ -226,7 +226,7 @@ func (i *initCmd) run() error {
i.kubeClient = c
}
if err := installer.Install(i.kubeClient, &i.opts); err != nil {
if !kerrors.IsAlreadyExists(err) {
if !apierrors.IsAlreadyExists(err) {
return fmt.Errorf("error installing: %s", err)
}
if i.upgrade {
......
......@@ -25,12 +25,13 @@ import (
"github.com/ghodss/yaml"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
testcore "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"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/helm/pkg/helm/helmpath"
)
......@@ -78,13 +79,13 @@ func TestInitCmd_exists(t *testing.T) {
var buf bytes.Buffer
fc := fake.NewSimpleClientset(&extensions.Deployment{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Namespace: api.NamespaceDefault,
Name: "tiller-deploy",
},
})
fc.PrependReactor("*", "*", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, errors.NewAlreadyExists(api.Resource("deployments"), "1")
return true, nil, apierrors.NewAlreadyExists(api.Resource("deployments"), "1")
})
cmd := &initCmd{
out: &buf,
......
......@@ -20,13 +20,14 @@ import (
"io/ioutil"
"github.com/ghodss/yaml"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api"
kerrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
extensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion"
"k8s.io/kubernetes/pkg/util/intstr"
)
// Install uses kubernetes client to install tiller.
......@@ -51,7 +52,7 @@ func Install(client internalclientset.Interface, opts *Options) error {
//
// Returns an error if the command failed.
func Upgrade(client internalclientset.Interface, opts *Options) error {
obj, err := client.Extensions().Deployments(opts.Namespace).Get("tiller-deploy")
obj, err := client.Extensions().Deployments(opts.Namespace).Get(deploymentName, metav1.GetOptions{})
if err != nil {
return err
}
......@@ -62,15 +63,11 @@ func Upgrade(client internalclientset.Interface, opts *Options) error {
}
// If the service does not exists that would mean we are upgrading from a tiller version
// that didn't deploy the service, so install it.
if _, err := client.Core().Services(opts.Namespace).Get("tiller-deploy"); err != nil {
if !kerrors.IsNotFound(err) {
return err
_, err = client.Core().Services(opts.Namespace).Get(serviceName, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return createService(client.Core(), opts.Namespace)
}
if err := createService(client.Core(), opts.Namespace); err != nil {
return err
}
}
return nil
}
// createDeployment creates the Tiller deployment reource
......@@ -122,15 +119,15 @@ func generateLabels(labels map[string]string) map[string]string {
func generateDeployment(opts *Options) *extensions.Deployment {
labels := generateLabels(map[string]string{"name": "tiller"})
d := &extensions.Deployment{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Namespace: opts.Namespace,
Name: "tiller-deploy",
Name: deploymentName,
Labels: labels,
},
Spec: extensions.DeploymentSpec{
Replicas: 1,
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: api.PodSpec{
......@@ -208,9 +205,9 @@ func generateDeployment(opts *Options) *extensions.Deployment {
func generateService(namespace string) *api.Service {
labels := generateLabels(map[string]string{"name": "tiller"})
s := &api.Service{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: "tiller-deploy",
Name: serviceName,
Labels: labels,
},
Spec: api.ServiceSpec{
......@@ -256,7 +253,7 @@ func generateSecret(opts *Options) (*api.Secret, error) {
secret := &api.Secret{
Type: api.SecretTypeOpaque,
Data: make(map[string][]byte),
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Labels: labels,
Namespace: opts.Namespace,
......
......@@ -21,12 +21,12 @@ import (
"testing"
"github.com/ghodss/yaml"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
testcore "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"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/helm/pkg/version"
)
......@@ -206,7 +206,7 @@ func TestUpgrade_serviceNotFound(t *testing.T) {
return true, obj, nil
})
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, errors.NewNotFound(api.Resource("services"), "1")
return true, nil, apierrors.NewNotFound(api.Resource("services"), "1")
})
fc.AddReactor("create", "services", func(action testcore.Action) (bool, runtime.Object, error) {
obj := action.(testcore.CreateAction).GetObject().(*api.Service)
......
......@@ -17,67 +17,45 @@ limitations under the License.
package installer // import "k8s.io/helm/cmd/helm/installer"
import (
"strings"
"github.com/ghodss/yaml"
"k8s.io/kubernetes/pkg/api"
kerrors "k8s.io/kubernetes/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/kubectl"
)
"k8s.io/helm/pkg/kube"
const (
deploymentName = "tiller-deploy"
serviceName = "tiller-deploy"
)
// Uninstall uses kubernetes client to uninstall tiller
func Uninstall(kubeClient internalclientset.Interface, kubeCmd *kube.Client, opts *Options) error {
if _, err := kubeClient.Core().Services(opts.Namespace).Get("tiller-deploy"); err != nil {
if !kerrors.IsNotFound(err) {
func Uninstall(client internalclientset.Interface, opts *Options) error {
if err := deleteService(client.Core(), opts.Namespace); err != nil {
return err
}
} else if err := deleteService(kubeClient.Core(), opts.Namespace); err != nil {
return err
}
if obj, err := kubeClient.Extensions().Deployments(opts.Namespace).Get("tiller-deploy"); err != nil {
if !kerrors.IsNotFound(err) {
return err
}
} else if err := deleteDeployment(kubeCmd, opts.Namespace, obj); err != nil {
return err
}
return nil
return deleteDeployment(client, opts.Namespace)
}
// deleteService deletes the Tiller Service resource
func deleteService(client internalversion.ServicesGetter, namespace string) error {
return client.Services(namespace).Delete("tiller-deploy", &api.DeleteOptions{})
err := client.Services(namespace).Delete(serviceName, &metav1.DeleteOptions{})
return ingoreNotFound(err)
}
// deleteDeployment deletes the Tiller Deployment resource
// We need to use the kubeCmd reaper instead of the kube API because GC for deployment dependents
// We need to use the reaper instead of the kube API because GC for deployment dependents
// is not yet supported at the k8s server level (<= 1.5)
func deleteDeployment(kubeCmd *kube.Client, namespace string, obj *extensions.Deployment) error {
obj.Kind = "Deployment"
obj.APIVersion = "extensions/v1beta1"
buf, err := yaml.Marshal(obj)
if err != nil {
return err
}
reader := strings.NewReader(string(buf))
infos, err := kubeCmd.Build(namespace, reader)
if err != nil {
return err
}
for _, info := range infos {
reaper, err := kubeCmd.Reaper(info.Mapping)
if err != nil {
return err
func deleteDeployment(client internalclientset.Interface, namespace string) error {
reaper, _ := kubectl.ReaperFor(extensions.Kind("Deployment"), client)
err := reaper.Stop(namespace, deploymentName, 0, nil)
return ingoreNotFound(err)
}
func ingoreNotFound(err error) error {
if apierrors.IsNotFound(err) {
return nil
}
err = reaper.Stop(info.Namespace, info.Name, 0, nil)
if err != nil {
return err
}
}
return nil
}
......@@ -18,150 +18,55 @@ package installer // import "k8s.io/helm/cmd/helm/installer"
import (
"testing"
"time"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
testcore "k8s.io/client-go/testing"
"k8s.io/kubernetes/pkg/api"
apierrors "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
testcore "k8s.io/kubernetes/pkg/client/testing/core"
"k8s.io/kubernetes/pkg/kubectl"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/helm/pkg/kube"
)
type fakeReaper struct {
namespace string
name string
}
func (r *fakeReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
r.namespace = namespace
r.name = name
return nil
}
type fakeReaperFactory struct {
cmdutil.Factory
reaper kubectl.Reaper
}
func (f *fakeReaperFactory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) {
return f.reaper, nil
}
func TestUninstall(t *testing.T) {
existingService := service(api.NamespaceDefault)
existingDeployment := deployment(&Options{
Namespace: api.NamespaceDefault,
ImageSpec: "image",
UseCanary: false,
})
fc := &fake.Clientset{}
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, existingService, nil
})
fc.AddReactor("delete", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, nil
})
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
return true, existingDeployment, nil
})
f, _, _, _ := cmdtesting.NewAPIFactory()
r := &fakeReaper{}
rf := &fakeReaperFactory{Factory: f, reaper: r}
kc := &kube.Client{Factory: rf}
opts := &Options{Namespace: api.NamespaceDefault}
if err := Uninstall(fc, kc, opts); err != nil {
if err := Uninstall(fc, opts); err != nil {
t.Errorf("unexpected error: %#+v", err)
}
if actions := fc.Actions(); len(actions) != 3 {
t.Errorf("unexpected actions: %v, expected 3 actions got %d", actions, len(actions))
}
if r.namespace != api.NamespaceDefault {
t.Errorf("unexpected reaper namespace: %s", r.name)
}
if r.name != "tiller-deploy" {
t.Errorf("unexpected reaper name: %s", r.name)
if actions := fc.Actions(); len(actions) != 6 {
t.Errorf("unexpected actions: %v, expected 6 actions got %d", actions, len(actions))
}
}
func TestUninstall_serviceNotFound(t *testing.T) {
existingDeployment := deployment(&Options{Namespace: api.NamespaceDefault, ImageSpec: "imageToReplace", UseCanary: false})
fc := &fake.Clientset{}
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, apierrors.NewNotFound(api.Resource("services"), "1")
})
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
return true, existingDeployment, nil
fc.AddReactor("delete", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, apierrors.NewNotFound(schema.GroupResource{Resource: "services"}, "1")
})
f, _, _, _ := cmdtesting.NewAPIFactory()
r := &fakeReaper{}
rf := &fakeReaperFactory{Factory: f, reaper: r}
kc := &kube.Client{Factory: rf}
opts := &Options{Namespace: api.NamespaceDefault}
if err := Uninstall(fc, kc, opts); err != nil {
if err := Uninstall(fc, opts); err != nil {
t.Errorf("unexpected error: %#+v", err)
}
if actions := fc.Actions(); len(actions) != 2 {
t.Errorf("unexpected actions: %v, expected 2 actions got %d", actions, len(actions))
}
if r.namespace != api.NamespaceDefault {
t.Errorf("unexpected reaper namespace: %s", r.name)
}
if r.name != "tiller-deploy" {
t.Errorf("unexpected reaper name: %s", r.name)
if actions := fc.Actions(); len(actions) != 6 {
t.Errorf("unexpected actions: %v, expected 6 actions got %d", actions, len(actions))
}
}
func TestUninstall_deploymentNotFound(t *testing.T) {
existingService := service(api.NamespaceDefault)
fc := &fake.Clientset{}
fc.AddReactor("get", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, existingService, nil
})
fc.AddReactor("delete", "services", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, nil
})
fc.AddReactor("get", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
fc.AddReactor("delete", "deployments", func(action testcore.Action) (bool, runtime.Object, error) {
return true, nil, apierrors.NewNotFound(api.Resource("deployments"), "1")
})
f, _, _, _ := cmdtesting.NewAPIFactory()
r := &fakeReaper{}
rf := &fakeReaperFactory{Factory: f, reaper: r}
kc := &kube.Client{Factory: rf}
opts := &Options{Namespace: api.NamespaceDefault}
if err := Uninstall(fc, kc, opts); err != nil {
if err := Uninstall(fc, opts); err != nil {
t.Errorf("unexpected error: %#+v", err)
}
if actions := fc.Actions(); len(actions) != 3 {
t.Errorf("unexpected actions: %v, expected 3 actions got %d", actions, len(actions))
}
if r.namespace != "" {
t.Errorf("unexpected reaper namespace: %s", r.name)
}
if r.name != "" {
t.Errorf("unexpected reaper name: %s", r.name)
if actions := fc.Actions(); len(actions) != 6 {
t.Errorf("unexpected actions: %v, expected 6 actions got %d", actions, len(actions))
}
}
......@@ -28,7 +28,6 @@ import (
"k8s.io/helm/cmd/helm/installer"
"k8s.io/helm/pkg/helm"
"k8s.io/helm/pkg/helm/helmpath"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/release"
)
......@@ -46,7 +45,6 @@ type resetCmd struct {
home helmpath.Home
client helm.Interface
kubeClient internalclientset.Interface
kubeCmd *kube.Client
}
func newResetCmd(client helm.Interface, out io.Writer) *cobra.Command {
......@@ -89,9 +87,6 @@ func (d *resetCmd) run() error {
}
d.kubeClient = c
}
if d.kubeCmd == nil {
d.kubeCmd = getKubeCmd(kubeContext)
}
res, err := d.client.ListReleases(
helm.ReleaseListStatuses([]release.Status_Code{release.Status_DEPLOYED}),
......@@ -104,7 +99,7 @@ func (d *resetCmd) run() error {
return fmt.Errorf("There are still %d deployed releases (Tip: use --force).", len(res.Releases))
}
if err := installer.Uninstall(d.kubeClient, d.kubeCmd, &installer.Options{Namespace: d.namespace}); err != nil {
if err := installer.Uninstall(d.kubeClient, &installer.Options{Namespace: d.namespace}); err != nil {
return fmt.Errorf("error unstalling Tiller: %s", err)
}
......
......@@ -54,12 +54,6 @@ func TestResetCmd(t *testing.T) {
if len(actions) != 2 {
t.Errorf("Expected 2 actions, got %d", len(actions))
}
if !actions[0].Matches("get", "services") {
t.Errorf("unexpected action: %v, expected get service", actions[1])
}
if !actions[1].Matches("get", "deployments") {
t.Errorf("unexpected action: %v, expected get deployment", actions[0])
}
expected := "Tiller (the helm server side component) has been uninstalled from your Kubernetes Cluster."
if !strings.Contains(buf.String(), expected) {
t.Errorf("expected %q, got %q", expected, buf.String())
......@@ -94,12 +88,6 @@ func TestResetCmd_removeHelmHome(t *testing.T) {
if len(actions) != 2 {
t.Errorf("Expected 2 actions, got %d", len(actions))
}
if !actions[0].Matches("get", "services") {
t.Errorf("unexpected action: %v, expected get service", actions[1])
}
if !actions[1].Matches("get", "deployments") {
t.Errorf("unexpected action: %v, expected get deployment", actions[0])
}
expected := "Tiller (the helm server side component) has been uninstalled from your Kubernetes Cluster."
if !strings.Contains(buf.String(), expected) {
t.Errorf("expected %q, got %q", expected, buf.String())
......@@ -171,12 +159,6 @@ func TestReset_forceFlag(t *testing.T) {
if len(actions) != 2 {
t.Errorf("Expected 2 actions, got %d", len(actions))
}
if !actions[0].Matches("get", "services") {
t.Errorf("unexpected action: %v, expected get service", actions[1])
}
if !actions[1].Matches("get", "deployments") {
t.Errorf("unexpected action: %v, expected get deployment", actions[0])
}
expected := "Tiller (the helm server side component) has been uninstalled from your Kubernetes Cluster."
if !strings.Contains(buf.String(), expected) {
t.Errorf("expected %q, got %q", expected, buf.String())
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ import:
- package: github.com/spf13/cobra
version: f62e98d28ab7ad31d707ba837a966378465c7b57
- package: github.com/spf13/pflag
version: 5ccb023bc27df288a957c5e994cd44fd19619465
version: 9ff6c6923cfffbcd502984b8e0c80539a94968b7
- package: github.com/Masterminds/vcs
version: ~1.11.0
- package: github.com/Masterminds/sprig
......@@ -24,39 +24,10 @@ import:
- ptypes/timestamp
- package: google.golang.org/grpc
version: 1.0.3
- package: k8s.io/apimachinery
- package: k8s.io/client-go
- package: k8s.io/kubernetes
version: ~1.5.0
subpackages:
- pkg/api
- pkg/api/errors
- pkg/api/meta
- pkg/api/unversioned
- pkg/api/v1
- pkg/apis/apps/v1beta1
- pkg/apis/batch
- pkg/apis/batch/v1
- pkg/apis/extensions
- pkg/apis/extensions/v1beta1
- pkg/client/clientset_generated/internalclientset
- pkg/client/clientset_generated/internalclientset/typed/core/internalversion
- pkg/client/clientset_generated/internalclientset/typed/extensions/internalversion
- pkg/client/restclient
- pkg/client/typed/discovery
- pkg/client/unversioned
- pkg/client/unversioned/clientcmd
- pkg/client/unversioned/portforward
- pkg/client/unversioned/remotecommand
- pkg/fields
- pkg/kubectl
- pkg/kubectl/cmd/util
- pkg/kubectl/resource
- pkg/labels
- pkg/runtime
- pkg/util/intstr
- pkg/util/strategicpatch
- pkg/util/wait
- pkg/version
- pkg/watch
version: ~1.6.0
- package: github.com/gosuri/uitable
- package: github.com/asaskevich/govalidator
version: ^4.0.0
......@@ -71,3 +42,9 @@ import:
version: ~0.1.0
- package: github.com/naoina/go-stringutil
version: ~0.1.0
- package: github.com/chai2010/gettext-go
testImports:
- package: github.com/stretchr/testify
version: ^1.1.4
subpackages:
- assert
......@@ -16,8 +16,8 @@ limitations under the License.
package chartutil
import (
"k8s.io/apimachinery/pkg/version"
tversion "k8s.io/helm/pkg/proto/hapi/version"
"k8s.io/kubernetes/pkg/version"
)
// DefaultVersionSet is the default version set, which includes only Core V1 ("v1").
......
......@@ -22,13 +22,13 @@ import (
"compress/gzip"
"errors"
"fmt"
"github.com/facebookgo/symwalk"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/facebookgo/symwalk"
"github.com/golang/protobuf/ptypes/any"
"k8s.io/helm/pkg/ignore"
......
......@@ -25,10 +25,10 @@ import (
"github.com/golang/protobuf/ptypes/any"
kversion "k8s.io/apimachinery/pkg/version"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/timeconv"
"k8s.io/helm/pkg/version"
kversion "k8s.io/kubernetes/pkg/version"
)
func TestReadValues(t *testing.T) {
......
......@@ -19,17 +19,18 @@ package portforwarder
import (
"fmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/helm/pkg/kube"
)
// New creates a new and initialized tunnel.
func New(namespace string, client *internalclientset.Clientset, config *restclient.Config) (*kube.Tunnel, error) {
func New(namespace string, client *internalclientset.Clientset, config *rest.Config) (*kube.Tunnel, error) {
podName, err := getTillerPodName(client.Core(), namespace)
if err != nil {
return nil, err
......@@ -50,7 +51,7 @@ func getTillerPodName(client internalversion.PodsGetter, namespace string) (stri
}
func getFirstRunningPod(client internalversion.PodsGetter, namespace string, selector labels.Selector) (*api.Pod, error) {
options := api.ListOptions{LabelSelector: selector}
options := metav1.ListOptions{LabelSelector: selector.String()}
pods, err := client.Pods(namespace).List(options)
if err != nil {
return nil, err
......
......@@ -19,13 +19,14 @@ package portforwarder
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
)
func mockTillerPod() api.Pod {
return api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: "orca",
Namespace: api.NamespaceDefault,
Labels: map[string]string{"app": "helm", "name": "tiller"},
......
This diff is collapsed.
......@@ -19,6 +19,7 @@ package kube
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
......@@ -26,19 +27,20 @@ import (
"testing"
"time"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest/fake"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/client/restclient/fake"
"k8s.io/kubernetes/pkg/kubectl"
cmdtesting "k8s.io/kubernetes/pkg/kubectl/cmd/testing"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
"k8s.io/kubernetes/pkg/printers"
watchjson "k8s.io/kubernetes/pkg/watch/json"
)
......@@ -56,7 +58,7 @@ func newPodWithStatus(name string, status api.PodStatus, namespace string) api.P
ns = namespace
}
return api.Pod{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: ns,
SelfLink: "/api/v1/namespaces/default/pods/" + name,
......@@ -80,13 +82,13 @@ func newPodList(names ...string) api.PodList {
return list
}
func notFoundBody() *unversioned.Status {
return &unversioned.Status{
func notFoundBody() *metav1.Status {
return &metav1.Status{
Code: http.StatusNotFound,
Status: unversioned.StatusFailure,
Reason: unversioned.StatusReasonNotFound,
Status: metav1.StatusFailure,
Reason: metav1.StatusReasonNotFound,
Message: " \"\" not found",
Details: &unversioned.StatusDetails{},
Details: &metav1.StatusDetails{},
}
}
......@@ -101,7 +103,7 @@ type fakeReaper struct {
name string
}
func (r *fakeReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
func (r *fakeReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *metav1.DeleteOptions) error {
r.name = name
return nil
}
......@@ -124,7 +126,7 @@ func newEventResponse(code int, e *watch.Event) (*http.Response, error) {
header := http.Header{}
header.Set("Content-Type", runtime.ContentTypeJSON)
body := ioutil.NopCloser(bytes.NewReader(dispatchedEvent))
return &http.Response{StatusCode: 200, Header: header, Body: body}, nil
return &http.Response{StatusCode: code, Header: header, Body: body}, nil
}
func encodeAndMarshalEvent(e *watch.Event) ([]byte, error) {
......@@ -133,12 +135,7 @@ func encodeAndMarshalEvent(e *watch.Event) ([]byte, error) {
return nil, err
}
marshaledEvent, err := json.Marshal(encodedEvent)
if err != nil {
return nil, err
}
return marshaledEvent, nil
return json.Marshal(encodedEvent)
}
func TestUpdate(t *testing.T) {
......@@ -150,9 +147,10 @@ func TestUpdate(t *testing.T) {
var actions []string
f, tf, codec, ns := cmdtesting.NewAPIFactory()
tf.Client = &fake.RESTClient{
NegotiatedSerializer: ns,
f, tf, codec, _ := cmdtesting.NewAPIFactory()
tf.UnstructuredClient = &fake.RESTClient{
APIRegistry: api.Registry,
NegotiatedSerializer: dynamic.ContentConfig().NegotiatedSerializer,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
p, m := req.URL.Path, req.Method
actions = append(actions, p+":"+m)
......@@ -280,11 +278,33 @@ func TestBuild(t *testing.T) {
}
}
type testPrinter struct {
Objects []runtime.Object
Err error
printers.ResourcePrinter
}
func (t *testPrinter) PrintObj(obj runtime.Object, out io.Writer) error {
t.Objects = append(t.Objects, obj)
fmt.Fprintf(out, "%#v", obj)
return t.Err
}
func (t *testPrinter) HandledResources() []string {
return []string{}
}
func (t *testPrinter) AfterPrint(io.Writer, string) error {
return t.Err
}
func TestGet(t *testing.T) {
list := newPodList("starfish", "otter")
f, tf, _, ns := cmdtesting.NewAPIFactory()
tf.Client = &fake.RESTClient{
NegotiatedSerializer: ns,
f, tf, _, _ := cmdtesting.NewAPIFactory()
tf.Printer = &testPrinter{}
tf.UnstructuredClient = &fake.RESTClient{
APIRegistry: api.Registry,
NegotiatedSerializer: dynamic.ContentConfig().NegotiatedSerializer,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
p, m := req.URL.Path, req.Method
//actions = append(actions, p+":"+m)
......@@ -378,7 +398,7 @@ func TestPerform(t *testing.T) {
t.Errorf("%q. Error while building manifests: %v", tt.name, err)
}
err = perform(c, tt.namespace, infos, fn)
err = perform(infos, fn)
if (err != nil) != tt.err {
t.Errorf("%q. expected error: %v, got %v", tt.name, tt.err, err)
}
......@@ -403,12 +423,12 @@ func TestWaitAndGetCompletedPodPhase(t *testing.T) {
podPhase: api.PodPending,
expectedPhase: api.PodUnknown,
err: true,
errMessage: "timed out waiting for the condition",
errMessage: "watch closed before Until timeout",
}, {
podPhase: api.PodRunning,
expectedPhase: api.PodUnknown,
err: true,
errMessage: "timed out waiting for the condition",
errMessage: "watch closed before Until timeout",
}, {
podPhase: api.PodSucceeded,
expectedPhase: api.PodSucceeded,
......@@ -426,6 +446,7 @@ func TestWaitAndGetCompletedPodPhase(t *testing.T) {
testPodList.Items = append(testPodList.Items, newPodWithStatus("bestpod", api.PodStatus{Phase: tt.podPhase}, "test"))
tf.Client = &fake.RESTClient{
APIRegistry: api.Registry,
NegotiatedSerializer: ns,
Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) {
p, m := req.URL.Path, req.Method
......@@ -433,7 +454,7 @@ func TestWaitAndGetCompletedPodPhase(t *testing.T) {
switch {
case p == "/namespaces/test/pods/bestpod" && m == "GET":
return newResponse(200, &testPodList.Items[0])
case p == "/watch/namespaces/test/pods/bestpod" && m == "GET":
case p == "/namespaces/test/pods" && m == "GET":
event := watch.Event{Type: watch.Added, Object: &testPodList.Items[0]}
return newEventResponse(200, &event)
default:
......
......@@ -16,7 +16,7 @@ limitations under the License.
package kube // import "k8s.io/helm/pkg/kube"
import "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
import "k8s.io/client-go/tools/clientcmd"
// GetConfig returns a kubernetes client config for a given context.
func GetConfig(context string) clientcmd.ClientConfig {
......
......@@ -17,14 +17,15 @@ limitations under the License.
package kube // import "k8s.io/helm/pkg/kube"
import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
)
func createNamespace(client internalclientset.Interface, namespace string) error {
ns := &api.Namespace{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
}
......@@ -33,7 +34,7 @@ func createNamespace(client internalclientset.Interface, namespace string) error
}
func getNamespace(client internalclientset.Interface, namespace string) (*api.Namespace, error) {
return client.Core().Namespaces().Get(namespace)
return client.Core().Namespaces().Get(namespace, metav1.GetOptions{})
}
func ensureNamespace(client internalclientset.Interface, namespace string) error {
......
......@@ -19,6 +19,7 @@ package kube // import "k8s.io/helm/pkg/kube"
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
)
......@@ -30,7 +31,7 @@ func TestEnsureNamespace(t *testing.T) {
if err := ensureNamespace(client, "foo"); err != nil {
t.Fatalf("unexpected error: %s", err)
}
if _, err := client.Core().Namespaces().Get("foo"); err != nil {
if _, err := client.Core().Namespaces().Get("foo", metav1.GetOptions{}); err != nil {
t.Fatalf("unexpected error: %s", err)
}
}
......@@ -19,13 +19,13 @@ package kube // import "k8s.io/helm/pkg/kube"
import (
"testing"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/kubectl/resource"
)
func TestResult(t *testing.T) {
mapping, err := testapi.Default.RESTMapper().RESTMapping(unversioned.GroupKind{Kind: "Pod"})
mapping, err := testapi.Default.RESTMapper().RESTMapping(schema.GroupKind{Kind: "Pod"})
if err != nil {
t.Fatal(err)
}
......
......@@ -23,8 +23,8 @@ import (
"net"
"strconv"
"k8s.io/kubernetes/pkg/client/restclient"
"k8s.io/kubernetes/pkg/client/unversioned/portforward"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/portforward"
"k8s.io/kubernetes/pkg/client/unversioned/remotecommand"
)
......@@ -37,12 +37,12 @@ type Tunnel struct {
Out io.Writer
stopChan chan struct{}
readyChan chan struct{}
config *restclient.Config
client restclient.Interface
config *rest.Config
client rest.Interface
}
// NewTunnel creates a new tunnel
func NewTunnel(client restclient.Interface, config *restclient.Config, namespace, podName string, remote int) *Tunnel {
func NewTunnel(client rest.Interface, config *rest.Config, namespace, podName string, remote int) *Tunnel {
return &Tunnel{
config: config,
client: client,
......
/*
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.
*/
package kube // import "k8s.io/helm/pkg/kube"
import (
"log"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/pkg/apis/apps"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
core "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/core/v1"
extensions "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1"
internalclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util"
)
// deployment holds associated replicaSets for a deployment
type deployment struct {
replicaSets *v1beta1.ReplicaSet
deployment *v1beta1.Deployment
}
// waitForResources polls to get the current status of all pods, PVCs, and Services
// until all are ready or a timeout is reached
func (c *Client) waitForResources(timeout time.Duration, created Result) error {
log.Printf("beginning wait for resources with timeout of %v", timeout)
cs, _ := c.ClientSet()
client := versionedClientsetForDeployment(cs)
return wait.Poll(2*time.Second, timeout, func() (bool, error) {
pods := []v1.Pod{}
services := []v1.Service{}
pvc := []v1.PersistentVolumeClaim{}
replicaSets := []*v1beta1.ReplicaSet{}
deployments := []deployment{}
for _, v := range created {
obj, err := c.AsVersionedObject(v.Object)
if err != nil && !runtime.IsNotRegisteredError(err) {
return false, err
}
switch value := obj.(type) {
case (*v1.ReplicationController):
list, err := getPods(client, value.Namespace, value.Spec.Selector)
if err != nil {
return false, err
}
pods = append(pods, list...)
case (*v1.Pod):
pod, err := client.Core().Pods(value.Namespace).Get(value.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
pods = append(pods, *pod)
case (*v1beta1.Deployment):
// Get the RS children first
rs, err := client.Extensions().ReplicaSets(value.Namespace).List(metav1.ListOptions{
FieldSelector: fields.Everything().String(),
LabelSelector: labels.Set(value.Spec.Selector.MatchLabels).AsSelector().String(),
})
if err != nil {
return false, err
}
for _, i := range rs.Items {
replicaSets = append(replicaSets, &i)
}
currentDeployment, err := client.Extensions().Deployments(value.Namespace).Get(value.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
// Find RS associated with deployment
newReplicaSet, err := deploymentutil.FindNewReplicaSet(currentDeployment, replicaSets)
if err != nil {
return false, err
}
newDeployment := deployment{
newReplicaSet,
currentDeployment,
}
deployments = append(deployments, newDeployment)
case (*v1beta1.DaemonSet):
list, err := getPods(client, value.Namespace, value.Spec.Selector.MatchLabels)
if err != nil {
return false, err
}
pods = append(pods, list...)
case (*apps.StatefulSet):
list, err := getPods(client, value.Namespace, value.Spec.Selector.MatchLabels)
if err != nil {
return false, err
}
pods = append(pods, list...)
case (*v1beta1.ReplicaSet):
list, err := getPods(client, value.Namespace, value.Spec.Selector.MatchLabels)
if err != nil {
return false, err
}
pods = append(pods, list...)
case (*v1.PersistentVolumeClaim):
claim, err := client.Core().PersistentVolumeClaims(value.Namespace).Get(value.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
pvc = append(pvc, *claim)
case (*v1.Service):
svc, err := client.Core().Services(value.Namespace).Get(value.Name, metav1.GetOptions{})
if err != nil {
return false, err
}
services = append(services, *svc)
}
}
return podsReady(pods) && servicesReady(services) && volumesReady(pvc) && deploymentsReady(deployments), nil
})
}
func podsReady(pods []v1.Pod) bool {
for _, pod := range pods {
if !v1.IsPodReady(&pod) {
return false
}
}
return true
}
func servicesReady(svc []v1.Service) bool {
for _, s := range svc {
// Make sure the service is not explicitly set to "None" before checking the IP
if s.Spec.ClusterIP != v1.ClusterIPNone && !v1.IsServiceIPSet(&s) {
return false
}
// This checks if the service has a LoadBalancer and that balancer has an Ingress defined
if s.Spec.Type == v1.ServiceTypeLoadBalancer && s.Status.LoadBalancer.Ingress == nil {
return false
}
}
return true
}
func volumesReady(vols []v1.PersistentVolumeClaim) bool {
for _, v := range vols {
if v.Status.Phase != v1.ClaimBound {
return false
}
}
return true
}
func deploymentsReady(deployments []deployment) bool {
for _, v := range deployments {
if !(v.replicaSets.Status.ReadyReplicas >= *v.deployment.Spec.Replicas-deploymentutil.MaxUnavailable(*v.deployment)) {
return false
}
}
return true
}
func getPods(client clientset.Interface, namespace string, selector map[string]string) ([]v1.Pod, error) {
list, err := client.Core().Pods(namespace).List(metav1.ListOptions{
FieldSelector: fields.Everything().String(),
LabelSelector: labels.Set(selector).AsSelector().String(),
})
return list.Items, err
}
func versionedClientsetForDeployment(internalClient internalclientset.Interface) clientset.Interface {
if internalClient == nil {
return &clientset.Clientset{}
}
return &clientset.Clientset{
CoreV1Client: core.New(internalClient.Core().RESTClient()),
ExtensionsV1beta1Client: extensions.New(internalClient.Extensions().RESTClient()),
}
}
......@@ -17,8 +17,9 @@ limitations under the License.
package releaseutil // import "k8s.io/helm/pkg/releaseutil"
import (
rspb "k8s.io/helm/pkg/proto/hapi/release"
"testing"
rspb "k8s.io/helm/pkg/proto/hapi/release"
)
func TestFilterAny(t *testing.T) {
......
......@@ -17,10 +17,11 @@ limitations under the License.
package releaseutil // import "k8s.io/helm/pkg/releaseutil"
import (
rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/timeconv"
"testing"
"time"
rspb "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/timeconv"
)
// note: this test data is shared with filter_test.go.
......
......@@ -28,11 +28,12 @@ import (
"time"
"github.com/golang/protobuf/proto"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kblabels "k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/kubernetes/pkg/api"
kberrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
kblabels "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/validation"
rspb "k8s.io/helm/pkg/proto/hapi/release"
)
......@@ -67,9 +68,9 @@ func (cfgmaps *ConfigMaps) Name() string {
// or error if not found.
func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) {
// fetch the configmap holding the release named by key
obj, err := cfgmaps.impl.Get(key)
obj, err := cfgmaps.impl.Get(key, metav1.GetOptions{})
if err != nil {
if kberrs.IsNotFound(err) {
if apierrors.IsNotFound(err) {
return nil, ErrReleaseNotFound(key)
}
......@@ -91,7 +92,7 @@ func (cfgmaps *ConfigMaps) Get(key string) (*rspb.Release, error) {
// configmap fails to retrieve the releases.
func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Release, error) {
lsel := kblabels.Set{"OWNER": "TILLER"}.AsSelector()
opts := api.ListOptions{LabelSelector: lsel}
opts := metav1.ListOptions{LabelSelector: lsel.String()}
list, err := cfgmaps.impl.List(opts)
if err != nil {
......@@ -127,7 +128,7 @@ func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, err
ls[k] = v
}
opts := api.ListOptions{LabelSelector: ls.AsSelector()}
opts := metav1.ListOptions{LabelSelector: ls.AsSelector().String()}
list, err := cfgmaps.impl.List(opts)
if err != nil {
......@@ -168,7 +169,7 @@ func (cfgmaps *ConfigMaps) Create(key string, rls *rspb.Release) error {
}
// push the configmap object out into the kubiverse
if _, err := cfgmaps.impl.Create(obj); err != nil {
if kberrs.IsAlreadyExists(err) {
if apierrors.IsAlreadyExists(err) {
return ErrReleaseExists(rls.Name)
}
......@@ -206,15 +207,15 @@ func (cfgmaps *ConfigMaps) Update(key string, rls *rspb.Release) error {
func (cfgmaps *ConfigMaps) Delete(key string) (rls *rspb.Release, err error) {
// fetch the release to check existence
if rls, err = cfgmaps.Get(key); err != nil {
if kberrs.IsNotFound(err) {
return nil, ErrReleaseNotFound(key)
if apierrors.IsNotFound(err) {
return nil, ErrReleaseExists(rls.Name)
}
logerrf(err, "delete: failed to get release %q", key)
return nil, err
}
// delete the release
if err = cfgmaps.impl.Delete(key, &api.DeleteOptions{}); err != nil {
if err = cfgmaps.impl.Delete(key, &metav1.DeleteOptions{}); err != nil {
return rls, err
}
return rls, nil
......@@ -254,7 +255,7 @@ func newConfigMapsObject(key string, rls *rspb.Release, lbs labels) (*api.Config
// create and return configmap object
return &api.ConfigMap{
ObjectMeta: api.ObjectMeta{
ObjectMeta: metav1.ObjectMeta{
Name: key,
Labels: lbs.toMap(),
},
......
......@@ -20,8 +20,9 @@ import (
"fmt"
"testing"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
kberrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
rspb "k8s.io/helm/pkg/proto/hapi/release"
......@@ -96,16 +97,16 @@ func (mock *MockConfigMapsInterface) Init(t *testing.T, releases ...*rspb.Releas
}
// Get returns the ConfigMap by name.
func (mock *MockConfigMapsInterface) Get(name string) (*api.ConfigMap, error) {
func (mock *MockConfigMapsInterface) Get(name string, options metav1.GetOptions) (*api.ConfigMap, error) {
object, ok := mock.objects[name]
if !ok {
return nil, kberrs.NewNotFound(api.Resource("tests"), name)
return nil, apierrors.NewNotFound(api.Resource("tests"), name)
}
return object, nil
}
// List returns the a of ConfigMaps.
func (mock *MockConfigMapsInterface) List(opts api.ListOptions) (*api.ConfigMapList, error) {
func (mock *MockConfigMapsInterface) List(opts metav1.ListOptions) (*api.ConfigMapList, error) {
var list api.ConfigMapList
for _, cfgmap := range mock.objects {
list.Items = append(list.Items, *cfgmap)
......@@ -117,7 +118,7 @@ func (mock *MockConfigMapsInterface) List(opts api.ListOptions) (*api.ConfigMapL
func (mock *MockConfigMapsInterface) Create(cfgmap *api.ConfigMap) (*api.ConfigMap, error) {
name := cfgmap.ObjectMeta.Name
if object, ok := mock.objects[name]; ok {
return object, kberrs.NewAlreadyExists(api.Resource("tests"), name)
return object, apierrors.NewAlreadyExists(api.Resource("tests"), name)
}
mock.objects[name] = cfgmap
return cfgmap, nil
......@@ -127,16 +128,16 @@ func (mock *MockConfigMapsInterface) Create(cfgmap *api.ConfigMap) (*api.ConfigM
func (mock *MockConfigMapsInterface) Update(cfgmap *api.ConfigMap) (*api.ConfigMap, error) {
name := cfgmap.ObjectMeta.Name
if _, ok := mock.objects[name]; !ok {
return nil, kberrs.NewNotFound(api.Resource("tests"), name)
return nil, apierrors.NewNotFound(api.Resource("tests"), name)
}
mock.objects[name] = cfgmap
return cfgmap, nil
}
// Delete deletes a ConfigMap by name.
func (mock *MockConfigMapsInterface) Delete(name string, opts *api.DeleteOptions) error {
func (mock *MockConfigMapsInterface) Delete(name string, opts *metav1.DeleteOptions) error {
if _, ok := mock.objects[name]; !ok {
return kberrs.NewNotFound(api.Resource("tests"), name)
return apierrors.NewNotFound(api.Resource("tests"), name)
}
delete(mock.objects, name)
return nil
......
......@@ -27,9 +27,9 @@ import (
"github.com/technosophos/moniker"
ctx "golang.org/x/net/context"
"k8s.io/kubernetes/pkg/api/unversioned"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
"k8s.io/kubernetes/pkg/client/typed/discovery"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/hooks"
......@@ -771,7 +771,7 @@ func getVersionSet(client discovery.ServerGroupsInterface) (chartutil.VersionSet
return chartutil.DefaultVersionSet, nil
}
versions := unversioned.ExtractGroupVersions(groups)
versions := metav1.ExtractGroupVersions(groups)
return chartutil.NewVersionSet(versions...), nil
}
......
#!/usr/bin/env 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.
# Copies the current versions of apimachinery and client-go out of the
# main kubernetes repo. These repos are currently out of sync and not
# versioned.
set -euo pipefail
rm -rf ./vendor/k8s.io/{kube-aggregator,apiserver,apimachinery,client-go}
cp -r ./vendor/k8s.io/kubernetes/staging/src/k8s.io/{kube-aggregator,apiserver,apimachinery,client-go} ./vendor/k8s.io
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