Skip to content
Snippets Groups Projects
Commit d653ae39 authored by Jessica Yuen's avatar Jessica Yuen
Browse files

Client-go v4 code changes


Signed-off-by: default avatarJessica Yuen <im.jessicayuen@gmail.com>
parent 8adcbf9e
No related branches found
No related tags found
No related merge requests found
...@@ -66,7 +66,8 @@ ks apply dev -c guestbook-ui -c nginx-depl --create false ...@@ -66,7 +66,8 @@ ks apply dev -c guestbook-ui -c nginx-depl --create false
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -45,7 +45,8 @@ ks delete --kubeconfig=./kubeconfig -c nginx ...@@ -45,7 +45,8 @@ ks delete --kubeconfig=./kubeconfig -c nginx
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -50,7 +50,8 @@ ks env ...@@ -50,7 +50,8 @@ ks env
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -73,7 +73,8 @@ ks env add prod --server=https://ksonnet-1.us-west.elb.amazonaws.com ...@@ -73,7 +73,8 @@ ks env add prod --server=https://ksonnet-1.us-west.elb.amazonaws.com
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -27,7 +27,8 @@ ks env list ...@@ -27,7 +27,8 @@ ks env list
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -40,7 +40,8 @@ ks env rm us-west/staging ...@@ -40,7 +40,8 @@ ks env rm us-west/staging
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -52,7 +52,8 @@ ks env set us-west/staging --context=staging-west ...@@ -52,7 +52,8 @@ ks env set us-west/staging --context=staging-west
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -84,7 +84,8 @@ ks init app-name --dir=custom-location ...@@ -84,7 +84,8 @@ ks init app-name --dir=custom-location
``` ```
--api-spec string Manually specified Kubernetes API version. The corresponding OpenAPI spec is used to generate ksonnet's Kubernetes libraries (default "version:v1.7.0") --api-spec string Manually specified Kubernetes API version. The corresponding OpenAPI spec is used to generate ksonnet's Kubernetes libraries (default "version:v1.7.0")
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -50,7 +50,8 @@ ksonnet validate prod -c redis ...@@ -50,7 +50,8 @@ ksonnet validate prod -c redis
``` ```
--as string Username to impersonate for the operation --as string Username to impersonate for the operation
--certificate-authority string Path to a cert. file for the certificate authority --as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS --client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS --client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use --cluster string The name of the kubeconfig cluster to use
......
...@@ -83,7 +83,7 @@ func (c ApplyCmd) Run(apiObjects []*unstructured.Unstructured, wd metadata.AbsPa ...@@ -83,7 +83,7 @@ func (c ApplyCmd) Run(apiObjects []*unstructured.Unstructured, wd metadata.AbsPa
newobj, err = rc.Patch(obj.GetName(), types.MergePatchType, asPatch) newobj, err = rc.Patch(obj.GetName(), types.MergePatchType, asPatch)
log.Debugf("Patch(%s) returned (%v, %v)", obj.GetName(), newobj, err) log.Debugf("Patch(%s) returned (%v, %v)", obj.GetName(), newobj, err)
} else { } else {
newobj, err = rc.Get(obj.GetName()) newobj, err = rc.Get(obj.GetName(), metav1.GetOptions{})
} }
if c.Create && errors.IsNotFound(err) { if c.Create && errors.IsNotFound(err) {
log.Info(" Creating non-existent ", desc, dryRunText) log.Info(" Creating non-existent ", desc, dryRunText)
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
"github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff"
"github.com/yudai/gojsondiff/formatter" "github.com/yudai/gojsondiff/formatter"
"k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/discovery" "k8s.io/client-go/discovery"
"k8s.io/client-go/dynamic" "k8s.io/client-go/dynamic"
...@@ -216,7 +217,7 @@ func getLiveObjs(client *Client) ([]*unstructured.Unstructured, map[string]*unst ...@@ -216,7 +217,7 @@ func getLiveObjs(client *Client) ([]*unstructured.Unstructured, map[string]*unst
return nil, nil, err return nil, nil, err
} }
liveObj, err := client.Get(obj.GetName()) liveObj, err := client.Get(obj.GetName(), metav1.GetOptions{})
if err != nil && errors.IsNotFound(err) { if err != nil && errors.IsNotFound(err) {
log.Debugf("%s doesn't exist on the server", desc) log.Debugf("%s doesn't exist on the server", desc)
continue continue
......
...@@ -173,8 +173,8 @@ func FlattenToV1(objs []runtime.Object) []*unstructured.Unstructured { ...@@ -173,8 +173,8 @@ func FlattenToV1(objs []runtime.Object) []*unstructured.Unstructured {
for _, obj := range objs { for _, obj := range objs {
switch o := obj.(type) { switch o := obj.(type) {
case *unstructured.UnstructuredList: case *unstructured.UnstructuredList:
for _, item := range o.Items { for i := range o.Items {
ret = append(ret, item) ret = append(ret, &o.Items[i])
} }
case *unstructured.Unstructured: case *unstructured.Unstructured:
ret = append(ret, o) ret = append(ret, o)
......
...@@ -19,7 +19,8 @@ import ( ...@@ -19,7 +19,8 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/emicklei/go-restful/swagger" "github.com/emicklei/go-restful-swagger12"
"github.com/go-openapi/spec"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
...@@ -37,6 +38,7 @@ type memcachedDiscoveryClient struct { ...@@ -37,6 +38,7 @@ type memcachedDiscoveryClient struct {
servergroups *metav1.APIGroupList servergroups *metav1.APIGroupList
serverresources map[string]*metav1.APIResourceList serverresources map[string]*metav1.APIResourceList
schemas map[string]*swagger.ApiDeclaration schemas map[string]*swagger.ApiDeclaration
schema *spec.Swagger
} }
// NewMemcachedDiscoveryClient creates a new DiscoveryClient that // NewMemcachedDiscoveryClient creates a new DiscoveryClient that
...@@ -123,6 +125,23 @@ func (c *memcachedDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (* ...@@ -123,6 +125,23 @@ func (c *memcachedDiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*
return schema, nil return schema, nil
} }
func (c *memcachedDiscoveryClient) OpenAPISchema() (*spec.Swagger, error) {
c.lock.Lock()
defer c.lock.Unlock()
if c.schema != nil {
return c.schema, nil
}
schema, err := c.cl.OpenAPISchema()
if err != nil {
return nil, err
}
c.schema = schema
return schema, nil
}
var _ discovery.CachedDiscoveryInterface = &memcachedDiscoveryClient{} var _ discovery.CachedDiscoveryInterface = &memcachedDiscoveryClient{}
// ClientForResource returns the ResourceClient for a given object // ClientForResource returns the ResourceClient for a given object
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"reflect" "reflect"
"regexp" "regexp"
"github.com/emicklei/go-restful/swagger" swagger "github.com/emicklei/go-restful-swagger12"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
......
...@@ -24,7 +24,7 @@ import ( ...@@ -24,7 +24,7 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/emicklei/go-restful/swagger" swagger "github.com/emicklei/go-restful-swagger12"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
......
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