mirror of
https://github.com/kubernetes/client-go.git
synced 2026-05-15 11:43:33 +00:00
Compare commits
23 Commits
release-1.
...
v0.23.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14fa49e736 | ||
|
|
a475c28713 | ||
|
|
8041ba924b | ||
|
|
0c2c708257 | ||
|
|
9b9e45fc6d | ||
|
|
ad6be0fa0b | ||
|
|
a26f2df3da | ||
|
|
b6f49c1554 | ||
|
|
0f7ee7041f | ||
|
|
42bda1a0ce | ||
|
|
857d6f1290 | ||
|
|
94fb0d02e4 | ||
|
|
f739adfab1 | ||
|
|
3074be12fe | ||
|
|
8ae6aa22f3 | ||
|
|
72a8f7483f | ||
|
|
d333414f84 | ||
|
|
c752eaaf05 | ||
|
|
17bbf03b1c | ||
|
|
1d1035d4c3 | ||
|
|
f3c25ef2e8 | ||
|
|
0d944767ec | ||
|
|
3f1288c57f |
@@ -24,7 +24,7 @@ type ProbeHandlerApplyConfiguration struct {
|
||||
Exec *ExecActionApplyConfiguration `json:"exec,omitempty"`
|
||||
HTTPGet *HTTPGetActionApplyConfiguration `json:"httpGet,omitempty"`
|
||||
TCPSocket *TCPSocketActionApplyConfiguration `json:"tcpSocket,omitempty"`
|
||||
GRPC *GRPCActionApplyConfiguration `json:"gRPC,omitempty"`
|
||||
GRPC *GRPCActionApplyConfiguration `json:"grpc,omitempty"`
|
||||
}
|
||||
|
||||
// ProbeHandlerApplyConfiguration constructs an declarative configuration of the ProbeHandler type for use with
|
||||
|
||||
@@ -5984,7 +5984,7 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
- name: failureThreshold
|
||||
type:
|
||||
scalar: numeric
|
||||
- name: gRPC
|
||||
- name: grpc
|
||||
type:
|
||||
namedType: io.k8s.api.core.v1.GRPCAction
|
||||
- name: httpGet
|
||||
|
||||
14
go.mod
14
go.mod
@@ -25,21 +25,21 @@ require (
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
|
||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
|
||||
google.golang.org/protobuf v1.27.1
|
||||
k8s.io/api v0.0.0-20211124232210-4c321cf829a0
|
||||
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a
|
||||
k8s.io/api v0.23.8
|
||||
k8s.io/apimachinery v0.23.8
|
||||
k8s.io/klog/v2 v2.30.0
|
||||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65
|
||||
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2
|
||||
k8s.io/utils v0.0.0-20211116205334-6203023598ed
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1
|
||||
sigs.k8s.io/yaml v1.2.0
|
||||
)
|
||||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20211124232210-4c321cf829a0
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a
|
||||
k8s.io/api => k8s.io/api v0.23.8
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.23.8
|
||||
)
|
||||
|
||||
20
go.sum
20
go.sum
@@ -335,8 +335,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a h1:bRuuGXV8wwSdGTB+CtJf+FjgO1APK1CoO39T4BN/XBw=
|
||||
golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63 h1:iocB37TsdFuN6IBRZ+ry36wrkoV51/tl5vOWqkcPGvY=
|
||||
golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -610,10 +610,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20211124232210-4c321cf829a0 h1:hTJnV20bAHUQZIzigjK3CvWqQuzeQP/C7AP72fzzEIo=
|
||||
k8s.io/api v0.0.0-20211124232210-4c321cf829a0/go.mod h1:Iod80qmyxDiUr9X93OyKup/yGuYZGx8VK8nLuWpK9Yc=
|
||||
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a h1:IggksFfccO+DgJNByne5JOJ+jfqpcMZRsYkwYGZ6qkA=
|
||||
k8s.io/apimachinery v0.0.0-20211124232001-ffb9472ec51a/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc=
|
||||
k8s.io/api v0.23.8 h1:tBMQ7z7s1NUUii649OaGe962xPacUzHwnGEj6Ahneu0=
|
||||
k8s.io/api v0.23.8/go.mod h1:26VNldp5fRyiZ/tEO/3V8RJW+In1Aay3YkxsDzkvuWU=
|
||||
k8s.io/apimachinery v0.23.8 h1:6Z+0LLvvPnAF6GXbUcBmzB1+b/AnDZpVd2N0MxUJcl0=
|
||||
k8s.io/apimachinery v0.23.8/go.mod h1:BEuFMMBaIbcOqVIJqNZJXGFTP4W6AycEpb5+m/97hrM=
|
||||
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
|
||||
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
|
||||
k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
|
||||
@@ -622,15 +622,15 @@ k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
|
||||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 h1:E3J9oCLlaobFUqsjG9DfKbP2BmgwBL2p7pn0A3dG9W4=
|
||||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
|
||||
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b h1:wxEMGetGMur3J1xuGLQY7GEQYg9bZxKn3tKo5k/eYcs=
|
||||
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
k8s.io/utils v0.0.0-20211116205334-6203023598ed h1:ck1fRPWPJWsMd8ZRFsWc6mh/zHp5fZ/shhbrgPUxDAE=
|
||||
k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 h1:fD1pz4yfdADVNfFmcP2aBEtudwUQ1AlLnRBALr33v3s=
|
||||
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 h1:Hr/htKFmJEbtMgS/UD0N+gtgctAqz81t3nu+sPzynno=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y=
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
|
||||
@@ -413,6 +413,10 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {
|
||||
func NewForConfig(c *rest.Config) (*Clientset, error) {
|
||||
configShallowCopy := *c
|
||||
|
||||
if configShallowCopy.UserAgent == "" {
|
||||
configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent()
|
||||
}
|
||||
|
||||
// share the transport between all clients
|
||||
httpClient, err := rest.HTTPClientFor(&configShallowCopy)
|
||||
if err != nil {
|
||||
|
||||
88
kubernetes_test/clientset_test.go
Normal file
88
kubernetes_test/clientset_test.go
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
Copyright 2022 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 kubernetes_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
func TestClientUserAgent(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
userAgent string
|
||||
expect string
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
expect: rest.DefaultKubernetesUserAgent(),
|
||||
},
|
||||
{
|
||||
name: "custom",
|
||||
userAgent: "test-agent",
|
||||
expect: "test-agent",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
userAgent := r.Header.Get("User-Agent")
|
||||
if userAgent != tc.expect {
|
||||
t.Errorf("User Agent expected: %s got: %s", tc.expect, userAgent)
|
||||
http.Error(w, "Unexpected user agent", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte("{}"))
|
||||
}))
|
||||
ts.Start()
|
||||
defer ts.Close()
|
||||
|
||||
gv := v1.SchemeGroupVersion
|
||||
config := &rest.Config{
|
||||
Host: ts.URL,
|
||||
}
|
||||
config.GroupVersion = &gv
|
||||
config.NegotiatedSerializer = scheme.Codecs.WithoutConversion()
|
||||
config.UserAgent = tc.userAgent
|
||||
config.ContentType = "application/json"
|
||||
|
||||
client, err := kubernetes.NewForConfig(config)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create REST client: %v", err)
|
||||
}
|
||||
_, err = client.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = client.CoreV1().Secrets("").List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
1
pkg/version/.gitattributes
vendored
1
pkg/version/.gitattributes
vendored
@@ -1 +0,0 @@
|
||||
base.go export-subst
|
||||
@@ -2995,7 +2995,7 @@ func TestHTTP1DoNotReuseRequestAfterTimeout(t *testing.T) {
|
||||
config := &Config{
|
||||
Host: ts.URL,
|
||||
Transport: utilnet.SetTransportDefaults(transport),
|
||||
Timeout: 100 * time.Millisecond,
|
||||
Timeout: 1 * time.Second,
|
||||
// These fields are required to create a REST client.
|
||||
ContentConfig: ContentConfig{
|
||||
GroupVersion: &schema.GroupVersion{},
|
||||
|
||||
13
tools/cache/thread_safe_store.go
vendored
13
tools/cache/thread_safe_store.go
vendored
@@ -284,18 +284,15 @@ func (c *threadSafeMap) updateIndices(oldObj interface{}, newObj interface{}, ke
|
||||
c.indices[name] = index
|
||||
}
|
||||
|
||||
if len(indexValues) == 1 && len(oldIndexValues) == 1 && indexValues[0] == oldIndexValues[0] {
|
||||
// We optimize for the most common case where indexFunc returns a single value which has not been changed
|
||||
continue
|
||||
}
|
||||
|
||||
for _, value := range oldIndexValues {
|
||||
// We optimize for the most common case where index returns a single value.
|
||||
if len(indexValues) == 1 && value == indexValues[0] {
|
||||
continue
|
||||
}
|
||||
c.deleteKeyFromIndex(key, value, index)
|
||||
}
|
||||
for _, value := range indexValues {
|
||||
// We optimize for the most common case where index returns a single value.
|
||||
if len(oldIndexValues) == 1 && value == oldIndexValues[0] {
|
||||
continue
|
||||
}
|
||||
c.addKeyToIndex(key, value, index)
|
||||
}
|
||||
}
|
||||
|
||||
73
tools/cache/thread_safe_store_test.go
vendored
73
tools/cache/thread_safe_store_test.go
vendored
@@ -18,7 +18,11 @@ package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestThreadSafeStoreDeleteRemovesEmptySetsFromIndex(t *testing.T) {
|
||||
@@ -92,6 +96,75 @@ func TestThreadSafeStoreAddKeepsNonEmptySetPostDeleteFromIndex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreadSafeStoreIndexingFunctionsWithMultipleValues(t *testing.T) {
|
||||
testIndexer := "testIndexer"
|
||||
|
||||
indexers := Indexers{
|
||||
testIndexer: func(obj interface{}) ([]string, error) {
|
||||
return strings.Split(obj.(string), ","), nil
|
||||
},
|
||||
}
|
||||
|
||||
indices := Indices{}
|
||||
store := NewThreadSafeStore(indexers, indices).(*threadSafeMap)
|
||||
|
||||
store.Add("key1", "foo")
|
||||
store.Add("key2", "bar")
|
||||
|
||||
assert := assert.New(t)
|
||||
|
||||
compare := func(key string, expected []string) error {
|
||||
values := store.indices[testIndexer][key].List()
|
||||
if cmp.Equal(values, expected) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unexpected index for key %s, diff=%s", key, cmp.Diff(values, expected))
|
||||
}
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1"}))
|
||||
assert.NoError(compare("bar", []string{"key2"}))
|
||||
|
||||
store.Update("key2", "foo,bar")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1", "key2"}))
|
||||
assert.NoError(compare("bar", []string{"key2"}))
|
||||
|
||||
store.Update("key1", "foo,bar")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1", "key2"}))
|
||||
assert.NoError(compare("bar", []string{"key1", "key2"}))
|
||||
|
||||
store.Add("key3", "foo,bar,baz")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1", "key2", "key3"}))
|
||||
assert.NoError(compare("bar", []string{"key1", "key2", "key3"}))
|
||||
assert.NoError(compare("baz", []string{"key3"}))
|
||||
|
||||
store.Update("key1", "foo")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1", "key2", "key3"}))
|
||||
assert.NoError(compare("bar", []string{"key2", "key3"}))
|
||||
assert.NoError(compare("baz", []string{"key3"}))
|
||||
|
||||
store.Update("key2", "bar")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key1", "key3"}))
|
||||
assert.NoError(compare("bar", []string{"key2", "key3"}))
|
||||
assert.NoError(compare("baz", []string{"key3"}))
|
||||
|
||||
store.Delete("key1")
|
||||
|
||||
assert.NoError(compare("foo", []string{"key3"}))
|
||||
assert.NoError(compare("bar", []string{"key2", "key3"}))
|
||||
assert.NoError(compare("baz", []string{"key3"}))
|
||||
|
||||
store.Delete("key3")
|
||||
|
||||
assert.NoError(compare("foo", []string{}))
|
||||
assert.NoError(compare("bar", []string{"key2"}))
|
||||
assert.NoError(compare("baz", []string{}))
|
||||
}
|
||||
|
||||
func BenchmarkIndexer(b *testing.B) {
|
||||
testIndexer := "testIndexer"
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
options.Limit = p.PageSize
|
||||
}
|
||||
requestedResourceVersion := options.ResourceVersion
|
||||
requestedResourceVersionMatch := options.ResourceVersionMatch
|
||||
var list *metainternalversion.List
|
||||
paginatedResult := false
|
||||
|
||||
@@ -102,6 +103,7 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
options.Limit = 0
|
||||
options.Continue = ""
|
||||
options.ResourceVersion = requestedResourceVersion
|
||||
options.ResourceVersionMatch = requestedResourceVersionMatch
|
||||
result, err := p.PageFn(ctx, options)
|
||||
return result, paginatedResult, err
|
||||
}
|
||||
@@ -135,10 +137,11 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
|
||||
// set the next loop up
|
||||
options.Continue = m.GetContinue()
|
||||
// Clear the ResourceVersion on the subsequent List calls to avoid the
|
||||
// Clear the ResourceVersion(Match) on the subsequent List calls to avoid the
|
||||
// `specifying resource version is not allowed when using continue` error.
|
||||
// See https://github.com/kubernetes/kubernetes/issues/85221#issuecomment-553748143.
|
||||
options.ResourceVersion = ""
|
||||
options.ResourceVersionMatch = ""
|
||||
// At this point, result is already paginated.
|
||||
paginatedResult = true
|
||||
}
|
||||
|
||||
@@ -76,6 +76,10 @@ func (p *testPager) PagedList(ctx context.Context, options metav1.ListOptions) (
|
||||
p.t.Errorf("invariant violated, specifying resource version (%s) is not allowed when using continue (%s).", options.ResourceVersion, options.Continue)
|
||||
return nil, fmt.Errorf("invariant violated")
|
||||
}
|
||||
if options.Continue != "" && options.ResourceVersionMatch != "" {
|
||||
p.t.Errorf("invariant violated, specifying resource version match type (%s) is not allowed when using continue (%s).", options.ResourceVersionMatch, options.Continue)
|
||||
return nil, fmt.Errorf("invariant violated")
|
||||
}
|
||||
var list metainternalversion.List
|
||||
total := options.Limit
|
||||
if total == 0 {
|
||||
@@ -201,6 +205,13 @@ func TestListPager_List(t *testing.T) {
|
||||
want: list(11, "rv:20"),
|
||||
wantPaged: true,
|
||||
},
|
||||
{
|
||||
name: "two pages with resourceVersion and resourceVersionMatch",
|
||||
fields: fields{PageSize: 10, PageFn: (&testPager{t: t, expectPage: 10, remaining: 11, rv: "rv:20"}).PagedList},
|
||||
args: args{options: metav1.ListOptions{ResourceVersion: "rv:10", ResourceVersionMatch: metav1.ResourceVersionMatchNotOlderThan}},
|
||||
want: list(11, "rv:20"),
|
||||
wantPaged: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user