Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
Update client-go to 10.0 (aka kubernetes 1.13)
Browse files Browse the repository at this point in the history
Update k8s.io/* to kubernetes 1.13.4 (or equivalent git tag).

- Numerous changes to use new upstream dynamic client.
- Also rewrite `utils.ClientForResource` to use standard upstream
  RESTMapper, rather than carry our own equivalent.
  • Loading branch information
anguslees committed Mar 6, 2019
1 parent 6b6a76d commit 52c0aea
Show file tree
Hide file tree
Showing 997 changed files with 114,902 additions and 25,174 deletions.
2 changes: 1 addition & 1 deletion cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var deleteCmd = &cobra.Command{
return err
}

c.ClientPool, c.Discovery, err = restClientPool(cmd)
c.Client, c.Mapper, c.Discovery, err = getDynamicClients(cmd)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var diffCmd = &cobra.Command{
return err
}

c.ClientPool, c.Discovery, err = restClientPool(cmd)
c.Client, c.Mapper, _, err = getDynamicClients(cmd)
if err != nil {
return err
}
Expand Down
21 changes: 13 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/tools/clientcmd"

"github.com/ksonnet/kubecfg/utils"
Expand Down Expand Up @@ -387,21 +389,24 @@ func dumpJSON(v interface{}) string {
return string(buf.Bytes())
}

func restClientPool(cmd *cobra.Command) (dynamic.ClientPool, discovery.DiscoveryInterface, error) {
func getDynamicClients(cmd *cobra.Command) (dynamic.Interface, meta.RESTMapper, discovery.DiscoveryInterface, error) {
conf, err := clientConfig.ClientConfig()
if err != nil {
return nil, nil, fmt.Errorf("Unable to read kubectl config: %v", err)
return nil, nil, nil, fmt.Errorf("Unable to read kubectl config: %v", err)
}

disco, err := discovery.NewDiscoveryClientForConfig(conf)
if err != nil {
return nil, nil, err
return nil, nil, nil, err
}

discoCache := utils.NewMemcachedDiscoveryClient(disco)
mapper := discovery.NewDeferredDiscoveryRESTMapper(discoCache, dynamic.VersionInterfaces)
pathresolver := dynamic.LegacyAPIPathResolverFunc

pool := dynamic.NewClientPool(conf, mapper, pathresolver)
return pool, discoCache, nil
mapper := restmapper.NewDeferredDiscoveryRESTMapper(discoCache)

cl, err := dynamic.NewForConfig(conf)
if err != nil {
return nil, nil, nil, err
}

return cl, mapper, discoCache, nil
}
3 changes: 2 additions & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var updateCmd = &cobra.Command{
return err
}

c.ClientPool, c.Discovery, err = restClientPool(cmd)
c.Client, c.Mapper, c.Discovery, err = getDynamicClients(cmd)
if err != nil {
return err
}
Expand All @@ -90,6 +90,7 @@ var updateCmd = &cobra.Command{

if validate {
v := kubecfg.ValidateCmd{
Mapper: c.Mapper,
Discovery: c.Discovery,
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var validateCmd = &cobra.Command{

c := kubecfg.ValidateCmd{}

_, c.Discovery, err = restClientPool(cmd)
_, c.Mapper, c.Discovery, err = getDynamicClients(cmd)
if err != nil {
return err
}
Expand Down
27 changes: 18 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,51 @@
module github.com/ksonnet/kubecfg

require (
github.com/Azure/go-autorest v9.4.0+incompatible // indirect
contrib.go.opencensus.io/exporter/ocagent v0.4.6 // indirect
github.com/Azure/go-autorest v11.5.0+incompatible // indirect
github.com/PuerkitoBio/purell v0.0.0-20170324134132-b938d81255b5 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170324140228-bbf7a2afc14f // indirect
github.com/dgrijalva/jwt-go v3.1.0+incompatible // indirect
github.com/elazarl/go-bindata-assetfs v0.0.0-20180223160309-38087fe4dafb
github.com/evanphx/json-patch v4.1.0+incompatible // indirect
github.com/genuinetools/reg v0.0.0-20190102165523-d959057b30da
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/jsonpointer v0.0.0-20170102174223-779f45308c19 // indirect
github.com/go-openapi/jsonreference v0.0.0-20161105162150-36d33bfe519e // indirect
github.com/go-openapi/spec v0.0.0-20170413060731-e51c28f07047 // indirect
github.com/go-openapi/swag v0.0.0-20170424051500-24ebf76d720b // indirect
github.com/golang/protobuf v1.2.0
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
github.com/google/go-jsonnet v0.12.1
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367 // indirect
github.com/googleapis/gnostic v0.0.0-20180218235700-15cf44e552f9
github.com/gophercloud/gophercloud v0.0.0-20180227043227-eedbafadaa1a // indirect
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c // indirect
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/imdario/mergo v0.0.0-20170326204527-d806ba8c2177 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v0.0.0-20180227044048-2a93f9003e4f // indirect
github.com/json-iterator/go v1.1.5 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mailru/easyjson v0.0.0-20170426073802-3f09c2282fc5 // indirect
github.com/mattn/go-isatty v0.0.2
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/onsi/ginkgo v1.6.0
github.com/onsi/gomega v1.4.2
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/sergi/go-diff v0.0.0-20170409071739-feef008d51ad
github.com/sirupsen/logrus v1.0.6
github.com/spf13/cobra v0.0.0-20180319062004-c439c4fa0937
github.com/spf13/pflag v0.0.0-20180220143236-ee5fd03fd6ac // indirect
github.com/stretchr/testify v1.2.2
github.com/v2pro/plz v0.0.0-20180227121118-d55f7f1d4903 // indirect
go.opencensus.io v0.19.0 // indirect
golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b
gopkg.in/inf.v0 v0.9.0 // indirect
gopkg.in/yaml.v2 v2.2.1
k8s.io/api v0.0.0-20180521142803-feb48db456a5
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05
k8s.io/client-go v0.0.0-20180521144600-29ae1f00c3d8
gopkg.in/yaml.v2 v2.2.2
k8s.io/api v0.0.0-20190222213804-5cb15d344471
k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628
k8s.io/client-go v2.0.0-alpha.0.0.20190228174230-b40b2a5939e4+incompatible
k8s.io/klog v0.2.0 // indirect
k8s.io/kube-openapi v0.0.0-20180509051136-39cb288412c4
k8s.io/kubernetes v1.10.3
k8s.io/kubernetes v1.13.4
sigs.k8s.io/yaml v1.1.0 // indirect
)
Loading

0 comments on commit 52c0aea

Please sign in to comment.