generated: staging update

This commit is contained in:
Clayton Coleman
2016-12-09 13:17:34 -05:00
parent c52d510a24
commit 9ff68e6667
192 changed files with 44131 additions and 27166 deletions

View File

@@ -161,6 +161,10 @@
"ImportPath": "github.com/jonboulle/clockwork",
"Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982"
},
{
"ImportPath": "github.com/juju/ratelimit",
"Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177"
},
{
"ImportPath": "github.com/mailru/easyjson/buffer",
"Rev": "d5b7844b561a7bc640052f1b935f7b800330d7e0"

View File

@@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 The Kubernetes Authors.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -0,0 +1,191 @@
All files in this repository are licensed as follows. If you contribute
to this repository, it is assumed that you license your contribution
under the same license unless you state otherwise.
All files Copyright (C) 2015 Canonical Ltd. unless otherwise specified in the file.
This software is licensed under the LGPLv3, included below.
As a special exception to the GNU Lesser General Public License version 3
("LGPL3"), the copyright holders of this Library give you permission to
convey to a third party a Combined Work that links statically or dynamically
to this Library without providing any Minimal Corresponding Source or
Minimal Application Code as set out in 4d or providing the installation
information set out in section 4e, provided that you comply with the other
provisions of LGPL3 and provided that you meet, for the Application the
terms and conditions of the license(s) which apply to the Application.
Except as stated in this special exception, the provisions of LGPL3 will
continue to comply in full to this Library. If you modify this Library, you
may apply this exception to your version of this Library, but you are not
obliged to do so. If you do not wish to do so, delete this exception
statement from your version. This exception does not (and cannot) modify any
license terms which apply to the Application, with which you must still
comply.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -0,0 +1,117 @@
# ratelimit
--
import "github.com/juju/ratelimit"
The ratelimit package provides an efficient token bucket implementation. See
http://en.wikipedia.org/wiki/Token_bucket.
## Usage
#### func Reader
```go
func Reader(r io.Reader, bucket *Bucket) io.Reader
```
Reader returns a reader that is rate limited by the given token bucket. Each
token in the bucket represents one byte.
#### func Writer
```go
func Writer(w io.Writer, bucket *Bucket) io.Writer
```
Writer returns a writer that is rate limited by the given token bucket. Each
token in the bucket represents one byte.
#### type Bucket
```go
type Bucket struct {
}
```
Bucket represents a token bucket that fills at a predetermined rate. Methods on
Bucket may be called concurrently.
#### func NewBucket
```go
func NewBucket(fillInterval time.Duration, capacity int64) *Bucket
```
NewBucket returns a new token bucket that fills at the rate of one token every
fillInterval, up to the given maximum capacity. Both arguments must be positive.
The bucket is initially full.
#### func NewBucketWithQuantum
```go
func NewBucketWithQuantum(fillInterval time.Duration, capacity, quantum int64) *Bucket
```
NewBucketWithQuantum is similar to NewBucket, but allows the specification of
the quantum size - quantum tokens are added every fillInterval.
#### func NewBucketWithRate
```go
func NewBucketWithRate(rate float64, capacity int64) *Bucket
```
NewBucketWithRate returns a token bucket that fills the bucket at the rate of
rate tokens per second up to the given maximum capacity. Because of limited
clock resolution, at high rates, the actual rate may be up to 1% different from
the specified rate.
#### func (*Bucket) Rate
```go
func (tb *Bucket) Rate() float64
```
Rate returns the fill rate of the bucket, in tokens per second.
#### func (*Bucket) Take
```go
func (tb *Bucket) Take(count int64) time.Duration
```
Take takes count tokens from the bucket without blocking. It returns the time
that the caller should wait until the tokens are actually available.
Note that if the request is irrevocable - there is no way to return tokens to
the bucket once this method commits us to taking them.
#### func (*Bucket) TakeAvailable
```go
func (tb *Bucket) TakeAvailable(count int64) int64
```
TakeAvailable takes up to count immediately available tokens from the bucket. It
returns the number of tokens removed, or zero if there are no available tokens.
It does not block.
#### func (*Bucket) TakeMaxDuration
```go
func (tb *Bucket) TakeMaxDuration(count int64, maxWait time.Duration) (time.Duration, bool)
```
TakeMaxDuration is like Take, except that it will only take tokens from the
bucket if the wait time for the tokens is no greater than maxWait.
If it would take longer than maxWait for the tokens to become available, it does
nothing and reports false, otherwise it returns the time that the caller should
wait until the tokens are actually available, and reports true.
#### func (*Bucket) Wait
```go
func (tb *Bucket) Wait(count int64)
```
Wait takes count tokens from the bucket, waiting until they are available.
#### func (*Bucket) WaitMaxDuration
```go
func (tb *Bucket) WaitMaxDuration(count int64, maxWait time.Duration) bool
```
WaitMaxDuration is like Wait except that it will only take tokens from the
bucket if it needs to wait for no greater than maxWait. It reports whether any
tokens have been removed from the bucket If no tokens have been removed, it
returns immediately.

View File

@@ -0,0 +1,245 @@
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
// The ratelimit package provides an efficient token bucket implementation
// that can be used to limit the rate of arbitrary things.
// See http://en.wikipedia.org/wiki/Token_bucket.
package ratelimit
import (
"math"
"strconv"
"sync"
"time"
)
// Bucket represents a token bucket that fills at a predetermined rate.
// Methods on Bucket may be called concurrently.
type Bucket struct {
startTime time.Time
capacity int64
quantum int64
fillInterval time.Duration
// The mutex guards the fields following it.
mu sync.Mutex
// avail holds the number of available tokens
// in the bucket, as of availTick ticks from startTime.
// It will be negative when there are consumers
// waiting for tokens.
avail int64
availTick int64
}
// NewBucket returns a new token bucket that fills at the
// rate of one token every fillInterval, up to the given
// maximum capacity. Both arguments must be
// positive. The bucket is initially full.
func NewBucket(fillInterval time.Duration, capacity int64) *Bucket {
return NewBucketWithQuantum(fillInterval, capacity, 1)
}
// rateMargin specifes the allowed variance of actual
// rate from specified rate. 1% seems reasonable.
const rateMargin = 0.01
// NewBucketWithRate returns a token bucket that fills the bucket
// at the rate of rate tokens per second up to the given
// maximum capacity. Because of limited clock resolution,
// at high rates, the actual rate may be up to 1% different from the
// specified rate.
func NewBucketWithRate(rate float64, capacity int64) *Bucket {
for quantum := int64(1); quantum < 1<<50; quantum = nextQuantum(quantum) {
fillInterval := time.Duration(1e9 * float64(quantum) / rate)
if fillInterval <= 0 {
continue
}
tb := NewBucketWithQuantum(fillInterval, capacity, quantum)
if diff := math.Abs(tb.Rate() - rate); diff/rate <= rateMargin {
return tb
}
}
panic("cannot find suitable quantum for " + strconv.FormatFloat(rate, 'g', -1, 64))
}
// nextQuantum returns the next quantum to try after q.
// We grow the quantum exponentially, but slowly, so we
// get a good fit in the lower numbers.
func nextQuantum(q int64) int64 {
q1 := q * 11 / 10
if q1 == q {
q1++
}
return q1
}
// NewBucketWithQuantum is similar to NewBucket, but allows
// the specification of the quantum size - quantum tokens
// are added every fillInterval.
func NewBucketWithQuantum(fillInterval time.Duration, capacity, quantum int64) *Bucket {
if fillInterval <= 0 {
panic("token bucket fill interval is not > 0")
}
if capacity <= 0 {
panic("token bucket capacity is not > 0")
}
if quantum <= 0 {
panic("token bucket quantum is not > 0")
}
return &Bucket{
startTime: time.Now(),
capacity: capacity,
quantum: quantum,
avail: capacity,
fillInterval: fillInterval,
}
}
// Wait takes count tokens from the bucket, waiting until they are
// available.
func (tb *Bucket) Wait(count int64) {
if d := tb.Take(count); d > 0 {
time.Sleep(d)
}
}
// WaitMaxDuration is like Wait except that it will
// only take tokens from the bucket if it needs to wait
// for no greater than maxWait. It reports whether
// any tokens have been removed from the bucket
// If no tokens have been removed, it returns immediately.
func (tb *Bucket) WaitMaxDuration(count int64, maxWait time.Duration) bool {
d, ok := tb.TakeMaxDuration(count, maxWait)
if d > 0 {
time.Sleep(d)
}
return ok
}
const infinityDuration time.Duration = 0x7fffffffffffffff
// Take takes count tokens from the bucket without blocking. It returns
// the time that the caller should wait until the tokens are actually
// available.
//
// Note that if the request is irrevocable - there is no way to return
// tokens to the bucket once this method commits us to taking them.
func (tb *Bucket) Take(count int64) time.Duration {
d, _ := tb.take(time.Now(), count, infinityDuration)
return d
}
// TakeMaxDuration is like Take, except that
// it will only take tokens from the bucket if the wait
// time for the tokens is no greater than maxWait.
//
// If it would take longer than maxWait for the tokens
// to become available, it does nothing and reports false,
// otherwise it returns the time that the caller should
// wait until the tokens are actually available, and reports
// true.
func (tb *Bucket) TakeMaxDuration(count int64, maxWait time.Duration) (time.Duration, bool) {
return tb.take(time.Now(), count, maxWait)
}
// TakeAvailable takes up to count immediately available tokens from the
// bucket. It returns the number of tokens removed, or zero if there are
// no available tokens. It does not block.
func (tb *Bucket) TakeAvailable(count int64) int64 {
return tb.takeAvailable(time.Now(), count)
}
// takeAvailable is the internal version of TakeAvailable - it takes the
// current time as an argument to enable easy testing.
func (tb *Bucket) takeAvailable(now time.Time, count int64) int64 {
if count <= 0 {
return 0
}
tb.mu.Lock()
defer tb.mu.Unlock()
tb.adjust(now)
if tb.avail <= 0 {
return 0
}
if count > tb.avail {
count = tb.avail
}
tb.avail -= count
return count
}
// Available returns the number of available tokens. It will be negative
// when there are consumers waiting for tokens. Note that if this
// returns greater than zero, it does not guarantee that calls that take
// tokens from the buffer will succeed, as the number of available
// tokens could have changed in the meantime. This method is intended
// primarily for metrics reporting and debugging.
func (tb *Bucket) Available() int64 {
return tb.available(time.Now())
}
// available is the internal version of available - it takes the current time as
// an argument to enable easy testing.
func (tb *Bucket) available(now time.Time) int64 {
tb.mu.Lock()
defer tb.mu.Unlock()
tb.adjust(now)
return tb.avail
}
// Capacity returns the capacity that the bucket was created with.
func (tb *Bucket) Capacity() int64 {
return tb.capacity
}
// Rate returns the fill rate of the bucket, in tokens per second.
func (tb *Bucket) Rate() float64 {
return 1e9 * float64(tb.quantum) / float64(tb.fillInterval)
}
// take is the internal version of Take - it takes the current time as
// an argument to enable easy testing.
func (tb *Bucket) take(now time.Time, count int64, maxWait time.Duration) (time.Duration, bool) {
if count <= 0 {
return 0, true
}
tb.mu.Lock()
defer tb.mu.Unlock()
currentTick := tb.adjust(now)
avail := tb.avail - count
if avail >= 0 {
tb.avail = avail
return 0, true
}
// Round up the missing tokens to the nearest multiple
// of quantum - the tokens won't be available until
// that tick.
endTick := currentTick + (-avail+tb.quantum-1)/tb.quantum
endTime := tb.startTime.Add(time.Duration(endTick) * tb.fillInterval)
waitTime := endTime.Sub(now)
if waitTime > maxWait {
return 0, false
}
tb.avail = avail
return waitTime, true
}
// adjust adjusts the current bucket capacity based on the current time.
// It returns the current tick.
func (tb *Bucket) adjust(now time.Time) (currentTick int64) {
currentTick = int64(now.Sub(tb.startTime) / tb.fillInterval)
if tb.avail >= tb.capacity {
return
}
tb.avail += (currentTick - tb.availTick) * tb.quantum
if tb.avail > tb.capacity {
tb.avail = tb.capacity
}
tb.availTick = currentTick
return
}

View File

@@ -0,0 +1,51 @@
// Copyright 2014 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package ratelimit
import "io"
type reader struct {
r io.Reader
bucket *Bucket
}
// Reader returns a reader that is rate limited by
// the given token bucket. Each token in the bucket
// represents one byte.
func Reader(r io.Reader, bucket *Bucket) io.Reader {
return &reader{
r: r,
bucket: bucket,
}
}
func (r *reader) Read(buf []byte) (int, error) {
n, err := r.r.Read(buf)
if n <= 0 {
return n, err
}
r.bucket.Wait(int64(n))
return n, err
}
type writer struct {
w io.Writer
bucket *Bucket
}
// Writer returns a reader that is rate limited by
// the given token bucket. Each token in the bucket
// represents one byte.
func Writer(w io.Writer, bucket *Bucket) io.Writer {
return &writer{
w: w,
bucket: bucket,
}
}
func (w *writer) Write(buf []byte) (int, error) {
w.bucket.Wait(int64(len(buf)))
return w.w.Write(buf)
}

View File

@@ -36,6 +36,9 @@ import (
"k8s.io/client-go/rest"
)
// defaultRetries is the number of times a resource discovery is repeated if an api group disappears on the fly (e.g. ThirdPartyResources).
const defaultRetries = 2
// DiscoveryInterface holds the methods that discover server-supported API groups,
// versions and resources.
type DiscoveryInterface interface {
@@ -67,13 +70,13 @@ type ServerResourcesInterface interface {
// ServerResourcesForGroupVersion returns the supported resources for a group and version.
ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
// ServerResources returns the supported resources for all groups and versions.
ServerResources() (map[string]*metav1.APIResourceList, error)
ServerResources() ([]*metav1.APIResourceList, error)
// ServerPreferredResources returns the supported resources with the version preferred by the
// server.
ServerPreferredResources() ([]schema.GroupVersionResource, error)
ServerPreferredResources() ([]*metav1.APIResourceList, error)
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
// version preferred by the server.
ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error)
ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
}
// ServerVersionInterface has a method for retrieving the server's version.
@@ -154,7 +157,9 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
} else {
url.Path = "/apis/" + groupVersion
}
resources = &metav1.APIResourceList{}
resources = &metav1.APIResourceList{
GroupVersion: groupVersion,
}
err = d.restClient.Get().AbsPath(url.String()).Do().Into(resources)
if err != nil {
// ignore 403 or 404 error to be compatible with an v1.0 server.
@@ -166,22 +171,43 @@ func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (r
return resources, nil
}
// ServerResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) ServerResources() (map[string]*metav1.APIResourceList, error) {
// serverResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) serverResources(failEarly bool) ([]*metav1.APIResourceList, error) {
apiGroups, err := d.ServerGroups()
if err != nil {
return nil, err
}
groupVersions := metav1.ExtractGroupVersions(apiGroups)
result := map[string]*metav1.APIResourceList{}
for _, groupVersion := range groupVersions {
resources, err := d.ServerResourcesForGroupVersion(groupVersion)
if err != nil {
return nil, err
result := []*metav1.APIResourceList{}
failedGroups := make(map[schema.GroupVersion]error)
for _, apiGroup := range apiGroups.Groups {
for _, version := range apiGroup.Versions {
gv := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
resources, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
if err != nil {
// TODO: maybe restrict this to NotFound errors
failedGroups[gv] = err
if failEarly {
return nil, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
continue
}
result = append(result, resources)
}
result[groupVersion] = resources
}
return result, nil
if len(failedGroups) == 0 {
return result, nil
}
return result, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
// ServerResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error) {
return withRetries(defaultRetries, d.serverResources)
}
// ErrGroupDiscoveryFailed is returned if one or more API groups fail to load.
@@ -207,78 +233,86 @@ func IsGroupDiscoveryFailedError(err error) bool {
return err != nil && ok
}
// serverPreferredResources returns the supported resources with the version preferred by the
// server. If namespaced is true, only namespaced resources will be returned.
func (d *DiscoveryClient) serverPreferredResources(namespaced bool) ([]schema.GroupVersionResource, error) {
// retry in case the groups supported by the server change after ServerGroup() returns.
const maxRetries = 2
var failedGroups map[schema.GroupVersion]error
var results []schema.GroupVersionResource
var resources map[schema.GroupResource]string
RetrieveGroups:
for i := 0; i < maxRetries; i++ {
results = []schema.GroupVersionResource{}
resources = map[schema.GroupResource]string{}
failedGroups = make(map[schema.GroupVersion]error)
serverGroupList, err := d.ServerGroups()
if err != nil {
return results, err
}
// serverPreferredResources returns the supported resources with the version preferred by the server.
func (d *DiscoveryClient) serverPreferredResources(failEarly bool) ([]*metav1.APIResourceList, error) {
serverGroupList, err := d.ServerGroups()
if err != nil {
return nil, err
}
for _, apiGroup := range serverGroupList.Groups {
versions := apiGroup.Versions
for _, version := range versions {
groupVersion := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
apiResourceList, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
if err != nil {
if i < maxRetries-1 {
continue RetrieveGroups
}
failedGroups[groupVersion] = err
result := []*metav1.APIResourceList{}
failedGroups := make(map[schema.GroupVersion]error)
grVersions := map[schema.GroupResource]string{} // selected version of a GroupResource
grApiResources := map[schema.GroupResource]*metav1.APIResource{} // selected APIResource for a GroupResource
gvApiResourceLists := map[schema.GroupVersion]*metav1.APIResourceList{} // blueprint for a APIResourceList for later grouping
for _, apiGroup := range serverGroupList.Groups {
for _, version := range apiGroup.Versions {
groupVersion := schema.GroupVersion{Group: apiGroup.Name, Version: version.Version}
apiResourceList, err := d.ServerResourcesForGroupVersion(version.GroupVersion)
if err != nil {
// TODO: maybe restrict this to NotFound errors
failedGroups[groupVersion] = err
if failEarly {
return nil, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
continue
}
// create empty list which is filled later in another loop
emptyApiResourceList := metav1.APIResourceList{
GroupVersion: version.GroupVersion,
}
gvApiResourceLists[groupVersion] = &emptyApiResourceList
result = append(result, &emptyApiResourceList)
for i := range apiResourceList.APIResources {
apiResource := &apiResourceList.APIResources[i]
if strings.Contains(apiResource.Name, "/") {
continue
}
for _, apiResource := range apiResourceList.APIResources {
// ignore the root scoped resources if "namespaced" is true.
if namespaced && !apiResource.Namespaced {
continue
}
if strings.Contains(apiResource.Name, "/") {
continue
}
gvr := groupVersion.WithResource(apiResource.Name)
if _, ok := resources[gvr.GroupResource()]; ok {
if gvr.Version != apiGroup.PreferredVersion.Version {
continue
}
// remove previous entry, because it will be replaced with a preferred one
for i := range results {
if results[i].GroupResource() == gvr.GroupResource() {
results = append(results[:i], results[i+1:]...)
}
}
}
resources[gvr.GroupResource()] = gvr.Version
results = append(results, gvr)
gv := schema.GroupResource{Group: apiGroup.Name, Resource: apiResource.Name}
if _, ok := grApiResources[gv]; ok && version.Version != apiGroup.PreferredVersion.Version {
// only override with preferred version
continue
}
grVersions[gv] = version.Version
grApiResources[gv] = apiResource
}
}
if len(failedGroups) == 0 {
return results, nil
}
}
return results, &ErrGroupDiscoveryFailed{Groups: failedGroups}
// group selected APIResources according to GroupVersion into APIResourceLists
for groupResource, apiResource := range grApiResources {
version := grVersions[groupResource]
groupVersion := schema.GroupVersion{Group: groupResource.Group, Version: version}
apiResourceList := gvApiResourceLists[groupVersion]
apiResourceList.APIResources = append(apiResourceList.APIResources, *apiResource)
}
if len(failedGroups) == 0 {
return result, nil
}
return result, &ErrGroupDiscoveryFailed{Groups: failedGroups}
}
// ServerPreferredResources returns the supported resources with the version preferred by the
// server.
func (d *DiscoveryClient) ServerPreferredResources() ([]schema.GroupVersionResource, error) {
return d.serverPreferredResources(false)
func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
return withRetries(defaultRetries, func(retryEarly bool) ([]*metav1.APIResourceList, error) {
return d.serverPreferredResources(retryEarly)
})
}
// ServerPreferredNamespacedResources returns the supported namespaced resources with the
// version preferred by the server.
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error) {
return d.serverPreferredResources(true)
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
all, err := d.ServerPreferredResources()
return FilteredBy(ResourcePredicateFunc(func(groupVersion string, r *metav1.APIResource) bool {
return r.Namespaced
}), all), err
}
// ServerVersion retrieves and parses the server's version (git version).
@@ -329,6 +363,23 @@ func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.A
return &schema, nil
}
// withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns.
func withRetries(maxRetries int, f func(failEarly bool) ([]*metav1.APIResourceList, error)) ([]*metav1.APIResourceList, error) {
var result []*metav1.APIResourceList
var err error
for i := 0; i < maxRetries; i++ {
failEarly := i < maxRetries-1
result, err = f(failEarly)
if err == nil {
return result, nil
}
if _, ok := err.(*ErrGroupDiscoveryFailed); !ok {
return nil, err
}
}
return result, err
}
func setDiscoveryDefaults(config *rest.Config) error {
config.APIPath = ""
config.GroupVersion = nil

View File

@@ -28,6 +28,7 @@ import (
"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/util/sets"
"k8s.io/client-go/pkg/version"
"k8s.io/client-go/rest"
)
@@ -141,14 +142,14 @@ func TestGetServerResourcesWithV1Server(t *testing.T) {
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
// ServerResources should not return an error even if server returns error at /api/v1.
resourceMap, err := client.ServerResources()
serverResources, err := client.ServerResources()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if _, found := resourceMap["v1"]; !found {
t.Errorf("missing v1 in resource map")
gvs := groupVersions(serverResources)
if !sets.NewString(gvs...).Has("v1") {
t.Errorf("missing v1 in resource list: %v", serverResources)
}
}
func TestGetServerResources(t *testing.T) {
@@ -161,7 +162,7 @@ func TestGetServerResources(t *testing.T) {
},
}
beta := metav1.APIResourceList{
GroupVersion: "extensions/v1",
GroupVersion: "extensions/v1beta1",
APIResources: []metav1.APIResource{
{Name: "deployments", Namespaced: true, Kind: "Deployment"},
{Name: "ingresses", Namespaced: true, Kind: "Ingress"},
@@ -249,13 +250,14 @@ func TestGetServerResources(t *testing.T) {
}
}
resourceMap, err := client.ServerResources()
serverResources, err := client.ServerResources()
if err != nil {
t.Errorf("unexpected error: %v", err)
}
serverGroupVersions := sets.NewString(groupVersions(serverResources)...)
for _, api := range []string{"v1", "extensions/v1beta1"} {
if _, found := resourceMap[api]; !found {
t.Errorf("missing expected api: %s", api)
if !serverGroupVersions.Has(api) {
t.Errorf("missing expected api %q in %v", api, serverResources)
}
}
}
@@ -332,12 +334,12 @@ func TestServerPreferredResources(t *testing.T) {
},
}
tests := []struct {
resourcesList *metav1.APIResourceList
resourcesList []*metav1.APIResourceList
response func(w http.ResponseWriter, req *http.Request)
expectErr func(err error) bool
}{
{
resourcesList: &stable,
resourcesList: []*metav1.APIResourceList{&stable},
expectErr: IsGroupDiscoveryFailedError,
response: func(w http.ResponseWriter, req *http.Request) {
var list interface{}
@@ -426,7 +428,7 @@ func TestServerPreferredResources(t *testing.T) {
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.ServerPreferredResources()
resources, err := client.ServerPreferredResources()
if test.expectErr != nil {
if err == nil {
t.Error("unexpected non-error")
@@ -438,7 +440,13 @@ func TestServerPreferredResources(t *testing.T) {
t.Errorf("unexpected error: %v", err)
continue
}
if !reflect.DeepEqual(got, test.resourcesList) {
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("unexpected error: %v", err)
continue
}
expected, _ := GroupVersionResources(test.resourcesList)
if !reflect.DeepEqual(got, expected) {
t.Errorf("expected:\n%v\ngot:\n%v\n", test.resourcesList, got)
}
server.Close()
@@ -533,10 +541,14 @@ func TestServerPreferredResourcesRetries(t *testing.T) {
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.ServerPreferredResources()
resources, err := client.ServerPreferredResources()
if !tc.expectedError(err) {
t.Errorf("case %d: unexpected error: %v", i, err)
}
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("case %d: unexpected error: %v", i, err)
}
if len(got) != tc.expectResources {
t.Errorf("case %d: expect %d resources, got %#v", i, tc.expectResources, got)
}
@@ -575,7 +587,7 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
}
tests := []struct {
response func(w http.ResponseWriter, req *http.Request)
expected []schema.GroupVersionResource
expected map[schema.GroupVersionResource]struct{}
}{
{
response: func(w http.ResponseWriter, req *http.Request) {
@@ -603,9 +615,9 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: []schema.GroupVersionResource{
{Group: "", Version: "v1", Resource: "pods"},
{Group: "", Version: "v1", Resource: "services"},
expected: map[schema.GroupVersionResource]struct{}{
schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}: {},
schema.GroupVersionResource{Group: "", Version: "v1", Resource: "services"}: {},
},
},
{
@@ -646,9 +658,9 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: []schema.GroupVersionResource{
{Group: "batch", Version: "v1", Resource: "jobs"},
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"},
expected: map[schema.GroupVersionResource]struct{}{
schema.GroupVersionResource{Group: "batch", Version: "v1", Resource: "jobs"}: {},
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
},
},
{
@@ -689,27 +701,39 @@ func TestServerPreferredNamespacedResources(t *testing.T) {
w.WriteHeader(http.StatusOK)
w.Write(output)
},
expected: []schema.GroupVersionResource{
{Group: "batch", Version: "v2alpha1", Resource: "jobs"},
{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"},
expected: map[schema.GroupVersionResource]struct{}{
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "jobs"}: {},
schema.GroupVersionResource{Group: "batch", Version: "v2alpha1", Resource: "cronjobs"}: {},
},
},
}
for _, test := range tests {
for i, test := range tests {
server := httptest.NewServer(http.HandlerFunc(test.response))
defer server.Close()
client := NewDiscoveryClientForConfigOrDie(&rest.Config{Host: server.URL})
got, err := client.ServerPreferredNamespacedResources()
resources, err := client.ServerPreferredNamespacedResources()
if err != nil {
t.Errorf("unexpected error: %v", err)
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
// we need deterministic order and since during processing in ServerPreferredNamespacedResources
// a map comes into play the result needs sorting
got, err := GroupVersionResources(resources)
if err != nil {
t.Errorf("[%d] unexpected error: %v", i, err)
continue
}
if !reflect.DeepEqual(got, test.expected) {
t.Errorf("expected:\n%v\ngot:\n%v\n", test.expected, got)
t.Errorf("[%d] expected:\n%v\ngot:\n%v\n", i, test.expected, got)
}
server.Close()
}
}
func groupVersions(resources []*metav1.APIResourceList) []string {
result := []string{}
for _, resourceList := range resources {
result = append(result, resourceList.GroupVersion)
}
return result
}

View File

@@ -17,7 +17,10 @@ limitations under the License.
package fake
import (
"fmt"
"github.com/emicklei/go-restful/swagger"
"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime/schema"
@@ -36,10 +39,15 @@ func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*me
Resource: schema.GroupVersionResource{Resource: "resource"},
}
c.Invokes(action, nil)
return c.Resources[groupVersion], nil
for _, resourceList := range c.Resources {
if resourceList.GroupVersion == groupVersion {
return resourceList, nil
}
}
return nil, fmt.Errorf("GroupVersion %q not found", groupVersion)
}
func (c *FakeDiscovery) ServerResources() (map[string]*metav1.APIResourceList, error) {
func (c *FakeDiscovery) ServerResources() ([]*metav1.APIResourceList, error) {
action := testing.ActionImpl{
Verb: "get",
Resource: schema.GroupVersionResource{Resource: "resource"},
@@ -48,11 +56,11 @@ func (c *FakeDiscovery) ServerResources() (map[string]*metav1.APIResourceList, e
return c.Resources, nil
}
func (c *FakeDiscovery) ServerPreferredResources() ([]schema.GroupVersionResource, error) {
func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}
func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error) {
func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}

View File

@@ -108,3 +108,55 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion
return nil, fmt.Errorf("failed to negotiate an api version; server supports: %v, client supports: %v",
serverVersions, clientVersions)
}
// GroupVersionResources converts APIResourceLists to the GroupVersionResources.
func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error) {
gvrs := map[schema.GroupVersionResource]struct{}{}
for _, rl := range rls {
gv, err := schema.ParseGroupVersion(rl.GroupVersion)
if err != nil {
return nil, err
}
for i := range rl.APIResources {
gvrs[schema.GroupVersionResource{Group: gv.Group, Version: gv.Version, Resource: rl.APIResources[i].Name}] = struct{}{}
}
}
return gvrs, nil
}
// FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.
func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList {
result := []*metav1.APIResourceList{}
for _, rl := range rls {
filtered := *rl
filtered.APIResources = nil
for i := range rl.APIResources {
if pred.Match(rl.GroupVersion, &rl.APIResources[i]) {
filtered.APIResources = append(filtered.APIResources, rl.APIResources[i])
}
}
if filtered.APIResources != nil {
result = append(result, &filtered)
}
}
return result
}
type ResourcePredicate interface {
Match(groupVersion string, r *metav1.APIResource) bool
}
type ResourcePredicateFunc func(groupVersion string, r *metav1.APIResource) bool
func (fn ResourcePredicateFunc) Match(groupVersion string, r *metav1.APIResource) bool {
return fn(groupVersion, r)
}
// SupportsAllVerbs is a predicate matching a resource iff all given verbs are supported.
type SupportsAllVerbs struct {
Verbs []string
}
func (p SupportsAllVerbs) Match(groupVersion string, r *metav1.APIResource) bool {
return sets.NewString([]string(r.Verbs)...).HasAll(p.Verbs...)
}

View File

@@ -30,9 +30,11 @@ import (
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/testapi"
"k8s.io/client-go/pkg/apimachinery/registered"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
uapi "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/util/sets"
"k8s.io/client-go/rest"
"k8s.io/client-go/rest/fake"
)
@@ -155,3 +157,74 @@ func TestNegotiateVersion(t *testing.T) {
}
}
}
func TestFilteredBy(t *testing.T) {
all := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return true
})
none := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return false
})
onlyV2 := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return strings.HasSuffix(gv, "/v2") || gv == "v2"
})
onlyBar := discovery.ResourcePredicateFunc(func(gv string, r *metav1.APIResource) bool {
return r.Kind == "Bar"
})
foo := []*metav1.APIResourceList{
{
GroupVersion: "foo/v1",
APIResources: []metav1.APIResource{
{Name: "bar", Kind: "Bar"},
{Name: "test", Kind: "Test"},
},
},
{
GroupVersion: "foo/v2",
APIResources: []metav1.APIResource{
{Name: "bar", Kind: "Bar"},
{Name: "test", Kind: "Test"},
},
},
{
GroupVersion: "foo/v3",
APIResources: []metav1.APIResource{},
},
}
tests := []struct {
input []*metav1.APIResourceList
pred discovery.ResourcePredicate
expectedResources []string
}{
{nil, all, []string{}},
{[]*metav1.APIResourceList{
{GroupVersion: "foo/v1"},
}, all, []string{}},
{foo, all, []string{"foo/v1.bar", "foo/v1.test", "foo/v2.bar", "foo/v2.test"}},
{foo, onlyV2, []string{"foo/v2.bar", "foo/v2.test"}},
{foo, onlyBar, []string{"foo/v1.bar", "foo/v2.bar"}},
{foo, none, []string{}},
}
for i, test := range tests {
filtered := discovery.FilteredBy(test.pred, test.input)
if expected, got := sets.NewString(test.expectedResources...), sets.NewString(stringify(filtered)...); !expected.Equal(got) {
t.Errorf("[%d] unexpected group versions: expected=%v, got=%v", i, test.expectedResources, stringify(filtered))
}
}
}
func stringify(rls []*metav1.APIResourceList) []string {
result := []string{}
for _, rl := range rls {
for _, r := range rl.APIResources {
result = append(result, rl.GroupVersion+"."+r.Name)
}
if len(rl.APIResources) == 0 {
result = append(result, rl.GroupVersion)
}
}
return result
}

View File

@@ -265,15 +265,15 @@ func (d *DeferredDiscoveryRESTMapper) RESTMapping(gk schema.GroupKind, versions
// RESTMappings returns the RESTMappings for the provided group kind
// in a rough internal preferred order. If no kind is found, it will
// return a NoResourceMatchError.
func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind) (ms []*meta.RESTMapping, err error) {
func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (ms []*meta.RESTMapping, err error) {
del, err := d.getDelegate()
if err != nil {
return nil, err
}
ms, err = del.RESTMappings(gk)
ms, err = del.RESTMappings(gk, versions...)
if len(ms) == 0 && !d.cl.Fresh() {
d.Reset()
ms, err = d.RESTMappings(gk)
ms, err = d.RESTMappings(gk, versions...)
}
return
}

View File

@@ -290,31 +290,34 @@ func (c *fakeCachedDiscoveryInterface) ServerResourcesForGroupVersion(groupVersi
return nil, errors.NewNotFound(schema.GroupResource{}, "")
}
func (c *fakeCachedDiscoveryInterface) ServerResources() (map[string]*metav1.APIResourceList, error) {
func (c *fakeCachedDiscoveryInterface) ServerResources() ([]*metav1.APIResourceList, error) {
if c.enabledA {
av1, _ := c.ServerResourcesForGroupVersion("a/v1")
return map[string]*metav1.APIResourceList{
"a/v1": av1,
}, nil
return []*metav1.APIResourceList{av1}, nil
}
return map[string]*metav1.APIResourceList{}, nil
return []*metav1.APIResourceList{}, nil
}
func (c *fakeCachedDiscoveryInterface) ServerPreferredResources() ([]schema.GroupVersionResource, error) {
func (c *fakeCachedDiscoveryInterface) ServerPreferredResources() ([]*metav1.APIResourceList, error) {
if c.enabledA {
return []schema.GroupVersionResource{
return []*metav1.APIResourceList{
{
Group: "a",
Version: "v1",
Resource: "foo",
GroupVersion: "a/v1",
APIResources: []metav1.APIResource{
{
Name: "foo",
Kind: "Foo",
Verbs: []string{},
},
},
},
}, nil
}
return []schema.GroupVersionResource{}, nil
return nil, nil
}
func (c *fakeCachedDiscoveryInterface) ServerPreferredNamespacedResources() ([]schema.GroupVersionResource, error) {
return []schema.GroupVersionResource{}, nil
func (c *fakeCachedDiscoveryInterface) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) {
return nil, nil
}
func (c *fakeCachedDiscoveryInterface) ServerVersion() (*version.Info, error) {

View File

@@ -50,10 +50,10 @@ func NewUnstructuredObjectTyper(groupResources []*APIGroupResources) *Unstructur
}
// ObjectKind returns the group,version,kind of the provided object, or an error
// if the object in not *runtime.Unstructured or has no group,version,kind
// if the object in not runtime.Unstructured or has no group,version,kind
// information.
func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (schema.GroupVersionKind, error) {
if _, ok := obj.(*runtime.Unstructured); !ok {
if _, ok := obj.(runtime.Unstructured); !ok {
return schema.GroupVersionKind{}, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
}
@@ -61,7 +61,7 @@ func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (schema.GroupVe
}
// ObjectKinds returns a slice of one element with the group,version,kind of the
// provided object, or an error if the object is not *runtime.Unstructured or
// provided object, or an error if the object is not runtime.Unstructured or
// has no group,version,kind information. unversionedType will always be false
// because runtime.Unstructured object should always have group,version,kind
// information set.
@@ -80,7 +80,7 @@ func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool {
return d.registered[gvk]
}
// IsUnversioned returns false always because *runtime.Unstructured objects
// IsUnversioned returns false always because runtime.Unstructured objects
// should always have group,version,kind information set. ok will be true if the
// object's group,version,kind is registered.
func (d *UnstructuredObjectTyper) IsUnversioned(obj runtime.Object) (unversioned bool, ok bool) {

View File

@@ -29,6 +29,7 @@ import (
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/pkg/conversion/queryparams"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
@@ -124,8 +125,8 @@ func (rc *ResourceClient) List(opts runtime.Object) (runtime.Object, error) {
}
// Get gets the resource with the specified name.
func (rc *ResourceClient) Get(name string) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Get(name string) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
err := rc.cl.Get().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -162,8 +163,8 @@ func (rc *ResourceClient) DeleteCollection(deleteOptions *v1.DeleteOptions, list
}
// Create creates the provided resource.
func (rc *ResourceClient) Create(obj *runtime.Unstructured) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
err := rc.cl.Post().
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -174,8 +175,8 @@ func (rc *ResourceClient) Create(obj *runtime.Unstructured) (*runtime.Unstructur
}
// Update updates the provided resource.
func (rc *ResourceClient) Update(obj *runtime.Unstructured) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Update(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
if len(obj.GetName()) == 0 {
return result, errors.New("object missing name")
}
@@ -203,8 +204,8 @@ func (rc *ResourceClient) Watch(opts runtime.Object) (watch.Interface, error) {
Watch()
}
func (rc *ResourceClient) Patch(name string, pt api.PatchType, data []byte) (*runtime.Unstructured, error) {
result := new(runtime.Unstructured)
func (rc *ResourceClient) Patch(name string, pt api.PatchType, data []byte) (*unstructured.Unstructured, error) {
result := new(unstructured.Unstructured)
err := rc.cl.Patch(pt).
NamespaceIfScoped(rc.ns, rc.resource.Namespaced).
Resource(rc.resource.Name).
@@ -220,7 +221,7 @@ func (rc *ResourceClient) Patch(name string, pt api.PatchType, data []byte) (*ru
type dynamicCodec struct{}
func (dynamicCodec) Decode(data []byte, gvk *schema.GroupVersionKind, obj runtime.Object) (runtime.Object, *schema.GroupVersionKind, error) {
obj, gvk, err := runtime.UnstructuredJSONScheme.Decode(data, gvk, obj)
obj, gvk, err := unstructured.UnstructuredJSONScheme.Decode(data, gvk, obj)
if err != nil {
return nil, nil, err
}
@@ -237,7 +238,7 @@ func (dynamicCodec) Decode(data []byte, gvk *schema.GroupVersionKind, obj runtim
}
func (dynamicCodec) Encode(obj runtime.Object, w io.Writer) error {
return runtime.UnstructuredJSONScheme.Encode(obj, w)
return unstructured.UnstructuredJSONScheme.Encode(obj, w)
}
// ContentConfig returns a rest.ContentConfig for dynamic types.

View File

@@ -28,6 +28,7 @@ import (
"k8s.io/client-go/pkg/api"
"k8s.io/client-go/pkg/api/v1"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/runtime/serializer/streaming"
@@ -46,8 +47,8 @@ func getListJSON(version, kind string, items ...[]byte) []byte {
return []byte(json)
}
func getObject(version, kind, name string) *runtime.Unstructured {
return &runtime.Unstructured{
func getObject(version, kind, name string) *unstructured.Unstructured {
return &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": version,
"kind": kind,
@@ -77,7 +78,7 @@ func TestList(t *testing.T) {
namespace string
path string
resp []byte
want *runtime.UnstructuredList
want *unstructured.UnstructuredList
}{
{
name: "normal_list",
@@ -85,12 +86,12 @@ func TestList(t *testing.T) {
resp: getListJSON("vTest", "rTestList",
getJSON("vTest", "rTest", "item1"),
getJSON("vTest", "rTest", "item2")),
want: &runtime.UnstructuredList{
want: &unstructured.UnstructuredList{
Object: map[string]interface{}{
"apiVersion": "vTest",
"kind": "rTestList",
},
Items: []*runtime.Unstructured{
Items: []*unstructured.Unstructured{
getObject("vTest", "rTest", "item1"),
getObject("vTest", "rTest", "item2"),
},
@@ -103,12 +104,12 @@ func TestList(t *testing.T) {
resp: getListJSON("vTest", "rTestList",
getJSON("vTest", "rTest", "item1"),
getJSON("vTest", "rTest", "item2")),
want: &runtime.UnstructuredList{
want: &unstructured.UnstructuredList{
Object: map[string]interface{}{
"apiVersion": "vTest",
"kind": "rTestList",
},
Items: []*runtime.Unstructured{
Items: []*unstructured.Unstructured{
getObject("vTest", "rTest", "item1"),
getObject("vTest", "rTest", "item2"),
},
@@ -154,7 +155,7 @@ func TestGet(t *testing.T) {
name string
path string
resp []byte
want *runtime.Unstructured
want *unstructured.Unstructured
}{
{
name: "normal_get",
@@ -236,7 +237,7 @@ func TestDelete(t *testing.T) {
}
w.Header().Set("Content-Type", runtime.ContentTypeJSON)
runtime.UnstructuredJSONScheme.Encode(statusOK, w)
unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
})
if err != nil {
t.Errorf("unexpected error when creating client: %v", err)
@@ -285,7 +286,7 @@ func TestDeleteCollection(t *testing.T) {
}
w.Header().Set("Content-Type", runtime.ContentTypeJSON)
runtime.UnstructuredJSONScheme.Encode(statusOK, w)
unstructured.UnstructuredJSONScheme.Encode(statusOK, w)
})
if err != nil {
t.Errorf("unexpected error when creating client: %v", err)
@@ -305,7 +306,7 @@ func TestCreate(t *testing.T) {
tcs := []struct {
name string
namespace string
obj *runtime.Unstructured
obj *unstructured.Unstructured
path string
}{
{
@@ -364,7 +365,7 @@ func TestUpdate(t *testing.T) {
tcs := []struct {
name string
namespace string
obj *runtime.Unstructured
obj *unstructured.Unstructured
path string
}{
{
@@ -489,7 +490,7 @@ func TestPatch(t *testing.T) {
name string
namespace string
patch []byte
want *runtime.Unstructured
want *unstructured.Unstructured
path string
}{
{

View File

@@ -21,6 +21,7 @@ import (
"k8s.io/client-go/pkg/api/meta"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
)
@@ -29,7 +30,7 @@ import (
// accessor appropriate for use with unstructured objects.
func VersionInterfaces(schema.GroupVersion) (*meta.VersionInterfaces, error) {
return &meta.VersionInterfaces{
ObjectConvertor: &runtime.UnstructuredObjectConverter{},
ObjectConvertor: &unstructured.UnstructuredObjectConverter{},
MetadataAccessor: meta.NewAccessor(),
}, nil
}
@@ -56,7 +57,7 @@ func NewDiscoveryRESTMapper(resources []*metav1.APIResourceList, versionFunc met
}
// ObjectTyper provides an ObjectTyper implementation for
// runtime.Unstructured object based on discovery information.
// unstructured.Unstructured object based on discovery information.
type ObjectTyper struct {
registered map[schema.GroupVersionKind]bool
}
@@ -79,10 +80,10 @@ func NewObjectTyper(resources []*metav1.APIResourceList) (runtime.ObjectTyper, e
// ObjectKinds returns a slice of one element with the
// group,version,kind of the provided object, or an error if the
// object is not *runtime.Unstructured or has no group,version,kind
// object is not *unstructured.Unstructured or has no group,version,kind
// information.
func (ot *ObjectTyper) ObjectKinds(obj runtime.Object) ([]schema.GroupVersionKind, bool, error) {
if _, ok := obj.(*runtime.Unstructured); !ok {
if _, ok := obj.(*unstructured.Unstructured); !ok {
return nil, false, fmt.Errorf("type %T is invalid for dynamic object typer", obj)
}
return []schema.GroupVersionKind{obj.GetObjectKind().GroupVersionKind()}, false, nil

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeStatefulSets) DeleteCollection(options *v1.DeleteOptions, listOptio
return err
}
func (c *FakeStatefulSets) Get(name string) (result *v1beta1.StatefulSet, err error) {
func (c *FakeStatefulSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.StatefulSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(statefulsetsResource, c.ns, name), &v1beta1.StatefulSet{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/apps/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type StatefulSetInterface interface {
UpdateStatus(*v1beta1.StatefulSet) (*v1beta1.StatefulSet, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.StatefulSet, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.StatefulSet, error)
List(opts v1.ListOptions) (*v1beta1.StatefulSetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.StatefulSet, err error)
@@ -83,6 +84,9 @@ func (c *statefulSets) Update(statefulSet *v1beta1.StatefulSet) (result *v1beta1
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *statefulSets) UpdateStatus(statefulSet *v1beta1.StatefulSet) (result *v1beta1.StatefulSet, err error) {
result = &v1beta1.StatefulSet{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *statefulSets) DeleteCollection(options *v1.DeleteOptions, listOptions v
}
// Get takes name of the statefulSet, and returns the corresponding statefulSet object, and an error if there is any.
func (c *statefulSets) Get(name string) (result *v1beta1.StatefulSet, err error) {
func (c *statefulSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.StatefulSet, err error) {
result = &v1beta1.StatefulSet{}
err = c.client.Get().
Namespace(c.ns).
Resource("statefulsets").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
api_v1 "k8s.io/client-go/pkg/api/v1"
v1 "k8s.io/client-go/pkg/apis/autoscaling/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeHorizontalPodAutoscalers) DeleteCollection(options *api_v1.DeleteOp
return err
}
func (c *FakeHorizontalPodAutoscalers) Get(name string) (result *v1.HorizontalPodAutoscaler, err error) {
func (c *FakeHorizontalPodAutoscalers) Get(name string, options meta_v1.GetOptions) (result *v1.HorizontalPodAutoscaler, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(horizontalpodautoscalersResource, c.ns, name), &v1.HorizontalPodAutoscaler{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
api_v1 "k8s.io/client-go/pkg/api/v1"
v1 "k8s.io/client-go/pkg/apis/autoscaling/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type HorizontalPodAutoscalerInterface interface {
UpdateStatus(*v1.HorizontalPodAutoscaler) (*v1.HorizontalPodAutoscaler, error)
Delete(name string, options *api_v1.DeleteOptions) error
DeleteCollection(options *api_v1.DeleteOptions, listOptions api_v1.ListOptions) error
Get(name string) (*v1.HorizontalPodAutoscaler, error)
Get(name string, options meta_v1.GetOptions) (*v1.HorizontalPodAutoscaler, error)
List(opts api_v1.ListOptions) (*v1.HorizontalPodAutoscalerList, error)
Watch(opts api_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.HorizontalPodAutoscaler, err error)
@@ -83,6 +84,9 @@ func (c *horizontalPodAutoscalers) Update(horizontalPodAutoscaler *v1.Horizontal
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *horizontalPodAutoscalers) UpdateStatus(horizontalPodAutoscaler *v1.HorizontalPodAutoscaler) (result *v1.HorizontalPodAutoscaler, err error) {
result = &v1.HorizontalPodAutoscaler{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *horizontalPodAutoscalers) DeleteCollection(options *api_v1.DeleteOption
}
// Get takes name of the horizontalPodAutoscaler, and returns the corresponding horizontalPodAutoscaler object, and an error if there is any.
func (c *horizontalPodAutoscalers) Get(name string) (result *v1.HorizontalPodAutoscaler, err error) {
func (c *horizontalPodAutoscalers) Get(name string, options meta_v1.GetOptions) (result *v1.HorizontalPodAutoscaler, err error) {
result = &v1.HorizontalPodAutoscaler{}
err = c.client.Get().
Namespace(c.ns).
Resource("horizontalpodautoscalers").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
api_v1 "k8s.io/client-go/pkg/api/v1"
v1 "k8s.io/client-go/pkg/apis/batch/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeJobs) DeleteCollection(options *api_v1.DeleteOptions, listOptions a
return err
}
func (c *FakeJobs) Get(name string) (result *v1.Job, err error) {
func (c *FakeJobs) Get(name string, options meta_v1.GetOptions) (result *v1.Job, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(jobsResource, c.ns, name), &v1.Job{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
api_v1 "k8s.io/client-go/pkg/api/v1"
v1 "k8s.io/client-go/pkg/apis/batch/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type JobInterface interface {
UpdateStatus(*v1.Job) (*v1.Job, error)
Delete(name string, options *api_v1.DeleteOptions) error
DeleteCollection(options *api_v1.DeleteOptions, listOptions api_v1.ListOptions) error
Get(name string) (*v1.Job, error)
Get(name string, options meta_v1.GetOptions) (*v1.Job, error)
List(opts api_v1.ListOptions) (*v1.JobList, error)
Watch(opts api_v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Job, err error)
@@ -83,6 +84,9 @@ func (c *jobs) Update(job *v1.Job) (result *v1.Job, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *jobs) UpdateStatus(job *v1.Job) (result *v1.Job, err error) {
result = &v1.Job{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *jobs) DeleteCollection(options *api_v1.DeleteOptions, listOptions api_v
}
// Get takes name of the job, and returns the corresponding job object, and an error if there is any.
func (c *jobs) Get(name string) (result *v1.Job, err error) {
func (c *jobs) Get(name string, options meta_v1.GetOptions) (result *v1.Job, err error) {
result = &v1.Job{}
err = c.client.Get().
Namespace(c.ns).
Resource("jobs").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type CronJobInterface interface {
UpdateStatus(*v2alpha1.CronJob) (*v2alpha1.CronJob, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v2alpha1.CronJob, error)
Get(name string, options meta_v1.GetOptions) (*v2alpha1.CronJob, error)
List(opts v1.ListOptions) (*v2alpha1.CronJobList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.CronJob, err error)
@@ -83,6 +84,9 @@ func (c *cronJobs) Update(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob,
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *cronJobs) UpdateStatus(cronJob *v2alpha1.CronJob) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *cronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li
}
// Get takes name of the cronJob, and returns the corresponding cronJob object, and an error if there is any.
func (c *cronJobs) Get(name string) (result *v2alpha1.CronJob, err error) {
func (c *cronJobs) Get(name string, options meta_v1.GetOptions) (result *v2alpha1.CronJob, err error) {
result = &v2alpha1.CronJob{}
err = c.client.Get().
Namespace(c.ns).
Resource("cronjobs").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeCronJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v
return err
}
func (c *FakeCronJobs) Get(name string) (result *v2alpha1.CronJob, err error) {
func (c *FakeCronJobs) Get(name string, options meta_v1.GetOptions) (result *v2alpha1.CronJob, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(cronjobsResource, c.ns, name), &v2alpha1.CronJob{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li
return err
}
func (c *FakeJobs) Get(name string) (result *v2alpha1.Job, err error) {
func (c *FakeJobs) Get(name string, options meta_v1.GetOptions) (result *v2alpha1.Job, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(jobsResource, c.ns, name), &v2alpha1.Job{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v2alpha1 "k8s.io/client-go/pkg/apis/batch/v2alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type JobInterface interface {
UpdateStatus(*v2alpha1.Job) (*v2alpha1.Job, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v2alpha1.Job, error)
Get(name string, options meta_v1.GetOptions) (*v2alpha1.Job, error)
List(opts v1.ListOptions) (*v2alpha1.JobList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v2alpha1.Job, err error)
@@ -83,6 +84,9 @@ func (c *jobs) Update(job *v2alpha1.Job) (result *v2alpha1.Job, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *jobs) UpdateStatus(job *v2alpha1.Job) (result *v2alpha1.Job, err error) {
result = &v2alpha1.Job{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *jobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOp
}
// Get takes name of the job, and returns the corresponding job object, and an error if there is any.
func (c *jobs) Get(name string) (result *v2alpha1.Job, err error) {
func (c *jobs) Get(name string, options meta_v1.GetOptions) (result *v2alpha1.Job, err error) {
result = &v2alpha1.Job{}
err = c.client.Get().
Namespace(c.ns).
Resource("jobs").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/certificates/v1alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type CertificateSigningRequestInterface interface {
UpdateStatus(*v1alpha1.CertificateSigningRequest) (*v1alpha1.CertificateSigningRequest, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1alpha1.CertificateSigningRequest, error)
Get(name string, options meta_v1.GetOptions) (*v1alpha1.CertificateSigningRequest, error)
List(opts v1.ListOptions) (*v1alpha1.CertificateSigningRequestList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.CertificateSigningRequest, err error)
@@ -79,6 +80,9 @@ func (c *certificateSigningRequests) Update(certificateSigningRequest *v1alpha1.
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *certificateSigningRequests) UpdateStatus(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) {
result = &v1alpha1.CertificateSigningRequest{}
err = c.client.Put().
@@ -112,11 +116,12 @@ func (c *certificateSigningRequests) DeleteCollection(options *v1.DeleteOptions,
}
// Get takes name of the certificateSigningRequest, and returns the corresponding certificateSigningRequest object, and an error if there is any.
func (c *certificateSigningRequests) Get(name string) (result *v1alpha1.CertificateSigningRequest, err error) {
func (c *certificateSigningRequests) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.CertificateSigningRequest, err error) {
result = &v1alpha1.CertificateSigningRequest{}
err = c.client.Get().
Resource("certificatesigningrequests").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/certificates/v1alpha1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -73,7 +74,7 @@ func (c *FakeCertificateSigningRequests) DeleteCollection(options *v1.DeleteOpti
return err
}
func (c *FakeCertificateSigningRequests) Get(name string) (result *v1alpha1.CertificateSigningRequest, err error) {
func (c *FakeCertificateSigningRequests) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.CertificateSigningRequest, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(certificatesigningrequestsResource, name), &v1alpha1.CertificateSigningRequest{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type ComponentStatusInterface interface {
Update(*v1.ComponentStatus) (*v1.ComponentStatus, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.ComponentStatus, error)
Get(name string, options meta_v1.GetOptions) (*v1.ComponentStatus, error)
List(opts v1.ListOptions) (*v1.ComponentStatusList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ComponentStatus, err error)
@@ -98,11 +99,12 @@ func (c *componentStatuses) DeleteCollection(options *v1.DeleteOptions, listOpti
}
// Get takes name of the componentStatus, and returns the corresponding componentStatus object, and an error if there is any.
func (c *componentStatuses) Get(name string) (result *v1.ComponentStatus, err error) {
func (c *componentStatuses) Get(name string, options meta_v1.GetOptions) (result *v1.ComponentStatus, err error) {
result = &v1.ComponentStatus{}
err = c.client.Get().
Resource("componentstatuses").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type ConfigMapInterface interface {
Update(*v1.ConfigMap) (*v1.ConfigMap, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.ConfigMap, error)
Get(name string, options meta_v1.GetOptions) (*v1.ConfigMap, error)
List(opts v1.ListOptions) (*v1.ConfigMapList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ConfigMap, err error)
@@ -104,12 +105,13 @@ func (c *configMaps) DeleteCollection(options *v1.DeleteOptions, listOptions v1.
}
// Get takes name of the configMap, and returns the corresponding configMap object, and an error if there is any.
func (c *configMaps) Get(name string) (result *v1.ConfigMap, err error) {
func (c *configMaps) Get(name string, options meta_v1.GetOptions) (result *v1.ConfigMap, err error) {
result = &v1.ConfigMap{}
err = c.client.Get().
Namespace(c.ns).
Resource("configmaps").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type EndpointsInterface interface {
Update(*v1.Endpoints) (*v1.Endpoints, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Endpoints, error)
Get(name string, options meta_v1.GetOptions) (*v1.Endpoints, error)
List(opts v1.ListOptions) (*v1.EndpointsList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Endpoints, err error)
@@ -104,12 +105,13 @@ func (c *endpoints) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L
}
// Get takes name of the endpoints, and returns the corresponding endpoints object, and an error if there is any.
func (c *endpoints) Get(name string) (result *v1.Endpoints, err error) {
func (c *endpoints) Get(name string, options meta_v1.GetOptions) (result *v1.Endpoints, err error) {
result = &v1.Endpoints{}
err = c.client.Get().
Namespace(c.ns).
Resource("endpoints").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type EventInterface interface {
Update(*v1.Event) (*v1.Event, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Event, error)
Get(name string, options meta_v1.GetOptions) (*v1.Event, error)
List(opts v1.ListOptions) (*v1.EventList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Event, err error)
@@ -104,12 +105,13 @@ func (c *events) DeleteCollection(options *v1.DeleteOptions, listOptions v1.List
}
// Get takes name of the event, and returns the corresponding event object, and an error if there is any.
func (c *events) Get(name string) (result *v1.Event, err error) {
func (c *events) Get(name string, options meta_v1.GetOptions) (result *v1.Event, err error) {
result = &v1.Event{}
err = c.client.Get().
Namespace(c.ns).
Resource("events").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -63,7 +64,7 @@ func (c *FakeComponentStatuses) DeleteCollection(options *v1.DeleteOptions, list
return err
}
func (c *FakeComponentStatuses) Get(name string) (result *v1.ComponentStatus, err error) {
func (c *FakeComponentStatuses) Get(name string, options meta_v1.GetOptions) (result *v1.ComponentStatus, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(componentstatusesResource, name), &v1.ComponentStatus{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeConfigMaps) DeleteCollection(options *v1.DeleteOptions, listOptions
return err
}
func (c *FakeConfigMaps) Get(name string) (result *v1.ConfigMap, err error) {
func (c *FakeConfigMaps) Get(name string, options meta_v1.GetOptions) (result *v1.ConfigMap, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(configmapsResource, c.ns, name), &v1.ConfigMap{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeEndpoints) DeleteCollection(options *v1.DeleteOptions, listOptions
return err
}
func (c *FakeEndpoints) Get(name string) (result *v1.Endpoints, err error) {
func (c *FakeEndpoints) Get(name string, options meta_v1.GetOptions) (result *v1.Endpoints, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(endpointsResource, c.ns, name), &v1.Endpoints{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeEvents) DeleteCollection(options *v1.DeleteOptions, listOptions v1.
return err
}
func (c *FakeEvents) Get(name string) (result *v1.Event, err error) {
func (c *FakeEvents) Get(name string, options meta_v1.GetOptions) (result *v1.Event, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(eventsResource, c.ns, name), &v1.Event{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeLimitRanges) DeleteCollection(options *v1.DeleteOptions, listOption
return err
}
func (c *FakeLimitRanges) Get(name string) (result *v1.LimitRange, err error) {
func (c *FakeLimitRanges) Get(name string, options meta_v1.GetOptions) (result *v1.LimitRange, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(limitrangesResource, c.ns, name), &v1.LimitRange{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -72,7 +73,7 @@ func (c *FakeNamespaces) DeleteCollection(options *v1.DeleteOptions, listOptions
return err
}
func (c *FakeNamespaces) Get(name string) (result *v1.Namespace, err error) {
func (c *FakeNamespaces) Get(name string, options meta_v1.GetOptions) (result *v1.Namespace, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(namespacesResource, name), &v1.Namespace{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -72,7 +73,7 @@ func (c *FakeNodes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L
return err
}
func (c *FakeNodes) Get(name string) (result *v1.Node, err error) {
func (c *FakeNodes) Get(name string, options meta_v1.GetOptions) (result *v1.Node, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(nodesResource, name), &v1.Node{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -72,7 +73,7 @@ func (c *FakePersistentVolumes) DeleteCollection(options *v1.DeleteOptions, list
return err
}
func (c *FakePersistentVolumes) Get(name string) (result *v1.PersistentVolume, err error) {
func (c *FakePersistentVolumes) Get(name string, options meta_v1.GetOptions) (result *v1.PersistentVolume, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(persistentvolumesResource, name), &v1.PersistentVolume{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -77,7 +78,7 @@ func (c *FakePersistentVolumeClaims) DeleteCollection(options *v1.DeleteOptions,
return err
}
func (c *FakePersistentVolumeClaims) Get(name string) (result *v1.PersistentVolumeClaim, err error) {
func (c *FakePersistentVolumeClaims) Get(name string, options meta_v1.GetOptions) (result *v1.PersistentVolumeClaim, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(persistentvolumeclaimsResource, c.ns, name), &v1.PersistentVolumeClaim{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -77,7 +78,7 @@ func (c *FakePods) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li
return err
}
func (c *FakePods) Get(name string) (result *v1.Pod, err error) {
func (c *FakePods) Get(name string, options meta_v1.GetOptions) (result *v1.Pod, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(podsResource, c.ns, name), &v1.Pod{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakePodTemplates) DeleteCollection(options *v1.DeleteOptions, listOptio
return err
}
func (c *FakePodTemplates) Get(name string) (result *v1.PodTemplate, err error) {
func (c *FakePodTemplates) Get(name string, options meta_v1.GetOptions) (result *v1.PodTemplate, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(podtemplatesResource, c.ns, name), &v1.PodTemplate{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -77,7 +78,7 @@ func (c *FakeReplicationControllers) DeleteCollection(options *v1.DeleteOptions,
return err
}
func (c *FakeReplicationControllers) Get(name string) (result *v1.ReplicationController, err error) {
func (c *FakeReplicationControllers) Get(name string, options meta_v1.GetOptions) (result *v1.ReplicationController, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(replicationcontrollersResource, c.ns, name), &v1.ReplicationController{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -77,7 +78,7 @@ func (c *FakeResourceQuotas) DeleteCollection(options *v1.DeleteOptions, listOpt
return err
}
func (c *FakeResourceQuotas) Get(name string) (result *v1.ResourceQuota, err error) {
func (c *FakeResourceQuotas) Get(name string, options meta_v1.GetOptions) (result *v1.ResourceQuota, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(resourcequotasResource, c.ns, name), &v1.ResourceQuota{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeSecrets) DeleteCollection(options *v1.DeleteOptions, listOptions v1
return err
}
func (c *FakeSecrets) Get(name string) (result *v1.Secret, err error) {
func (c *FakeSecrets) Get(name string, options meta_v1.GetOptions) (result *v1.Secret, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(secretsResource, c.ns, name), &v1.Secret{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -77,7 +78,7 @@ func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v
return err
}
func (c *FakeServices) Get(name string) (result *v1.Service, err error) {
func (c *FakeServices) Get(name string, options meta_v1.GetOptions) (result *v1.Service, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1.Service{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -67,7 +68,7 @@ func (c *FakeServiceAccounts) DeleteCollection(options *v1.DeleteOptions, listOp
return err
}
func (c *FakeServiceAccounts) Get(name string) (result *v1.ServiceAccount, err error) {
func (c *FakeServiceAccounts) Get(name string, options meta_v1.GetOptions) (result *v1.ServiceAccount, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(serviceaccountsResource, c.ns, name), &v1.ServiceAccount{})

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type LimitRangeInterface interface {
Update(*v1.LimitRange) (*v1.LimitRange, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.LimitRange, error)
Get(name string, options meta_v1.GetOptions) (*v1.LimitRange, error)
List(opts v1.ListOptions) (*v1.LimitRangeList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.LimitRange, err error)
@@ -104,12 +105,13 @@ func (c *limitRanges) DeleteCollection(options *v1.DeleteOptions, listOptions v1
}
// Get takes name of the limitRange, and returns the corresponding limitRange object, and an error if there is any.
func (c *limitRanges) Get(name string) (result *v1.LimitRange, err error) {
func (c *limitRanges) Get(name string, options meta_v1.GetOptions) (result *v1.LimitRange, err error) {
result = &v1.LimitRange{}
err = c.client.Get().
Namespace(c.ns).
Resource("limitranges").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type NamespaceInterface interface {
UpdateStatus(*v1.Namespace) (*v1.Namespace, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Namespace, error)
Get(name string, options meta_v1.GetOptions) (*v1.Namespace, error)
List(opts v1.ListOptions) (*v1.NamespaceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Namespace, err error)
@@ -78,6 +79,9 @@ func (c *namespaces) Update(namespace *v1.Namespace) (result *v1.Namespace, err
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *namespaces) UpdateStatus(namespace *v1.Namespace) (result *v1.Namespace, err error) {
result = &v1.Namespace{}
err = c.client.Put().
@@ -111,11 +115,12 @@ func (c *namespaces) DeleteCollection(options *v1.DeleteOptions, listOptions v1.
}
// Get takes name of the namespace, and returns the corresponding namespace object, and an error if there is any.
func (c *namespaces) Get(name string) (result *v1.Namespace, err error) {
func (c *namespaces) Get(name string, options meta_v1.GetOptions) (result *v1.Namespace, err error) {
result = &v1.Namespace{}
err = c.client.Get().
Resource("namespaces").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type NodeInterface interface {
UpdateStatus(*v1.Node) (*v1.Node, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Node, error)
Get(name string, options meta_v1.GetOptions) (*v1.Node, error)
List(opts v1.ListOptions) (*v1.NodeList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Node, err error)
@@ -78,6 +79,9 @@ func (c *nodes) Update(node *v1.Node) (result *v1.Node, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *nodes) UpdateStatus(node *v1.Node) (result *v1.Node, err error) {
result = &v1.Node{}
err = c.client.Put().
@@ -111,11 +115,12 @@ func (c *nodes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListO
}
// Get takes name of the node, and returns the corresponding node object, and an error if there is any.
func (c *nodes) Get(name string) (result *v1.Node, err error) {
func (c *nodes) Get(name string, options meta_v1.GetOptions) (result *v1.Node, err error) {
result = &v1.Node{}
err = c.client.Get().
Resource("nodes").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type PersistentVolumeInterface interface {
UpdateStatus(*v1.PersistentVolume) (*v1.PersistentVolume, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.PersistentVolume, error)
Get(name string, options meta_v1.GetOptions) (*v1.PersistentVolume, error)
List(opts v1.ListOptions) (*v1.PersistentVolumeList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolume, err error)
@@ -78,6 +79,9 @@ func (c *persistentVolumes) Update(persistentVolume *v1.PersistentVolume) (resul
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *persistentVolumes) UpdateStatus(persistentVolume *v1.PersistentVolume) (result *v1.PersistentVolume, err error) {
result = &v1.PersistentVolume{}
err = c.client.Put().
@@ -111,11 +115,12 @@ func (c *persistentVolumes) DeleteCollection(options *v1.DeleteOptions, listOpti
}
// Get takes name of the persistentVolume, and returns the corresponding persistentVolume object, and an error if there is any.
func (c *persistentVolumes) Get(name string) (result *v1.PersistentVolume, err error) {
func (c *persistentVolumes) Get(name string, options meta_v1.GetOptions) (result *v1.PersistentVolume, err error) {
result = &v1.PersistentVolume{}
err = c.client.Get().
Resource("persistentvolumes").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type PersistentVolumeClaimInterface interface {
UpdateStatus(*v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.PersistentVolumeClaim, error)
Get(name string, options meta_v1.GetOptions) (*v1.PersistentVolumeClaim, error)
List(opts v1.ListOptions) (*v1.PersistentVolumeClaimList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolumeClaim, err error)
@@ -82,6 +83,9 @@ func (c *persistentVolumeClaims) Update(persistentVolumeClaim *v1.PersistentVolu
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *persistentVolumeClaims) UpdateStatus(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Put().
@@ -118,12 +122,13 @@ func (c *persistentVolumeClaims) DeleteCollection(options *v1.DeleteOptions, lis
}
// Get takes name of the persistentVolumeClaim, and returns the corresponding persistentVolumeClaim object, and an error if there is any.
func (c *persistentVolumeClaims) Get(name string) (result *v1.PersistentVolumeClaim, err error) {
func (c *persistentVolumeClaims) Get(name string, options meta_v1.GetOptions) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Get().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type PodInterface interface {
UpdateStatus(*v1.Pod) (*v1.Pod, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Pod, error)
Get(name string, options meta_v1.GetOptions) (*v1.Pod, error)
List(opts v1.ListOptions) (*v1.PodList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Pod, err error)
@@ -82,6 +83,9 @@ func (c *pods) Update(pod *v1.Pod) (result *v1.Pod, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *pods) UpdateStatus(pod *v1.Pod) (result *v1.Pod, err error) {
result = &v1.Pod{}
err = c.client.Put().
@@ -118,12 +122,13 @@ func (c *pods) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOp
}
// Get takes name of the pod, and returns the corresponding pod object, and an error if there is any.
func (c *pods) Get(name string) (result *v1.Pod, err error) {
func (c *pods) Get(name string, options meta_v1.GetOptions) (result *v1.Pod, err error) {
result = &v1.Pod{}
err = c.client.Get().
Namespace(c.ns).
Resource("pods").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type PodTemplateInterface interface {
Update(*v1.PodTemplate) (*v1.PodTemplate, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.PodTemplate, error)
Get(name string, options meta_v1.GetOptions) (*v1.PodTemplate, error)
List(opts v1.ListOptions) (*v1.PodTemplateList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PodTemplate, err error)
@@ -104,12 +105,13 @@ func (c *podTemplates) DeleteCollection(options *v1.DeleteOptions, listOptions v
}
// Get takes name of the podTemplate, and returns the corresponding podTemplate object, and an error if there is any.
func (c *podTemplates) Get(name string) (result *v1.PodTemplate, err error) {
func (c *podTemplates) Get(name string, options meta_v1.GetOptions) (result *v1.PodTemplate, err error) {
result = &v1.PodTemplate{}
err = c.client.Get().
Namespace(c.ns).
Resource("podtemplates").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type ReplicationControllerInterface interface {
UpdateStatus(*v1.ReplicationController) (*v1.ReplicationController, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.ReplicationController, error)
Get(name string, options meta_v1.GetOptions) (*v1.ReplicationController, error)
List(opts v1.ListOptions) (*v1.ReplicationControllerList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ReplicationController, err error)
@@ -82,6 +83,9 @@ func (c *replicationControllers) Update(replicationController *v1.ReplicationCon
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *replicationControllers) UpdateStatus(replicationController *v1.ReplicationController) (result *v1.ReplicationController, err error) {
result = &v1.ReplicationController{}
err = c.client.Put().
@@ -118,12 +122,13 @@ func (c *replicationControllers) DeleteCollection(options *v1.DeleteOptions, lis
}
// Get takes name of the replicationController, and returns the corresponding replicationController object, and an error if there is any.
func (c *replicationControllers) Get(name string) (result *v1.ReplicationController, err error) {
func (c *replicationControllers) Get(name string, options meta_v1.GetOptions) (result *v1.ReplicationController, err error) {
result = &v1.ReplicationController{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicationcontrollers").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type ResourceQuotaInterface interface {
UpdateStatus(*v1.ResourceQuota) (*v1.ResourceQuota, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.ResourceQuota, error)
Get(name string, options meta_v1.GetOptions) (*v1.ResourceQuota, error)
List(opts v1.ListOptions) (*v1.ResourceQuotaList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ResourceQuota, err error)
@@ -82,6 +83,9 @@ func (c *resourceQuotas) Update(resourceQuota *v1.ResourceQuota) (result *v1.Res
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *resourceQuotas) UpdateStatus(resourceQuota *v1.ResourceQuota) (result *v1.ResourceQuota, err error) {
result = &v1.ResourceQuota{}
err = c.client.Put().
@@ -118,12 +122,13 @@ func (c *resourceQuotas) DeleteCollection(options *v1.DeleteOptions, listOptions
}
// Get takes name of the resourceQuota, and returns the corresponding resourceQuota object, and an error if there is any.
func (c *resourceQuotas) Get(name string) (result *v1.ResourceQuota, err error) {
func (c *resourceQuotas) Get(name string, options meta_v1.GetOptions) (result *v1.ResourceQuota, err error) {
result = &v1.ResourceQuota{}
err = c.client.Get().
Namespace(c.ns).
Resource("resourcequotas").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type SecretInterface interface {
Update(*v1.Secret) (*v1.Secret, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Secret, error)
Get(name string, options meta_v1.GetOptions) (*v1.Secret, error)
List(opts v1.ListOptions) (*v1.SecretList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Secret, err error)
@@ -104,12 +105,13 @@ func (c *secrets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Lis
}
// Get takes name of the secret, and returns the corresponding secret object, and an error if there is any.
func (c *secrets) Get(name string) (result *v1.Secret, err error) {
func (c *secrets) Get(name string, options meta_v1.GetOptions) (result *v1.Secret, err error) {
result = &v1.Secret{}
err = c.client.Get().
Namespace(c.ns).
Resource("secrets").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type ServiceInterface interface {
UpdateStatus(*v1.Service) (*v1.Service, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.Service, error)
Get(name string, options meta_v1.GetOptions) (*v1.Service, error)
List(opts v1.ListOptions) (*v1.ServiceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.Service, err error)
@@ -82,6 +83,9 @@ func (c *services) Update(service *v1.Service) (result *v1.Service, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *services) UpdateStatus(service *v1.Service) (result *v1.Service, err error) {
result = &v1.Service{}
err = c.client.Put().
@@ -118,12 +122,13 @@ func (c *services) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li
}
// Get takes name of the service, and returns the corresponding service object, and an error if there is any.
func (c *services) Get(name string) (result *v1.Service, err error) {
func (c *services) Get(name string, options meta_v1.GetOptions) (result *v1.Service, err error) {
result = &v1.Service{}
err = c.client.Get().
Namespace(c.ns).
Resource("services").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -35,7 +36,7 @@ type ServiceAccountInterface interface {
Update(*v1.ServiceAccount) (*v1.ServiceAccount, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1.ServiceAccount, error)
Get(name string, options meta_v1.GetOptions) (*v1.ServiceAccount, error)
List(opts v1.ListOptions) (*v1.ServiceAccountList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.ServiceAccount, err error)
@@ -104,12 +105,13 @@ func (c *serviceAccounts) DeleteCollection(options *v1.DeleteOptions, listOption
}
// Get takes name of the serviceAccount, and returns the corresponding serviceAccount object, and an error if there is any.
func (c *serviceAccounts) Get(name string) (result *v1.ServiceAccount, err error) {
func (c *serviceAccounts) Get(name string, options meta_v1.GetOptions) (result *v1.ServiceAccount, err error) {
result = &v1.ServiceAccount{}
err = c.client.Get().
Namespace(c.ns).
Resource("serviceaccounts").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type DaemonSetInterface interface {
UpdateStatus(*v1beta1.DaemonSet) (*v1beta1.DaemonSet, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.DaemonSet, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.DaemonSet, error)
List(opts v1.ListOptions) (*v1beta1.DaemonSetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.DaemonSet, err error)
@@ -83,6 +84,9 @@ func (c *daemonSets) Update(daemonSet *v1beta1.DaemonSet) (result *v1beta1.Daemo
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *daemonSets) UpdateStatus(daemonSet *v1beta1.DaemonSet) (result *v1beta1.DaemonSet, err error) {
result = &v1beta1.DaemonSet{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *daemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions v1.
}
// Get takes name of the daemonSet, and returns the corresponding daemonSet object, and an error if there is any.
func (c *daemonSets) Get(name string) (result *v1beta1.DaemonSet, err error) {
func (c *daemonSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.DaemonSet, err error) {
result = &v1beta1.DaemonSet{}
err = c.client.Get().
Namespace(c.ns).
Resource("daemonsets").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type DeploymentInterface interface {
UpdateStatus(*v1beta1.Deployment) (*v1beta1.Deployment, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.Deployment, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.Deployment, error)
List(opts v1.ListOptions) (*v1beta1.DeploymentList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.Deployment, err error)
@@ -83,6 +84,9 @@ func (c *deployments) Update(deployment *v1beta1.Deployment) (result *v1beta1.De
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *deployments) UpdateStatus(deployment *v1beta1.Deployment) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *deployments) DeleteCollection(options *v1.DeleteOptions, listOptions v1
}
// Get takes name of the deployment, and returns the corresponding deployment object, and an error if there is any.
func (c *deployments) Get(name string) (result *v1beta1.Deployment, err error) {
func (c *deployments) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Deployment, err error) {
result = &v1beta1.Deployment{}
err = c.client.Get().
Namespace(c.ns).
Resource("deployments").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeDaemonSets) DeleteCollection(options *v1.DeleteOptions, listOptions
return err
}
func (c *FakeDaemonSets) Get(name string) (result *v1beta1.DaemonSet, err error) {
func (c *FakeDaemonSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.DaemonSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(daemonsetsResource, c.ns, name), &v1beta1.DaemonSet{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeDeployments) DeleteCollection(options *v1.DeleteOptions, listOption
return err
}
func (c *FakeDeployments) Get(name string) (result *v1beta1.Deployment, err error) {
func (c *FakeDeployments) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Deployment, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(deploymentsResource, c.ns, name), &v1beta1.Deployment{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions
return err
}
func (c *FakeIngresses) Get(name string) (result *v1beta1.Ingress, err error) {
func (c *FakeIngresses) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Ingress, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(ingressesResource, c.ns, name), &v1beta1.Ingress{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeJobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.Li
return err
}
func (c *FakeJobs) Get(name string) (result *v1beta1.Job, err error) {
func (c *FakeJobs) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Job, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(jobsResource, c.ns, name), &v1beta1.Job{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -64,7 +65,7 @@ func (c *FakePodSecurityPolicies) DeleteCollection(options *v1.DeleteOptions, li
return err
}
func (c *FakePodSecurityPolicies) Get(name string) (result *v1beta1.PodSecurityPolicy, err error) {
func (c *FakePodSecurityPolicies) Get(name string, options meta_v1.GetOptions) (result *v1beta1.PodSecurityPolicy, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(podsecuritypoliciesResource, name), &v1beta1.PodSecurityPolicy{})
if obj == nil {

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -78,7 +79,7 @@ func (c *FakeReplicaSets) DeleteCollection(options *v1.DeleteOptions, listOption
return err
}
func (c *FakeReplicaSets) Get(name string) (result *v1beta1.ReplicaSet, err error) {
func (c *FakeReplicaSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.ReplicaSet, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(replicasetsResource, c.ns, name), &v1beta1.ReplicaSet{})

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
watch "k8s.io/client-go/pkg/watch"
@@ -64,7 +65,7 @@ func (c *FakeThirdPartyResources) DeleteCollection(options *v1.DeleteOptions, li
return err
}
func (c *FakeThirdPartyResources) Get(name string) (result *v1beta1.ThirdPartyResource, err error) {
func (c *FakeThirdPartyResources) Get(name string, options meta_v1.GetOptions) (result *v1beta1.ThirdPartyResource, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(thirdpartyresourcesResource, name), &v1beta1.ThirdPartyResource{})
if obj == nil {

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type IngressInterface interface {
UpdateStatus(*v1beta1.Ingress) (*v1beta1.Ingress, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.Ingress, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.Ingress, error)
List(opts v1.ListOptions) (*v1beta1.IngressList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.Ingress, err error)
@@ -83,6 +84,9 @@ func (c *ingresses) Update(ingress *v1beta1.Ingress) (result *v1beta1.Ingress, e
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *ingresses) UpdateStatus(ingress *v1beta1.Ingress) (result *v1beta1.Ingress, err error) {
result = &v1beta1.Ingress{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *ingresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L
}
// Get takes name of the ingress, and returns the corresponding ingress object, and an error if there is any.
func (c *ingresses) Get(name string) (result *v1beta1.Ingress, err error) {
func (c *ingresses) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Ingress, err error) {
result = &v1beta1.Ingress{}
err = c.client.Get().
Namespace(c.ns).
Resource("ingresses").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type JobInterface interface {
UpdateStatus(*v1beta1.Job) (*v1beta1.Job, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.Job, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.Job, error)
List(opts v1.ListOptions) (*v1beta1.JobList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.Job, err error)
@@ -83,6 +84,9 @@ func (c *jobs) Update(job *v1beta1.Job) (result *v1beta1.Job, err error) {
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *jobs) UpdateStatus(job *v1beta1.Job) (result *v1beta1.Job, err error) {
result = &v1beta1.Job{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *jobs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOp
}
// Get takes name of the job, and returns the corresponding job object, and an error if there is any.
func (c *jobs) Get(name string) (result *v1beta1.Job, err error) {
func (c *jobs) Get(name string, options meta_v1.GetOptions) (result *v1beta1.Job, err error) {
result = &v1beta1.Job{}
err = c.client.Get().
Namespace(c.ns).
Resource("jobs").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type PodSecurityPolicyInterface interface {
Update(*v1beta1.PodSecurityPolicy) (*v1beta1.PodSecurityPolicy, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.PodSecurityPolicy, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.PodSecurityPolicy, error)
List(opts v1.ListOptions) (*v1beta1.PodSecurityPolicyList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.PodSecurityPolicy, err error)
@@ -99,11 +100,12 @@ func (c *podSecurityPolicies) DeleteCollection(options *v1.DeleteOptions, listOp
}
// Get takes name of the podSecurityPolicy, and returns the corresponding podSecurityPolicy object, and an error if there is any.
func (c *podSecurityPolicies) Get(name string) (result *v1beta1.PodSecurityPolicy, err error) {
func (c *podSecurityPolicies) Get(name string, options meta_v1.GetOptions) (result *v1beta1.PodSecurityPolicy, err error) {
result = &v1beta1.PodSecurityPolicy{}
err = c.client.Get().
Resource("podsecuritypolicies").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -37,7 +38,7 @@ type ReplicaSetInterface interface {
UpdateStatus(*v1beta1.ReplicaSet) (*v1beta1.ReplicaSet, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.ReplicaSet, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.ReplicaSet, error)
List(opts v1.ListOptions) (*v1beta1.ReplicaSetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.ReplicaSet, err error)
@@ -83,6 +84,9 @@ func (c *replicaSets) Update(replicaSet *v1beta1.ReplicaSet) (result *v1beta1.Re
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *replicaSets) UpdateStatus(replicaSet *v1beta1.ReplicaSet) (result *v1beta1.ReplicaSet, err error) {
result = &v1beta1.ReplicaSet{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *replicaSets) DeleteCollection(options *v1.DeleteOptions, listOptions v1
}
// Get takes name of the replicaSet, and returns the corresponding replicaSet object, and an error if there is any.
func (c *replicaSets) Get(name string) (result *v1beta1.ReplicaSet, err error) {
func (c *replicaSets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.ReplicaSet, err error) {
result = &v1beta1.ReplicaSet{}
err = c.client.Get().
Namespace(c.ns).
Resource("replicasets").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -20,6 +20,7 @@ import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
v1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
)
@@ -36,7 +37,7 @@ type ThirdPartyResourceInterface interface {
Update(*v1beta1.ThirdPartyResource) (*v1beta1.ThirdPartyResource, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.ThirdPartyResource, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.ThirdPartyResource, error)
List(opts v1.ListOptions) (*v1beta1.ThirdPartyResourceList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.ThirdPartyResource, err error)
@@ -99,11 +100,12 @@ func (c *thirdPartyResources) DeleteCollection(options *v1.DeleteOptions, listOp
}
// Get takes name of the thirdPartyResource, and returns the corresponding thirdPartyResource object, and an error if there is any.
func (c *thirdPartyResources) Get(name string) (result *v1beta1.ThirdPartyResource, err error) {
func (c *thirdPartyResources) Get(name string, options meta_v1.GetOptions) (result *v1beta1.ThirdPartyResource, err error) {
result = &v1beta1.ThirdPartyResource{}
err = c.client.Get().
Resource("thirdpartyresources").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -0,0 +1,46 @@
/*
Copyright 2016 The Kubernetes Authors.
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 v1beta1
import (
rest "k8s.io/client-go/rest"
)
// EvictionsGetter has a method to return a EvictionInterface.
// A group's client should implement this interface.
type EvictionsGetter interface {
Evictions(namespace string) EvictionInterface
}
// EvictionInterface has methods to work with Eviction resources.
type EvictionInterface interface {
EvictionExpansion
}
// evictions implements EvictionInterface
type evictions struct {
client rest.Interface
ns string
}
// newEvictions returns a Evictions
func newEvictions(c *PolicyV1beta1Client, namespace string) *evictions {
return &evictions{
client: c.RESTClient(),
ns: namespace,
}
}

View File

@@ -0,0 +1,38 @@
/*
Copyright 2016 The Kubernetes Authors.
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 v1beta1
import (
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
)
// The EvictionExpansion interface allows manually adding extra methods to the ScaleInterface.
type EvictionExpansion interface {
Evict(eviction *policy.Eviction) error
}
func (c *evictions) Evict(eviction *policy.Eviction) error {
return c.client.Post().
AbsPath("/api/v1").
Namespace(eviction.Namespace).
Resource("pods").
Name(eviction.Name).
SubResource("eviction").
Body(eviction).
Do().
Error()
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2014 The Kubernetes Authors.
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,17 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// The types defined in this package are used by the meta package to represent
// the in-memory version of objects. We cannot reuse the __internal version of
// API objects because it causes import cycle.
package metatypes
package fake
import "k8s.io/client-go/pkg/types"
type OwnerReference struct {
APIVersion string
Kind string
UID types.UID
Name string
Controller *bool
// FakeEvictions implements EvictionInterface
type FakeEvictions struct {
Fake *FakePolicyV1beta1
ns string
}

View File

@@ -0,0 +1,33 @@
/*
Copyright 2016 The Kubernetes Authors.
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 fake
import (
policy "k8s.io/client-go/pkg/apis/policy/v1beta1"
"k8s.io/client-go/pkg/runtime/schema"
testing "k8s.io/client-go/testing"
)
func (c *FakeEvictions) Evict(eviction *policy.Eviction) error {
action := testing.GetActionImpl{}
action.Verb = "post"
action.Namespace = c.ns
action.Resource = schema.GroupVersionResource{Group: "", Version: "", Resource: "pods"}
action.Subresource = "eviction"
_, err := c.Fake.Invokes(action, eviction)
return err
}

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -78,7 +79,7 @@ func (c *FakePodDisruptionBudgets) DeleteCollection(options *v1.DeleteOptions, l
return err
}
func (c *FakePodDisruptionBudgets) Get(name string) (result *v1beta1.PodDisruptionBudget, err error) {
func (c *FakePodDisruptionBudgets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.PodDisruptionBudget, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(poddisruptionbudgetsResource, c.ns, name), &v1beta1.PodDisruptionBudget{})

View File

@@ -26,6 +26,10 @@ type FakePolicyV1beta1 struct {
*testing.Fake
}
func (c *FakePolicyV1beta1) Evictions(namespace string) v1beta1.EvictionInterface {
return &FakeEvictions{c, namespace}
}
func (c *FakePolicyV1beta1) PodDisruptionBudgets(namespace string) v1beta1.PodDisruptionBudgetInterface {
return &FakePodDisruptionBudgets{c, namespace}
}

View File

@@ -19,6 +19,7 @@ package v1beta1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -37,7 +38,7 @@ type PodDisruptionBudgetInterface interface {
UpdateStatus(*v1beta1.PodDisruptionBudget) (*v1beta1.PodDisruptionBudget, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.PodDisruptionBudget, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.PodDisruptionBudget, error)
List(opts v1.ListOptions) (*v1beta1.PodDisruptionBudgetList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.PodDisruptionBudget, err error)
@@ -83,6 +84,9 @@ func (c *podDisruptionBudgets) Update(podDisruptionBudget *v1beta1.PodDisruption
return
}
// UpdateStatus was generated because the type contains a Status member.
// Add a +genclientstatus=false comment above the type to avoid generating UpdateStatus().
func (c *podDisruptionBudgets) UpdateStatus(podDisruptionBudget *v1beta1.PodDisruptionBudget) (result *v1beta1.PodDisruptionBudget, err error) {
result = &v1beta1.PodDisruptionBudget{}
err = c.client.Put().
@@ -119,12 +123,13 @@ func (c *podDisruptionBudgets) DeleteCollection(options *v1.DeleteOptions, listO
}
// Get takes name of the podDisruptionBudget, and returns the corresponding podDisruptionBudget object, and an error if there is any.
func (c *podDisruptionBudgets) Get(name string) (result *v1beta1.PodDisruptionBudget, err error) {
func (c *podDisruptionBudgets) Get(name string, options meta_v1.GetOptions) (result *v1beta1.PodDisruptionBudget, err error) {
result = &v1beta1.PodDisruptionBudget{}
err = c.client.Get().
Namespace(c.ns).
Resource("poddisruptionbudgets").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -27,6 +27,7 @@ import (
type PolicyV1beta1Interface interface {
RESTClient() rest.Interface
EvictionsGetter
PodDisruptionBudgetsGetter
}
@@ -35,6 +36,10 @@ type PolicyV1beta1Client struct {
restClient rest.Interface
}
func (c *PolicyV1beta1Client) Evictions(namespace string) EvictionInterface {
return newEvictions(c, namespace)
}
func (c *PolicyV1beta1Client) PodDisruptionBudgets(namespace string) PodDisruptionBudgetInterface {
return newPodDisruptionBudgets(c, namespace)
}

View File

@@ -19,6 +19,7 @@ package v1alpha1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -36,7 +37,7 @@ type ClusterRoleInterface interface {
Update(*v1alpha1.ClusterRole) (*v1alpha1.ClusterRole, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1alpha1.ClusterRole, error)
Get(name string, options meta_v1.GetOptions) (*v1alpha1.ClusterRole, error)
List(opts v1.ListOptions) (*v1alpha1.ClusterRoleList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRole, err error)
@@ -99,11 +100,12 @@ func (c *clusterRoles) DeleteCollection(options *v1.DeleteOptions, listOptions v
}
// Get takes name of the clusterRole, and returns the corresponding clusterRole object, and an error if there is any.
func (c *clusterRoles) Get(name string) (result *v1alpha1.ClusterRole, err error) {
func (c *clusterRoles) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.ClusterRole, err error) {
result = &v1alpha1.ClusterRole{}
err = c.client.Get().
Resource("clusterroles").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1alpha1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -36,7 +37,7 @@ type ClusterRoleBindingInterface interface {
Update(*v1alpha1.ClusterRoleBinding) (*v1alpha1.ClusterRoleBinding, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1alpha1.ClusterRoleBinding, error)
Get(name string, options meta_v1.GetOptions) (*v1alpha1.ClusterRoleBinding, error)
List(opts v1.ListOptions) (*v1alpha1.ClusterRoleBindingList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error)
@@ -99,11 +100,12 @@ func (c *clusterRoleBindings) DeleteCollection(options *v1.DeleteOptions, listOp
}
// Get takes name of the clusterRoleBinding, and returns the corresponding clusterRoleBinding object, and an error if there is any.
func (c *clusterRoleBindings) Get(name string) (result *v1alpha1.ClusterRoleBinding, err error) {
func (c *clusterRoleBindings) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.ClusterRoleBinding, err error) {
result = &v1alpha1.ClusterRoleBinding{}
err = c.client.Get().
Resource("clusterrolebindings").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -64,7 +65,7 @@ func (c *FakeClusterRoles) DeleteCollection(options *v1.DeleteOptions, listOptio
return err
}
func (c *FakeClusterRoles) Get(name string) (result *v1alpha1.ClusterRole, err error) {
func (c *FakeClusterRoles) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.ClusterRole, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(clusterrolesResource, name), &v1alpha1.ClusterRole{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -64,7 +65,7 @@ func (c *FakeClusterRoleBindings) DeleteCollection(options *v1.DeleteOptions, li
return err
}
func (c *FakeClusterRoleBindings) Get(name string) (result *v1alpha1.ClusterRoleBinding, err error) {
func (c *FakeClusterRoleBindings) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.ClusterRoleBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(clusterrolebindingsResource, name), &v1alpha1.ClusterRoleBinding{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -68,7 +69,7 @@ func (c *FakeRoles) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L
return err
}
func (c *FakeRoles) Get(name string) (result *v1alpha1.Role, err error) {
func (c *FakeRoles) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.Role, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(rolesResource, c.ns, name), &v1alpha1.Role{})

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -68,7 +69,7 @@ func (c *FakeRoleBindings) DeleteCollection(options *v1.DeleteOptions, listOptio
return err
}
func (c *FakeRoleBindings) Get(name string) (result *v1alpha1.RoleBinding, err error) {
func (c *FakeRoleBindings) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.RoleBinding, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(rolebindingsResource, c.ns, name), &v1alpha1.RoleBinding{})

View File

@@ -19,6 +19,7 @@ package v1alpha1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -36,7 +37,7 @@ type RoleInterface interface {
Update(*v1alpha1.Role) (*v1alpha1.Role, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1alpha1.Role, error)
Get(name string, options meta_v1.GetOptions) (*v1alpha1.Role, error)
List(opts v1.ListOptions) (*v1alpha1.RoleList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.Role, err error)
@@ -105,12 +106,13 @@ func (c *roles) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListO
}
// Get takes name of the role, and returns the corresponding role object, and an error if there is any.
func (c *roles) Get(name string) (result *v1alpha1.Role, err error) {
func (c *roles) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.Role, err error) {
result = &v1alpha1.Role{}
err = c.client.Get().
Namespace(c.ns).
Resource("roles").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package v1alpha1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1alpha1 "k8s.io/client-go/pkg/apis/rbac/v1alpha1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -36,7 +37,7 @@ type RoleBindingInterface interface {
Update(*v1alpha1.RoleBinding) (*v1alpha1.RoleBinding, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1alpha1.RoleBinding, error)
Get(name string, options meta_v1.GetOptions) (*v1alpha1.RoleBinding, error)
List(opts v1.ListOptions) (*v1alpha1.RoleBindingList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error)
@@ -105,12 +106,13 @@ func (c *roleBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v
}
// Get takes name of the roleBinding, and returns the corresponding roleBinding object, and an error if there is any.
func (c *roleBindings) Get(name string) (result *v1alpha1.RoleBinding, err error) {
func (c *roleBindings) Get(name string, options meta_v1.GetOptions) (result *v1alpha1.RoleBinding, err error) {
result = &v1alpha1.RoleBinding{}
err = c.client.Get().
Namespace(c.ns).
Resource("rolebindings").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -19,6 +19,7 @@ package fake
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1beta1 "k8s.io/client-go/pkg/apis/storage/v1beta1"
labels "k8s.io/client-go/pkg/labels"
schema "k8s.io/client-go/pkg/runtime/schema"
@@ -64,7 +65,7 @@ func (c *FakeStorageClasses) DeleteCollection(options *v1.DeleteOptions, listOpt
return err
}
func (c *FakeStorageClasses) Get(name string) (result *v1beta1.StorageClass, err error) {
func (c *FakeStorageClasses) Get(name string, options meta_v1.GetOptions) (result *v1beta1.StorageClass, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(storageclassesResource, name), &v1beta1.StorageClass{})
if obj == nil {

View File

@@ -19,6 +19,7 @@ package v1beta1
import (
api "k8s.io/client-go/pkg/api"
v1 "k8s.io/client-go/pkg/api/v1"
meta_v1 "k8s.io/client-go/pkg/apis/meta/v1"
v1beta1 "k8s.io/client-go/pkg/apis/storage/v1beta1"
watch "k8s.io/client-go/pkg/watch"
rest "k8s.io/client-go/rest"
@@ -36,7 +37,7 @@ type StorageClassInterface interface {
Update(*v1beta1.StorageClass) (*v1beta1.StorageClass, error)
Delete(name string, options *v1.DeleteOptions) error
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
Get(name string) (*v1beta1.StorageClass, error)
Get(name string, options meta_v1.GetOptions) (*v1beta1.StorageClass, error)
List(opts v1.ListOptions) (*v1beta1.StorageClassList, error)
Watch(opts v1.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.StorageClass, err error)
@@ -99,11 +100,12 @@ func (c *storageClasses) DeleteCollection(options *v1.DeleteOptions, listOptions
}
// Get takes name of the storageClass, and returns the corresponding storageClass object, and an error if there is any.
func (c *storageClasses) Get(name string) (result *v1beta1.StorageClass, err error) {
func (c *storageClasses) Get(name string, options meta_v1.GetOptions) (result *v1beta1.StorageClass, err error) {
result = &v1beta1.StorageClass{}
err = c.client.Get().
Resource("storageclasses").
Name(name).
VersionedParams(&options, api.ParameterCodec).
Do().
Into(result)
return

View File

@@ -18,7 +18,6 @@ package api
import (
"k8s.io/client-go/pkg/api/meta"
"k8s.io/client-go/pkg/api/meta/metatypes"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/conversion"
"k8s.io/client-go/pkg/runtime"
@@ -102,8 +101,8 @@ func (meta *ObjectMeta) SetAnnotations(annotations map[string]string) { meta.Ann
func (meta *ObjectMeta) GetFinalizers() []string { return meta.Finalizers }
func (meta *ObjectMeta) SetFinalizers(finalizers []string) { meta.Finalizers = finalizers }
func (meta *ObjectMeta) GetOwnerReferences() []metatypes.OwnerReference {
ret := make([]metatypes.OwnerReference, len(meta.OwnerReferences))
func (meta *ObjectMeta) GetOwnerReferences() []metav1.OwnerReference {
ret := make([]metav1.OwnerReference, len(meta.OwnerReferences))
for i := 0; i < len(meta.OwnerReferences); i++ {
ret[i].Kind = meta.OwnerReferences[i].Kind
ret[i].Name = meta.OwnerReferences[i].Name
@@ -117,8 +116,8 @@ func (meta *ObjectMeta) GetOwnerReferences() []metatypes.OwnerReference {
return ret
}
func (meta *ObjectMeta) SetOwnerReferences(references []metatypes.OwnerReference) {
newReferences := make([]OwnerReference, len(references))
func (meta *ObjectMeta) SetOwnerReferences(references []metav1.OwnerReference) {
newReferences := make([]metav1.OwnerReference, len(references))
for i := 0; i < len(references); i++ {
newReferences[i].Kind = references[i].Kind
newReferences[i].Name = references[i].Name

View File

@@ -26,12 +26,10 @@ import (
// IsListType returns true if the provided Object has a slice called Items
func IsListType(obj runtime.Object) bool {
// if we're a runtime.Unstructured, check to see if we have an `items` key
// This is a list type for recognition, but other Items type methods will fail on it
// and give you errors.
if unstructured, ok := obj.(*runtime.Unstructured); ok {
_, ok := unstructured.Object["items"]
return ok
// if we're a runtime.Unstructured, check whether this is a list.
// TODO: refactor GetItemsPtr to use an interface that returns []runtime.Object
if unstructured, ok := obj.(runtime.Unstructured); ok {
return unstructured.IsList()
}
_, err := GetItemsPtr(obj)

View File

@@ -17,8 +17,8 @@ limitations under the License.
package meta
import (
"k8s.io/client-go/pkg/api/meta/metatypes"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/pkg/runtime"
"k8s.io/client-go/pkg/runtime/schema"
"k8s.io/client-go/pkg/types"
@@ -61,13 +61,14 @@ type Object interface {
SetAnnotations(annotations map[string]string)
GetFinalizers() []string
SetFinalizers(finalizers []string)
GetOwnerReferences() []metatypes.OwnerReference
SetOwnerReferences([]metatypes.OwnerReference)
GetOwnerReferences() []metav1.OwnerReference
SetOwnerReferences([]metav1.OwnerReference)
GetClusterName() string
SetClusterName(clusterName string)
}
var _ Object = &runtime.Unstructured{}
// TODO: move me to pkg/apis/meta/v1/unstructured once Object is moved to pkg/apis/meta/v1
var _ Object = &unstructured.Unstructured{}
type ListMetaAccessor interface {
GetListMeta() List
@@ -177,8 +178,10 @@ type RESTMapper interface {
// RESTMapping identifies a preferred resource mapping for the provided group kind.
RESTMapping(gk schema.GroupKind, versions ...string) (*RESTMapping, error)
// RESTMappings returns all resource mappings for the provided group kind.
RESTMappings(gk schema.GroupKind) ([]*RESTMapping, error)
// RESTMappings returns all resource mappings for the provided group kind if no
// version search is provided. Otherwise identifies a preferred resource mapping for
// the provided version(s).
RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error)
AliasesForResource(resource string) ([]string, bool)
ResourceSingularizer(resource string) (singular string, err error)

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"reflect"
"k8s.io/client-go/pkg/api/meta/metatypes"
metav1 "k8s.io/client-go/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/conversion"
"k8s.io/client-go/pkg/runtime"
@@ -314,7 +313,7 @@ func (resourceAccessor) SetResourceVersion(obj runtime.Object, version string) e
}
// extractFromOwnerReference extracts v to o. v is the OwnerReferences field of an object.
func extractFromOwnerReference(v reflect.Value, o *metatypes.OwnerReference) error {
func extractFromOwnerReference(v reflect.Value, o *metav1.OwnerReference) error {
if err := runtime.Field(v, "APIVersion", &o.APIVersion); err != nil {
return err
}
@@ -339,7 +338,7 @@ func extractFromOwnerReference(v reflect.Value, o *metatypes.OwnerReference) err
}
// setOwnerReference sets v to o. v is the OwnerReferences field of an object.
func setOwnerReference(v reflect.Value, o *metatypes.OwnerReference) error {
func setOwnerReference(v reflect.Value, o *metav1.OwnerReference) error {
if err := runtime.SetField(o.APIVersion, v, "APIVersion"); err != nil {
return err
}
@@ -521,8 +520,8 @@ func (a genericAccessor) SetFinalizers(finalizers []string) {
*a.finalizers = finalizers
}
func (a genericAccessor) GetOwnerReferences() []metatypes.OwnerReference {
var ret []metatypes.OwnerReference
func (a genericAccessor) GetOwnerReferences() []metav1.OwnerReference {
var ret []metav1.OwnerReference
s := a.ownerReferences
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
glog.Errorf("expect %v to be a pointer to slice", s)
@@ -530,7 +529,7 @@ func (a genericAccessor) GetOwnerReferences() []metatypes.OwnerReference {
}
s = s.Elem()
// Set the capacity to one element greater to avoid copy if the caller later append an element.
ret = make([]metatypes.OwnerReference, s.Len(), s.Len()+1)
ret = make([]metav1.OwnerReference, s.Len(), s.Len()+1)
for i := 0; i < s.Len(); i++ {
if err := extractFromOwnerReference(s.Index(i), &ret[i]); err != nil {
glog.Errorf("extractFromOwnerReference failed: %v", err)
@@ -540,7 +539,7 @@ func (a genericAccessor) GetOwnerReferences() []metatypes.OwnerReference {
return ret
}
func (a genericAccessor) SetOwnerReferences(references []metatypes.OwnerReference) {
func (a genericAccessor) SetOwnerReferences(references []metav1.OwnerReference) {
s := a.ownerReferences
if s.Kind() != reflect.Ptr || s.Elem().Kind() != reflect.Slice {
glog.Errorf("expect %v to be a pointer to slice", s)

View File

@@ -185,12 +185,12 @@ func (m MultiRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*
// RESTMappings returns all possible RESTMappings for the provided group kind, or an error
// if the type is not recognized.
func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind) ([]*RESTMapping, error) {
func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error) {
var allMappings []*RESTMapping
var errors []error
for _, t := range m {
currMappings, err := t.RESTMappings(gk)
currMappings, err := t.RESTMappings(gk, versions...)
// ignore "no match" errors, but any other error percolates back up
if IsNoMatchError(err) {
continue

View File

@@ -205,8 +205,8 @@ func (m PriorityRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
return nil, &AmbiguousKindError{PartialKind: gk.WithVersion(""), MatchingKinds: kinds}
}
func (m PriorityRESTMapper) RESTMappings(gk schema.GroupKind) ([]*RESTMapping, error) {
return m.Delegate.RESTMappings(gk)
func (m PriorityRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error) {
return m.Delegate.RESTMappings(gk, versions...)
}
func (m PriorityRESTMapper) AliasesForResource(alias string) (aliases []string, ok bool) {

View File

@@ -468,91 +468,56 @@ func (o resourceByPreferredGroupVersion) Less(i, j int) bool {
// RESTClient should use to operate on the provided group/kind in order of versions. If a version search
// order is not provided, the search order provided to DefaultRESTMapper will be used to resolve which
// version should be used to access the named group/kind.
// TODO: consider refactoring to use RESTMappings in a way that preserves version ordering and preference
func (m *DefaultRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (*RESTMapping, error) {
// Pick an appropriate version
var gvk *schema.GroupVersionKind
mappings, err := m.RESTMappings(gk, versions...)
if err != nil {
return nil, err
}
if len(mappings) == 0 {
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
}
// since we rely on RESTMappings method
// take the first match and return to the caller
// as this was the existing behavior.
return mappings[0], nil
}
// RESTMappings returns the RESTMappings for the provided group kind. If a version search order
// is not provided, the search order provided to DefaultRESTMapper will be used.
func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error) {
mappings := make([]*RESTMapping, 0)
potentialGVK := make([]schema.GroupVersionKind, 0)
hadVersion := false
// Pick an appropriate version
for _, version := range versions {
if len(version) == 0 || version == runtime.APIVersionInternal {
continue
}
currGVK := gk.WithVersion(version)
hadVersion = true
if _, ok := m.kindToPluralResource[currGVK]; ok {
gvk = &currGVK
potentialGVK = append(potentialGVK, currGVK)
break
}
}
// Use the default preferred versions
if !hadVersion && (gvk == nil) {
if !hadVersion && len(potentialGVK) == 0 {
for _, gv := range m.defaultGroupVersions {
if gv.Group != gk.Group {
continue
}
currGVK := gk.WithVersion(gv.Version)
if _, ok := m.kindToPluralResource[currGVK]; ok {
gvk = &currGVK
break
}
potentialGVK = append(potentialGVK, gk.WithVersion(gv.Version))
}
}
if gvk == nil {
if len(potentialGVK) == 0 {
return nil, &NoKindMatchError{PartialKind: gk.WithVersion("")}
}
// Ensure we have a REST mapping
resource, ok := m.kindToPluralResource[*gvk]
if !ok {
found := []schema.GroupVersion{}
for _, gv := range m.defaultGroupVersions {
if _, ok := m.kindToPluralResource[*gvk]; ok {
found = append(found, gv)
}
}
if len(found) > 0 {
return nil, fmt.Errorf("object with kind %q exists in versions %v, not %v", gvk.Kind, found, gvk.GroupVersion().String())
}
return nil, fmt.Errorf("the provided version %q and kind %q cannot be mapped to a supported object", gvk.GroupVersion().String(), gvk.Kind)
}
// Ensure we have a REST scope
scope, ok := m.kindToScope[*gvk]
if !ok {
return nil, fmt.Errorf("the provided version %q and kind %q cannot be mapped to a supported scope", gvk.GroupVersion().String(), gvk.Kind)
}
interfaces, err := m.interfacesFunc(gvk.GroupVersion())
if err != nil {
return nil, fmt.Errorf("the provided version %q has no relevant versions: %v", gvk.GroupVersion().String(), err)
}
retVal := &RESTMapping{
Resource: resource.Resource,
GroupVersionKind: *gvk,
Scope: scope,
ObjectConvertor: interfaces.ObjectConvertor,
MetadataAccessor: interfaces.MetadataAccessor,
}
return retVal, nil
}
// RESTMappings returns the RESTMappings for the provided group kind in a rough internal preferred order. If no
// kind is found it will return a NoResourceMatchError.
func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind) ([]*RESTMapping, error) {
// Use the default preferred versions
var mappings []*RESTMapping
for _, gv := range m.defaultGroupVersions {
if gv.Group != gk.Group {
continue
}
gvk := gk.WithVersion(gv.Version)
gvr, ok := m.kindToPluralResource[gvk]
for _, gvk := range potentialGVK {
//Ensure we have a REST mapping
res, ok := m.kindToPluralResource[gvk]
if !ok {
continue
}
@@ -569,7 +534,7 @@ func (m *DefaultRESTMapper) RESTMappings(gk schema.GroupKind) ([]*RESTMapping, e
}
mappings = append(mappings, &RESTMapping{
Resource: gvr.Resource,
Resource: res.Resource,
GroupVersionKind: gvk,
Scope: scope,

Some files were not shown because too many files have changed in this diff Show More