Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
29ed2d8
kubectl proxy: append context host path to request path
FabianKramm Dec 16, 2020
c542eeb
fix AsApproximateFloat64() for BinarySI
y-tag Jul 16, 2021
ac0292d
klog 2.20.0, logr v1.1.0, zapr v1.1.0
pohly Aug 3, 2021
42dd94c
apimachinery: remove unused ignoredConversions map and nameFunc in co…
j2gg0s Aug 6, 2021
6b8f11a
generated: Run hack/lint-dependencies.sh and hack/update-vendor.sh
justaugustus Aug 11, 2021
e001aa9
generated: Run hack/update-gofmt.sh
justaugustus Aug 12, 2021
04387bf
run hack/update-netparse-cve.sh
Aug 19, 2021
9cba95e
update vendor
Aug 20, 2021
8e946d1
Merge pull request #104368 from aojea/ruleguard
k8s-publishing-bot Aug 20, 2021
19d9835
Merge pull request #97350 from FabianKramm/master
k8s-publishing-bot Aug 20, 2021
43d8bfe
Merge pull request #104187 from j2gg0s/remove-unnecessary-map-in-conv…
k8s-publishing-bot Aug 23, 2021
a068ff4
[go1.17] Bump golang.org/x/... dependencies
justaugustus Aug 11, 2021
74be3b8
Merge pull request #103692 from justaugustus/go117
k8s-publishing-bot Aug 25, 2021
43a0941
Object creation with generateName should return a proper error
vincepri Sep 1, 2021
1059638
Fix typo coersion -> coercion
invidian Sep 2, 2021
0adefd5
Additional resource quantity testing
smarterclayton Sep 3, 2021
6c3d45d
Update the valid string from rand.go
mkumatag Sep 7, 2021
60a8f1c
Merge pull request #104699 from vincepri/generate-name-error
k8s-publishing-bot Sep 8, 2021
9fff050
Merge pull request #104816 from mkumatag/fix-rand
k8s-publishing-bot Sep 8, 2021
b274948
Merge pull request #103751 from y-tag/approx-float64
k8s-publishing-bot Sep 9, 2021
2694a9d
Merge pull request #104103 from pohly/logr-1.0
k8s-publishing-bot Sep 9, 2021
71bf7ba
Merge pull request #104747 from kinvolk/invidian/typos
k8s-publishing-bot Sep 10, 2021
dd07dbd
CloseIdleConnections for wrapped Transport
Sep 10, 2021
093b2e9
Updated vendor files and pinned versions
Karthik-K-N Sep 13, 2021
40349b1
vendor sigs.k8s.io/json
liggitt Sep 14, 2021
234eb3d
Migrate to k8s.io/utils/clock in apimachinery
wojtek-t Sep 15, 2021
8c52066
Compact pretty-printed compatibility fixtures when decoding
liggitt Sep 15, 2021
87fb71e
Merge pull request #104949 from Karthik-K-N/json-iterator-version-update
k8s-publishing-bot Sep 16, 2021
f7f8dd8
Merge pull request #105026 from wojtek-t/migrate_clock_2
k8s-publishing-bot Sep 17, 2021
ddfe1ec
Migrate to k8s.io/utils/clock in client-go
wojtek-t Sep 17, 2021
86c0c0f
Merge pull request #105095 from wojtek-t/migrate_clock_3
k8s-publishing-bot Sep 20, 2021
e896b70
Make package paths referenced by import boss valid
liggitt Sep 28, 2021
0eeeaa3
Merge pull request #105330 from liggitt/importboss-doc
k8s-publishing-bot Sep 29, 2021
2616b06
run hack/{pind-dependency.sh, update-vendor.sh}
MadhavJivrajani Sep 30, 2021
df63df3
Merge pull request #105372 from MadhavJivrajani/vendor-clock-utils
k8s-publishing-bot Sep 30, 2021
f8ea685
Use stdlib json encoder for yaml and pretty-json marshaling
liggitt Sep 15, 2021
918d368
Fix bug where attempting to use patch with deleteFromPrimitiveList on…
brianpursley Oct 2, 2021
ec3388c
Redirect proxy requests for only GET & HEAD methods
heyste Oct 4, 2021
968be71
Merge pull request #105466 from liggitt/json-stdlib-pretty
k8s-publishing-bot Oct 5, 2021
6ea1bd9
resource: support using Quantity as command line value
pohly Oct 5, 2021
9111733
Merge pull request #104873 from pohly/json-output-stream
k8s-publishing-bot Oct 11, 2021
6c3d2b3
Merge pull request #95128 from ii/remove-unwanted-redirects
k8s-publishing-bot Oct 12, 2021
ff30008
Add missing json tag on internal unstructured list
liggitt Sep 15, 2021
551a1f0
ResettableRESTMapper to make it possible to reset wrapped mappers
ash2k Oct 13, 2021
3c79fac
Fix strict json decoder test
liggitt Oct 15, 2021
436a610
Test json/yaml decoding type coercion
liggitt Oct 15, 2021
e6c90c4
Merge pull request #105702 from liggitt/json-strict-test
k8s-publishing-bot Oct 15, 2021
253c511
Switch from json-iterator to utiljson
liggitt Sep 14, 2021
a7973b2
Merge pull request #105030 from liggitt/json-stdlib
k8s-publishing-bot Oct 22, 2021
f8f6d27
klog 2.30.0, logr 1.2.0, zapr 1.2.0
pohly Oct 22, 2021
153f11a
Merge pull request #104877 from pohly/json-kobj
k8s-publishing-bot Oct 22, 2021
0a1a573
upgrade github.com/evanphx/json-patch to v4.12.0
zqzten Oct 26, 2021
a39cb4b
Merge pull request #105896 from zqzten/upgrade-json-patch
k8s-publishing-bot Oct 26, 2021
43e7be7
apierrors: Avoid spurious <nil> in invalid error message
liggitt Oct 28, 2021
11a505a
apierrors: optimize ToAggregate() for zero-length lists
liggitt Oct 28, 2021
b255da5
Merge pull request #105959 from liggitt/podsecurity-details
k8s-publishing-bot Oct 28, 2021
aa7685d
generated: ./hack/update-vendor.sh
jiahuif Nov 1, 2021
9402052
Merge pull request #105983 from jiahuif-forks/dep/bump-smd
k8s-publishing-bot Nov 3, 2021
b2cebad
Bump k8s.io/kube-openapi to commit ee342a809c29
ulucinar Nov 5, 2021
d7e096f
Merge pull request #105421 from brianpursley/kubernetes-105146
k8s-publishing-bot Nov 5, 2021
0922fd5
Merge pull request #106181 from ulucinar/aru/consume-kube-openapi
k8s-publishing-bot Nov 10, 2021
b076af9
Pin new dependency: github.com/google/cel-go v0.9.0
jpbetz Nov 1, 2021
19377c9
Merge pull request #106234 from jpbetz/cel-libs
k8s-publishing-bot Nov 10, 2021
8dbf676
generated: ./hack/update-vendor.sh
jiahuif Nov 15, 2021
15e61a1
fix SA4005: ineffective assignment to field PatchMeta.patchStrategies…
Nov 16, 2021
c3a9c93
fix ineffectual assignment to base var
Nov 16, 2021
3c77d51
nolint unused expectNoMatchDirect function
Nov 16, 2021
c6fa79a
nolint float64(-0.0), //nolint:staticcheck // SA4026:
Nov 16, 2021
10158cf
Merge pull request #104844 from aojea/clientgo_close_idle
k8s-publishing-bot Nov 16, 2021
7b19dc5
remove ineffectual assignment base var
Nov 16, 2021
f3cf56e
Merge pull request #105057 from jiahuif-forks/feature/enum-types-feat…
k8s-publishing-bot Nov 17, 2021
cc08b72
Merge pull request #105623 from ash2k/ash2k/resettable-rest-mapper
k8s-publishing-bot Nov 17, 2021
9d6998d
migrate nolint coments to golangci-lint
Nov 16, 2021
9edaf59
Merge pull request #106448 from aojea/hlee/issue-103721/staticcheck
k8s-publishing-bot Nov 17, 2021
db630ad
Server Side Field Validation
kevindelgado Aug 18, 2021
bc8397d
Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2
liggitt Nov 24, 2021
1d209c8
Merge pull request #106661 from liggitt/automated-cherry-pick-of-#106…
k8s-publishing-bot Dec 2, 2021
343629c
Merge tag 'v0.23.0' into merge-v0.23.0
lukasschwab Dec 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.15'
go-version: '1.17'
- name: Run testsuites
run: go test ./pkg/...
17 changes: 17 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2021 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 apimachinery // import "k8s.io/apimachinery"
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ go 1.16
require (
github.com/davecgh/go-spew v1.1.1
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153
github.com/evanphx/json-patch v4.11.0+incompatible
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.5
github.com/google/gofuzz v1.1.0
github.com/google/uuid v1.1.2
github.com/googleapis/gnostic v0.5.5
github.com/json-iterator/go v1.1.11
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/moby/spdystream v0.2.0
github.com/modern-go/reflect2 v1.0.1
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect
golang.org/x/net v0.0.0-20210825183410-e898025ed96a
golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/inf.v0 v0.9.1
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.9.0
k8s.io/kube-openapi v0.0.0-20210817084001-7fbd8d59e5b8
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/json v0.0.0-20211020170558-c049b76a60c6
sigs.k8s.io/structured-merge-diff/v4 v4.1.2
sigs.k8s.io/yaml v1.2.0
)
62 changes: 40 additions & 22 deletions go.sum

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions pkg/api/apitesting/roundtrip/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package roundtrip

import (
"bytes"
gojson "encoding/json"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -336,8 +337,14 @@ func (c *CompatibilityTestOptions) runCurrentVersionTest(t *testing.T, gvk schem
t.Fatal(err)
}
{
// compact before decoding since embedded RawExtension fields retain indenting
compacted := &bytes.Buffer{}
if err := gojson.Compact(compacted, actualJSON); err != nil {
t.Error(err)
}

jsonDecoded := emptyObj.DeepCopyObject()
jsonDecoded, _, err = c.JSON.Decode(actualJSON, &gvk, jsonDecoded)
jsonDecoded, _, err = c.JSON.Decode(compacted.Bytes(), &gvk, jsonDecoded)
if err != nil {
t.Error(err)
} else if !apiequality.Semantic.DeepEqual(expectedObject, jsonDecoded) {
Expand Down Expand Up @@ -420,8 +427,14 @@ func (c *CompatibilityTestOptions) runPreviousVersionTest(t *testing.T, gvk sche
t.Fatal(err)
}

// compact before decoding since embedded RawExtension fields retain indenting
compacted := &bytes.Buffer{}
if err := gojson.Compact(compacted, jsonBeforeRoundTrip); err != nil {
t.Fatal(err)
}

jsonDecoded := emptyObj.DeepCopyObject()
jsonDecoded, _, err = c.JSON.Decode(jsonBeforeRoundTrip, &gvk, jsonDecoded)
jsonDecoded, _, err = c.JSON.Decode(compacted.Bytes(), &gvk, jsonDecoded)
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/api/apitesting/roundtrip/fuzz_norace.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !race
// +build !race

/*
Expand Down
1 change: 1 addition & 0 deletions pkg/api/apitesting/roundtrip/fuzz_race.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build race
// +build race

/*
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/apitesting/roundtrip/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"

"github.com/davecgh/go-spew/spew"
//lint:ignore SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs
//nolint:staticcheck //iccheck // SA1019 Keep using deprecated module; it still seems to be maintained and the api of the recommended replacement differs
"github.com/golang/protobuf/proto"
fuzz "github.com/google/gofuzz"
flag "github.com/spf13/pflag"
Expand Down
29 changes: 27 additions & 2 deletions pkg/api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ func NewAlreadyExists(qualifiedResource schema.GroupResource, name string) *Stat
}}
}

// NewGenerateNameConflict returns an error indicating the server
// was not able to generate a valid name for a resource.
func NewGenerateNameConflict(qualifiedResource schema.GroupResource, name string, retryAfterSeconds int) *StatusError {
return &StatusError{metav1.Status{
Status: metav1.StatusFailure,
Code: http.StatusConflict,
Reason: metav1.StatusReasonAlreadyExists,
Details: &metav1.StatusDetails{
Group: qualifiedResource.Group,
Kind: qualifiedResource.Resource,
Name: name,
RetryAfterSeconds: int32(retryAfterSeconds),
},
Message: fmt.Sprintf(
"%s %q already exists, the server was not able to generate a unique name for the object",
qualifiedResource.String(), name),
}}
}

// NewUnauthorized returns an error indicating the client is not authorized to perform the requested
// action.
func NewUnauthorized(reason string) *StatusError {
Expand Down Expand Up @@ -270,7 +289,7 @@ func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorLis
Field: err.Field,
})
}
return &StatusError{metav1.Status{
err := &StatusError{metav1.Status{
Status: metav1.StatusFailure,
Code: http.StatusUnprocessableEntity,
Reason: metav1.StatusReasonInvalid,
Expand All @@ -280,8 +299,14 @@ func NewInvalid(qualifiedKind schema.GroupKind, name string, errs field.ErrorLis
Name: name,
Causes: causes,
},
Message: fmt.Sprintf("%s %q is invalid: %v", qualifiedKind.String(), name, errs.ToAggregate()),
}}
aggregatedErrs := errs.ToAggregate()
if aggregatedErrs == nil {
err.ErrStatus.Message = fmt.Sprintf("%s %q is invalid", qualifiedKind.String(), name)
} else {
err.ErrStatus.Message = fmt.Sprintf("%s %q is invalid: %v", qualifiedKind.String(), name, aggregatedErrs)
}
return err
}

// NewBadRequest creates an error that indicates that the request is invalid and can not be processed.
Expand Down
37 changes: 34 additions & 3 deletions pkg/api/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestErrorNew(t *testing.T) {
}

if !IsConflict(NewConflict(resource("tests"), "2", errors.New("message"))) {
t.Errorf("expected to be conflict")
t.Errorf("expected to be %s", metav1.StatusReasonAlreadyExists)
}
if !IsNotFound(NewNotFound(resource("tests"), "3")) {
t.Errorf("expected to be %s", metav1.StatusReasonNotFound)
Expand All @@ -88,6 +88,13 @@ func TestErrorNew(t *testing.T) {
t.Errorf("expected to be %s", metav1.StatusReasonMethodNotAllowed)
}

if !IsAlreadyExists(NewGenerateNameConflict(resource("tests"), "3", 1)) {
t.Errorf("expected to be %s", metav1.StatusReasonAlreadyExists)
}
if time, ok := SuggestsClientDelay(NewGenerateNameConflict(resource("tests"), "3", 1)); time != 1 || !ok {
t.Errorf("unexpected %d", time)
}

if time, ok := SuggestsClientDelay(NewServerTimeout(resource("tests"), "doing something", 10)); time != 10 || !ok {
t.Errorf("unexpected %d", time)
}
Expand Down Expand Up @@ -118,6 +125,7 @@ func TestNewInvalid(t *testing.T) {
testCases := []struct {
Err *field.Error
Details *metav1.StatusDetails
Msg string
}{
{
field.Duplicate(field.NewPath("field[0].name"), "bar"),
Expand All @@ -129,6 +137,7 @@ func TestNewInvalid(t *testing.T) {
Field: "field[0].name",
}},
},
`Kind "name" is invalid: field[0].name: Duplicate value: "bar"`,
},
{
field.Invalid(field.NewPath("field[0].name"), "bar", "detail"),
Expand All @@ -140,6 +149,7 @@ func TestNewInvalid(t *testing.T) {
Field: "field[0].name",
}},
},
`Kind "name" is invalid: field[0].name: Invalid value: "bar": detail`,
},
{
field.NotFound(field.NewPath("field[0].name"), "bar"),
Expand All @@ -151,6 +161,7 @@ func TestNewInvalid(t *testing.T) {
Field: "field[0].name",
}},
},
`Kind "name" is invalid: field[0].name: Not found: "bar"`,
},
{
field.NotSupported(field.NewPath("field[0].name"), "bar", nil),
Expand All @@ -162,6 +173,7 @@ func TestNewInvalid(t *testing.T) {
Field: "field[0].name",
}},
},
`Kind "name" is invalid: field[0].name: Unsupported value: "bar"`,
},
{
field.Required(field.NewPath("field[0].name"), ""),
Expand All @@ -173,19 +185,38 @@ func TestNewInvalid(t *testing.T) {
Field: "field[0].name",
}},
},
`Kind "name" is invalid: field[0].name: Required value`,
},
{
nil,
&metav1.StatusDetails{
Kind: "Kind",
Name: "name",
Causes: []metav1.StatusCause{},
},
`Kind "name" is invalid`,
},
}
for i, testCase := range testCases {
vErr, expected := testCase.Err, testCase.Details
expected.Causes[0].Message = vErr.ErrorBody()
err := NewInvalid(kind("Kind"), "name", field.ErrorList{vErr})
if vErr != nil && expected != nil {
expected.Causes[0].Message = vErr.ErrorBody()
}
var errList field.ErrorList
if vErr != nil {
errList = append(errList, vErr)
}
err := NewInvalid(kind("Kind"), "name", errList)
status := err.ErrStatus
if status.Code != 422 || status.Reason != metav1.StatusReasonInvalid {
t.Errorf("%d: unexpected status: %#v", i, status)
}
if !reflect.DeepEqual(expected, status.Details) {
t.Errorf("%d: expected %#v, got %#v", i, expected, status.Details)
}
if testCase.Msg != status.Message {
t.Errorf("%d: expected\n%s\ngot\n%s", i, testCase.Msg, status.Message)
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/api/meta/firsthit_restmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
)

var (
_ ResettableRESTMapper = &FirstHitRESTMapper{}
)

// FirstHitRESTMapper is a wrapper for multiple RESTMappers which returns the
// first successful result for the singular requests
type FirstHitRESTMapper struct {
Expand Down Expand Up @@ -75,6 +79,10 @@ func (m FirstHitRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string)
return nil, collapseAggregateErrors(errors)
}

func (m FirstHitRESTMapper) Reset() {
m.MultiRESTMapper.Reset()
}

// collapseAggregateErrors returns the minimal errors. it handles empty as nil, handles one item in a list
// by returning the item, and collapses all NoMatchErrors to a single one (since they should all be the same)
func collapseAggregateErrors(errors []error) error {
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/meta/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,12 @@ type RESTMapper interface {

ResourceSingularizer(resource string) (singular string, err error)
}

// ResettableRESTMapper is a RESTMapper which is capable of resetting itself
// from discovery.
// All rest mappers that delegate to other rest mappers must implement this interface and dynamically
// check if the delegate mapper supports the Reset() operation.
type ResettableRESTMapper interface {
RESTMapper
Reset()
}
12 changes: 10 additions & 2 deletions pkg/api/meta/lazy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type lazyObject struct {
mapper RESTMapper
}

// NewLazyObjectLoader handles unrecoverable errors when creating a RESTMapper / ObjectTyper by
// NewLazyRESTMapperLoader handles unrecoverable errors when creating a RESTMapper / ObjectTyper by
// returning those initialization errors when the interface methods are invoked. This defers the
// initialization and any server calls until a client actually needs to perform the action.
func NewLazyRESTMapperLoader(fn func() (RESTMapper, error)) RESTMapper {
Expand All @@ -52,7 +52,7 @@ func (o *lazyObject) init() error {
return o.err
}

var _ RESTMapper = &lazyObject{}
var _ ResettableRESTMapper = &lazyObject{}

func (o *lazyObject) KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error) {
if err := o.init(); err != nil {
Expand Down Expand Up @@ -102,3 +102,11 @@ func (o *lazyObject) ResourceSingularizer(resource string) (singular string, err
}
return o.mapper.ResourceSingularizer(resource)
}

func (o *lazyObject) Reset() {
o.lock.Lock()
defer o.lock.Unlock()
if o.loaded && o.err == nil {
MaybeResetRESTMapper(o.mapper)
}
}
12 changes: 11 additions & 1 deletion pkg/api/meta/multirestmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ import (
utilerrors "k8s.io/apimachinery/pkg/util/errors"
)

var (
_ ResettableRESTMapper = MultiRESTMapper{}
)

// MultiRESTMapper is a wrapper for multiple RESTMappers.
type MultiRESTMapper []RESTMapper

func (m MultiRESTMapper) String() string {
nested := []string{}
nested := make([]string, 0, len(m))
for _, t := range m {
currString := fmt.Sprintf("%v", t)
splitStrings := strings.Split(currString, "\n")
Expand Down Expand Up @@ -208,3 +212,9 @@ func (m MultiRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (
}
return allMappings, nil
}

func (m MultiRESTMapper) Reset() {
for _, t := range m {
MaybeResetRESTMapper(t)
}
}
8 changes: 8 additions & 0 deletions pkg/api/meta/priority.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const (
AnyKind = "*"
)

var (
_ ResettableRESTMapper = PriorityRESTMapper{}
)

// PriorityRESTMapper is a wrapper for automatically choosing a particular Resource or Kind
// when multiple matches are possible
type PriorityRESTMapper struct {
Expand Down Expand Up @@ -220,3 +224,7 @@ func (m PriorityRESTMapper) ResourcesFor(partiallySpecifiedResource schema.Group
func (m PriorityRESTMapper) KindsFor(partiallySpecifiedResource schema.GroupVersionResource) (gvk []schema.GroupVersionKind, err error) {
return m.Delegate.KindsFor(partiallySpecifiedResource)
}

func (m PriorityRESTMapper) Reset() {
MaybeResetRESTMapper(m.Delegate)
}
Loading