From 14396fc4643b1b1e7b86ba6cc652e85fa1b0b2c5 Mon Sep 17 00:00:00 2001 From: deads2k Date: Tue, 15 Dec 2015 13:37:56 -0500 Subject: [PATCH] add subject access review types --- docs/admin/kube-apiserver.md | 4 +- .../update-generated-conversions.sh | 2 +- .../update-generated-deep-copies.sh | 2 +- .../verify-generated-conversions.sh | 2 +- .../verify-generated-deep-copies.sh | 2 +- hack/update-generated-swagger-docs.sh | 2 +- pkg/apis/authorization/deep_copy_generated.go | 29 + pkg/apis/authorization/install/install.go | 128 + pkg/apis/authorization/register.go | 54 + pkg/apis/authorization/types.generated.go | 2281 ++++++++++++++++ pkg/apis/authorization/types.go | 121 + pkg/apis/authorization/v1beta1/conversion.go | 30 + .../v1beta1/conversion_generated.go | 29 + .../v1beta1/deep_copy_generated.go | 29 + pkg/apis/authorization/v1beta1/defaults.go | 25 + pkg/apis/authorization/v1beta1/register.go | 51 + .../authorization/v1beta1/types.generated.go | 2414 +++++++++++++++++ pkg/apis/authorization/v1beta1/types.go | 120 + .../v1beta1/types_swagger_doc_generated.go | 117 + .../authorization/validation/validation.go | 64 + .../validation/validation_test.go | 135 + .../unversioned/import_known_versions.go | 1 + pkg/master/import_known_versions.go | 1 + 23 files changed, 5636 insertions(+), 7 deletions(-) create mode 100644 pkg/apis/authorization/deep_copy_generated.go create mode 100644 pkg/apis/authorization/install/install.go create mode 100644 pkg/apis/authorization/register.go create mode 100644 pkg/apis/authorization/types.generated.go create mode 100644 pkg/apis/authorization/types.go create mode 100644 pkg/apis/authorization/v1beta1/conversion.go create mode 100644 pkg/apis/authorization/v1beta1/conversion_generated.go create mode 100644 pkg/apis/authorization/v1beta1/deep_copy_generated.go create mode 100644 pkg/apis/authorization/v1beta1/defaults.go create mode 100644 pkg/apis/authorization/v1beta1/register.go create mode 100644 pkg/apis/authorization/v1beta1/types.generated.go create mode 100644 pkg/apis/authorization/v1beta1/types.go create mode 100644 pkg/apis/authorization/v1beta1/types_swagger_doc_generated.go create mode 100644 pkg/apis/authorization/validation/validation.go create mode 100644 pkg/apis/authorization/validation/validation_test.go diff --git a/docs/admin/kube-apiserver.md b/docs/admin/kube-apiserver.md index f4c74d292e3..1d775b58e9f 100644 --- a/docs/admin/kube-apiserver.md +++ b/docs/admin/kube-apiserver.md @@ -100,14 +100,14 @@ kube-apiserver --service-node-port-range=: A port range to reserve for services with NodePort visibility. Example: '30000-32767'. Inclusive at both ends of the range. --ssh-keyfile="": If non-empty, use secure SSH proxy to the nodes, using this user keyfile --ssh-user="": If non-empty, use secure SSH proxy to the nodes, using this user name - --storage-versions="componentconfig/v1alpha1,extensions/v1beta1,metrics/v1alpha1,v1": The versions to store resources with. Different groups may be stored in different versions. Specified in the format "group1/version1,group2/version2...". This flag expects a complete list of storage versions of ALL groups registered in the server. It defaults to a list of preferred versions of all registered groups, which is derived from the KUBE_API_VERSIONS environment variable. + --storage-versions="authorization.k8s.io/v1beta1,componentconfig/v1alpha1,extensions/v1beta1,metrics/v1alpha1,v1": The versions to store resources with. Different groups may be stored in different versions. Specified in the format "group1/version1,group2/version2...". This flag expects a complete list of storage versions of ALL groups registered in the server. It defaults to a list of preferred versions of all registered groups, which is derived from the KUBE_API_VERSIONS environment variable. --tls-cert-file="": File containing x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). If HTTPS serving is enabled, and --tls-cert-file and --tls-private-key-file are not provided, a self-signed certificate and key are generated for the public address and saved to /var/run/kubernetes. --tls-private-key-file="": File containing x509 private key matching --tls-cert-file. --token-auth-file="": If set, the file that will be used to secure the secure port of the API server via token authentication. --watch-cache[=true]: Enable watch caching in the apiserver ``` -###### Auto generated by spf13/cobra on 22-Dec-2015 +###### Auto generated by spf13/cobra on 14-Jan-2016 diff --git a/hack/after-build/update-generated-conversions.sh b/hack/after-build/update-generated-conversions.sh index 5bb75d52947..4258ff6f824 100755 --- a/hack/after-build/update-generated-conversions.sh +++ b/hack/after-build/update-generated-conversions.sh @@ -43,7 +43,7 @@ EOF } # TODO(lavalamp): get this list by listing the pkg/apis/ directory? -DEFAULT_GROUP_VERSIONS="v1 extensions/v1beta1 componentconfig/v1alpha1 metrics/v1alpha1" +DEFAULT_GROUP_VERSIONS="v1 authorization/v1beta1 extensions/v1beta1 componentconfig/v1alpha1 metrics/v1alpha1" VERSIONS=${VERSIONS:-$DEFAULT_GROUP_VERSIONS} for ver in $VERSIONS; do # Ensure that the version being processed is registered by setting diff --git a/hack/after-build/update-generated-deep-copies.sh b/hack/after-build/update-generated-deep-copies.sh index 37cefcf6142..83740149bf4 100755 --- a/hack/after-build/update-generated-deep-copies.sh +++ b/hack/after-build/update-generated-deep-copies.sh @@ -62,6 +62,6 @@ function generate_deep_copies() { # Currently pkg/api/deep_copy_generated.go is generated by the new go2idl generator. # All others (mentioned above) are still generated by the old reflection-based generator. # TODO: Migrate these to the new generator. -DEFAULT_VERSIONS="v1 extensions/ extensions/v1beta1 componentconfig/ componentconfig/v1alpha1 metrics/ metrics/v1alpha1" +DEFAULT_VERSIONS="v1 authorization/ authorization/v1beta1 extensions/ extensions/v1beta1 componentconfig/ componentconfig/v1alpha1 metrics/ metrics/v1alpha1" VERSIONS=${VERSIONS:-$DEFAULT_VERSIONS} generate_deep_copies "$VERSIONS" diff --git a/hack/after-build/verify-generated-conversions.sh b/hack/after-build/verify-generated-conversions.sh index db9e858b08d..56bd73f8c83 100755 --- a/hack/after-build/verify-generated-conversions.sh +++ b/hack/after-build/verify-generated-conversions.sh @@ -23,7 +23,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env -APIROOTS=${APIROOTS:-pkg/api pkg/apis/extensions pkg/apis/metrics} +APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/extensions pkg/apis/metrics} _tmp="${KUBE_ROOT}/_tmp" cleanup() { diff --git a/hack/after-build/verify-generated-deep-copies.sh b/hack/after-build/verify-generated-deep-copies.sh index 204f7621394..b8e594027b3 100755 --- a/hack/after-build/verify-generated-deep-copies.sh +++ b/hack/after-build/verify-generated-deep-copies.sh @@ -25,7 +25,7 @@ kube::golang::setup_env gendeepcopy=$(kube::util::find-binary "gendeepcopy") -APIROOTS=${APIROOTS:-pkg/api pkg/apis/extensions pkg/apis/metrics} +APIROOTS=${APIROOTS:-pkg/api pkg/apis/authorization pkg/apis/extensions pkg/apis/metrics} _tmp="${KUBE_ROOT}/_tmp" cleanup() { diff --git a/hack/update-generated-swagger-docs.sh b/hack/update-generated-swagger-docs.sh index 8747af3e80f..5bdcfedbc23 100755 --- a/hack/update-generated-swagger-docs.sh +++ b/hack/update-generated-swagger-docs.sh @@ -56,7 +56,7 @@ EOF mv "$TMPFILE" "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go" } -GROUP_VERSIONS=(unversioned v1 extensions/v1beta1) +GROUP_VERSIONS=(unversioned v1 authorization/v1beta1 extensions/v1beta1) # To avoid compile errors, remove the currently existing files. for group_version in "${GROUP_VERSIONS[@]}"; do rm -f "pkg/$(kube::util::group-version-to-pkg-path "${group_version}")/types_swagger_doc_generated.go" diff --git a/pkg/apis/authorization/deep_copy_generated.go b/pkg/apis/authorization/deep_copy_generated.go new file mode 100644 index 00000000000..034a94d1e16 --- /dev/null +++ b/pkg/apis/authorization/deep_copy_generated.go @@ -0,0 +1,29 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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. +*/ + +// DO NOT EDIT. THIS FILE IS AUTO-GENERATED BY $KUBEROOT/hack/update-generated-deep-copies.sh. + +package authorization + +import api "k8s.io/kubernetes/pkg/api" + +func init() { + err := api.Scheme.AddGeneratedDeepCopyFuncs() + if err != nil { + // if one of the deep copy functions is malformed, detect it immediately. + panic(err) + } +} diff --git a/pkg/apis/authorization/install/install.go b/pkg/apis/authorization/install/install.go new file mode 100644 index 00000000000..d7b6fa6b700 --- /dev/null +++ b/pkg/apis/authorization/install/install.go @@ -0,0 +1,128 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 install installs the experimental API group, making it available as +// an option to all of the API encoding/decoding machinery. +package install + +import ( + "fmt" + + "github.com/golang/glog" + + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/latest" + "k8s.io/kubernetes/pkg/api/meta" + "k8s.io/kubernetes/pkg/api/registered" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/apis/authorization" + "k8s.io/kubernetes/pkg/apis/authorization/v1beta1" + "k8s.io/kubernetes/pkg/runtime" + "k8s.io/kubernetes/pkg/util/sets" +) + +const importPrefix = "k8s.io/kubernetes/pkg/apis/authorization" + +var accessor = meta.NewAccessor() + +// availableVersions lists all known external versions for this group from most preferred to least preferred +var availableVersions = []unversioned.GroupVersion{v1beta1.SchemeGroupVersion} + +func init() { + registered.RegisterVersions(availableVersions...) + + externalVersions := []unversioned.GroupVersion{} + for _, v := range availableVersions { + if registered.IsAllowedVersion(v) { + externalVersions = append(externalVersions, v) + } + } + if len(externalVersions) == 0 { + glog.V(4).Infof("No version is registered for group %v", authorization.GroupName) + return + } + if err := registered.EnableVersions(externalVersions...); err != nil { + glog.V(4).Infof("%v", err) + return + } + if err := enableVersions(externalVersions); err != nil { + glog.V(4).Infof("%v", err) + return + } +} + +// TODO: enableVersions should be centralized rather than spread in each API +// group. +func enableVersions(externalVersions []unversioned.GroupVersion) error { + addVersionsToScheme(externalVersions...) + preferredExternalVersion := externalVersions[0] + + groupMeta := latest.GroupMeta{ + GroupVersion: preferredExternalVersion, + GroupVersions: externalVersions, + Codec: runtime.CodecFor(api.Scheme, preferredExternalVersion), + RESTMapper: newRESTMapper(externalVersions), + SelfLinker: runtime.SelfLinker(accessor), + InterfacesFor: interfacesFor, + } + + if err := latest.RegisterGroup(groupMeta); err != nil { + return err + } + api.RegisterRESTMapper(groupMeta.RESTMapper) + return nil +} + +func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { + // add the internal version to Scheme + authorization.AddToScheme(api.Scheme) + // add the enabled external versions to Scheme + for _, v := range externalVersions { + if !registered.IsEnabledVersion(v) { + glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) + continue + } + switch v { + case v1beta1.SchemeGroupVersion: + v1beta1.AddToScheme(api.Scheme) + } + } +} + +func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { + worstToBestGroupVersions := []unversioned.GroupVersion{} + for i := len(externalVersions) - 1; i >= 0; i-- { + worstToBestGroupVersions = append(worstToBestGroupVersions, externalVersions[i]) + } + + rootScoped := sets.NewString("SubjectAccessReview", "SelfSubjectAccessReview") + ignoredKinds := sets.NewString() + return api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) +} + +func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { + switch version { + case v1beta1.SchemeGroupVersion: + return &meta.VersionInterfaces{ + Codec: v1beta1.Codec, + ObjectConvertor: api.Scheme, + MetadataAccessor: accessor, + }, nil + default: + g, _ := latest.Group(authorization.GroupName) + return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) + } +} diff --git a/pkg/apis/authorization/register.go b/pkg/apis/authorization/register.go new file mode 100644 index 00000000000..317e44c9131 --- /dev/null +++ b/pkg/apis/authorization/register.go @@ -0,0 +1,54 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 authorization + +import ( + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" +) + +// GroupName is the group name use in this package +const GroupName = "authorization.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: ""} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) unversioned.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns back a Group qualified GroupResource +func Resource(resource string) unversioned.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +func AddToScheme(scheme *runtime.Scheme) { + addKnownTypes(scheme) +} + +func addKnownTypes(scheme *runtime.Scheme) { + scheme.AddKnownTypes(SchemeGroupVersion, + &SelfSubjectAccessReview{}, + &SubjectAccessReview{}, + &LocalSubjectAccessReview{}, + ) +} + +func (obj *LocalSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } +func (obj *SubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } +func (obj *SelfSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } diff --git a/pkg/apis/authorization/types.generated.go b/pkg/apis/authorization/types.generated.go new file mode 100644 index 00000000000..668b9dfc3bb --- /dev/null +++ b/pkg/apis/authorization/types.generated.go @@ -0,0 +1,2281 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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. +*/ + +// ************************************************************ +// DO NOT EDIT. +// THIS FILE IS AUTO-GENERATED BY codecgen. +// ************************************************************ + +package authorization + +import ( + "errors" + "fmt" + codec1978 "github.com/ugorji/go/codec" + pkg1_unversioned "k8s.io/kubernetes/pkg/api/unversioned" + "reflect" + "runtime" +) + +const ( + // ----- content types ---- + codecSelferC_UTF81234 = 1 + codecSelferC_RAW1234 = 0 + // ----- value types used ---- + codecSelferValueTypeArray1234 = 10 + codecSelferValueTypeMap1234 = 9 + // ----- containerStateValues ---- + codecSelfer_containerMapKey1234 = 2 + codecSelfer_containerMapValue1234 = 3 + codecSelfer_containerMapEnd1234 = 4 + codecSelfer_containerArrayElem1234 = 6 + codecSelfer_containerArrayEnd1234 = 7 +) + +var ( + codecSelferBitsize1234 = uint8(reflect.TypeOf(uint(0)).Bits()) + codecSelferOnlyMapOrArrayEncodeToStructErr1234 = errors.New(`only encoded map or array can be decoded into a struct`) +) + +type codecSelfer1234 struct{} + +func init() { + if codec1978.GenVersion != 5 { + _, file, _, _ := runtime.Caller(0) + err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", + 5, codec1978.GenVersion, file) + panic(err) + } + if false { // reference the types, but skip this branch at build/run time + var v0 pkg1_unversioned.TypeMeta + _ = v0 + } +} + +func (x *SubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [4]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[0] = x.Kind != "" + yyq2[1] = x.APIVersion != "" + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(4) + } else { + yynn2 = 2 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[0] { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[1] { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy10 := &x.Spec + yy10.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy11 := &x.Spec + yy11.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy13 := &x.Status + yy13.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy14 := &x.Status + yy14.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym15 := z.DecBinary() + _ = yym15 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct16 := r.ContainerType() + if yyct16 == codecSelferValueTypeMap1234 { + yyl16 := r.ReadMapStart() + if yyl16 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl16, d) + } + } else if yyct16 == codecSelferValueTypeArray1234 { + yyl16 := r.ReadArrayStart() + if yyl16 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl16, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys17Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys17Slc + var yyhl17 bool = l >= 0 + for yyj17 := 0; ; yyj17++ { + if yyhl17 { + if yyj17 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys17Slc = r.DecodeBytes(yys17Slc, true, true) + yys17 := string(yys17Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys17 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "Spec": + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv20 := &x.Spec + yyv20.CodecDecodeSelf(d) + } + case "Status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv21 := &x.Status + yyv21.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys17) + } // end switch yys17 + } // end for yyj17 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj22 int + var yyb22 bool + var yyhl22 bool = l >= 0 + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv25 := &x.Spec + yyv25.CodecDecodeSelf(d) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv26 := &x.Status + yyv26.CodecDecodeSelf(d) + } + for { + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj22-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SelfSubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym27 := z.EncBinary() + _ = yym27 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep28 := !z.EncBinary() + yy2arr28 := z.EncBasicHandle().StructToArray + var yyq28 [4]bool + _, _, _ = yysep28, yyq28, yy2arr28 + const yyr28 bool = false + yyq28[0] = x.Kind != "" + yyq28[1] = x.APIVersion != "" + var yynn28 int + if yyr28 || yy2arr28 { + r.EncodeArrayStart(4) + } else { + yynn28 = 2 + for _, b := range yyq28 { + if b { + yynn28++ + } + } + r.EncodeMapStart(yynn28) + yynn28 = 0 + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq28[0] { + yym30 := z.EncBinary() + _ = yym30 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq28[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym31 := z.EncBinary() + _ = yym31 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq28[1] { + yym33 := z.EncBinary() + _ = yym33 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq28[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym34 := z.EncBinary() + _ = yym34 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy36 := &x.Spec + yy36.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy37 := &x.Spec + yy37.CodecEncodeSelf(e) + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy39 := &x.Status + yy39.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy40 := &x.Status + yy40.CodecEncodeSelf(e) + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SelfSubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym41 := z.DecBinary() + _ = yym41 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct42 := r.ContainerType() + if yyct42 == codecSelferValueTypeMap1234 { + yyl42 := r.ReadMapStart() + if yyl42 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl42, d) + } + } else if yyct42 == codecSelferValueTypeArray1234 { + yyl42 := r.ReadArrayStart() + if yyl42 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl42, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SelfSubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys43Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys43Slc + var yyhl43 bool = l >= 0 + for yyj43 := 0; ; yyj43++ { + if yyhl43 { + if yyj43 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys43Slc = r.DecodeBytes(yys43Slc, true, true) + yys43 := string(yys43Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys43 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "Spec": + if r.TryDecodeAsNil() { + x.Spec = SelfSubjectAccessReviewSpec{} + } else { + yyv46 := &x.Spec + yyv46.CodecDecodeSelf(d) + } + case "Status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv47 := &x.Status + yyv47.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys43) + } // end switch yys43 + } // end for yyj43 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SelfSubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj48 int + var yyb48 bool + var yyhl48 bool = l >= 0 + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SelfSubjectAccessReviewSpec{} + } else { + yyv51 := &x.Spec + yyv51.CodecDecodeSelf(d) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv52 := &x.Status + yyv52.CodecDecodeSelf(d) + } + for { + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj48-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *LocalSubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym53 := z.EncBinary() + _ = yym53 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep54 := !z.EncBinary() + yy2arr54 := z.EncBasicHandle().StructToArray + var yyq54 [4]bool + _, _, _ = yysep54, yyq54, yy2arr54 + const yyr54 bool = false + yyq54[0] = x.Kind != "" + yyq54[1] = x.APIVersion != "" + var yynn54 int + if yyr54 || yy2arr54 { + r.EncodeArrayStart(4) + } else { + yynn54 = 2 + for _, b := range yyq54 { + if b { + yynn54++ + } + } + r.EncodeMapStart(yynn54) + yynn54 = 0 + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq54[0] { + yym56 := z.EncBinary() + _ = yym56 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq54[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym57 := z.EncBinary() + _ = yym57 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq54[1] { + yym59 := z.EncBinary() + _ = yym59 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq54[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym60 := z.EncBinary() + _ = yym60 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy62 := &x.Spec + yy62.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy63 := &x.Spec + yy63.CodecEncodeSelf(e) + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy65 := &x.Status + yy65.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy66 := &x.Status + yy66.CodecEncodeSelf(e) + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *LocalSubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym67 := z.DecBinary() + _ = yym67 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct68 := r.ContainerType() + if yyct68 == codecSelferValueTypeMap1234 { + yyl68 := r.ReadMapStart() + if yyl68 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl68, d) + } + } else if yyct68 == codecSelferValueTypeArray1234 { + yyl68 := r.ReadArrayStart() + if yyl68 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl68, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *LocalSubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys69Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys69Slc + var yyhl69 bool = l >= 0 + for yyj69 := 0; ; yyj69++ { + if yyhl69 { + if yyj69 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys69Slc = r.DecodeBytes(yys69Slc, true, true) + yys69 := string(yys69Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys69 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "Spec": + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv72 := &x.Spec + yyv72.CodecDecodeSelf(d) + } + case "Status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv73 := &x.Status + yyv73.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys69) + } // end switch yys69 + } // end for yyj69 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *LocalSubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj74 int + var yyb74 bool + var yyhl74 bool = l >= 0 + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv77 := &x.Spec + yyv77.CodecDecodeSelf(d) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv78 := &x.Status + yyv78.CodecDecodeSelf(d) + } + for { + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj74-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *ResourceAttributes) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym79 := z.EncBinary() + _ = yym79 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep80 := !z.EncBinary() + yy2arr80 := z.EncBasicHandle().StructToArray + var yyq80 [7]bool + _, _, _ = yysep80, yyq80, yy2arr80 + const yyr80 bool = false + var yynn80 int + if yyr80 || yy2arr80 { + r.EncodeArrayStart(7) + } else { + yynn80 = 7 + for _, b := range yyq80 { + if b { + yynn80++ + } + } + r.EncodeMapStart(yynn80) + yynn80 = 0 + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym82 := z.EncBinary() + _ = yym82 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Namespace)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Namespace")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym83 := z.EncBinary() + _ = yym83 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Namespace)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym85 := z.EncBinary() + _ = yym85 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Verb")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym86 := z.EncBinary() + _ = yym86 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym88 := z.EncBinary() + _ = yym88 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Group)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Group")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym89 := z.EncBinary() + _ = yym89 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Group)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym91 := z.EncBinary() + _ = yym91 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Version)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Version")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym92 := z.EncBinary() + _ = yym92 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Version)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym94 := z.EncBinary() + _ = yym94 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Resource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym95 := z.EncBinary() + _ = yym95 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym97 := z.EncBinary() + _ = yym97 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Subresource)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Subresource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym98 := z.EncBinary() + _ = yym98 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Subresource)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym100 := z.EncBinary() + _ = yym100 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Name)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Name")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym101 := z.EncBinary() + _ = yym101 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Name)) + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ResourceAttributes) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym102 := z.DecBinary() + _ = yym102 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct103 := r.ContainerType() + if yyct103 == codecSelferValueTypeMap1234 { + yyl103 := r.ReadMapStart() + if yyl103 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl103, d) + } + } else if yyct103 == codecSelferValueTypeArray1234 { + yyl103 := r.ReadArrayStart() + if yyl103 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl103, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ResourceAttributes) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys104Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys104Slc + var yyhl104 bool = l >= 0 + for yyj104 := 0; ; yyj104++ { + if yyhl104 { + if yyj104 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys104Slc = r.DecodeBytes(yys104Slc, true, true) + yys104 := string(yys104Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys104 { + case "Namespace": + if r.TryDecodeAsNil() { + x.Namespace = "" + } else { + x.Namespace = string(r.DecodeString()) + } + case "Verb": + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + case "Group": + if r.TryDecodeAsNil() { + x.Group = "" + } else { + x.Group = string(r.DecodeString()) + } + case "Version": + if r.TryDecodeAsNil() { + x.Version = "" + } else { + x.Version = string(r.DecodeString()) + } + case "Resource": + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + case "Subresource": + if r.TryDecodeAsNil() { + x.Subresource = "" + } else { + x.Subresource = string(r.DecodeString()) + } + case "Name": + if r.TryDecodeAsNil() { + x.Name = "" + } else { + x.Name = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys104) + } // end switch yys104 + } // end for yyj104 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ResourceAttributes) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj112 int + var yyb112 bool + var yyhl112 bool = l >= 0 + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Namespace = "" + } else { + x.Namespace = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Group = "" + } else { + x.Group = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Version = "" + } else { + x.Version = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Subresource = "" + } else { + x.Subresource = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Name = "" + } else { + x.Name = string(r.DecodeString()) + } + for { + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj112-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *NonResourceAttributes) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym120 := z.EncBinary() + _ = yym120 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep121 := !z.EncBinary() + yy2arr121 := z.EncBasicHandle().StructToArray + var yyq121 [2]bool + _, _, _ = yysep121, yyq121, yy2arr121 + const yyr121 bool = false + var yynn121 int + if yyr121 || yy2arr121 { + r.EncodeArrayStart(2) + } else { + yynn121 = 2 + for _, b := range yyq121 { + if b { + yynn121++ + } + } + r.EncodeMapStart(yynn121) + yynn121 = 0 + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym123 := z.EncBinary() + _ = yym123 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Path)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Path")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym124 := z.EncBinary() + _ = yym124 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Path)) + } + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym126 := z.EncBinary() + _ = yym126 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Verb")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym127 := z.EncBinary() + _ = yym127 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *NonResourceAttributes) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym128 := z.DecBinary() + _ = yym128 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct129 := r.ContainerType() + if yyct129 == codecSelferValueTypeMap1234 { + yyl129 := r.ReadMapStart() + if yyl129 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl129, d) + } + } else if yyct129 == codecSelferValueTypeArray1234 { + yyl129 := r.ReadArrayStart() + if yyl129 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl129, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *NonResourceAttributes) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys130Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys130Slc + var yyhl130 bool = l >= 0 + for yyj130 := 0; ; yyj130++ { + if yyhl130 { + if yyj130 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys130Slc = r.DecodeBytes(yys130Slc, true, true) + yys130 := string(yys130Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys130 { + case "Path": + if r.TryDecodeAsNil() { + x.Path = "" + } else { + x.Path = string(r.DecodeString()) + } + case "Verb": + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys130) + } // end switch yys130 + } // end for yyj130 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *NonResourceAttributes) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj133 int + var yyb133 bool + var yyhl133 bool = l >= 0 + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Path = "" + } else { + x.Path = string(r.DecodeString()) + } + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + for { + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj133-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym136 := z.EncBinary() + _ = yym136 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep137 := !z.EncBinary() + yy2arr137 := z.EncBasicHandle().StructToArray + var yyq137 [4]bool + _, _, _ = yysep137, yyq137, yy2arr137 + const yyr137 bool = false + var yynn137 int + if yyr137 || yy2arr137 { + r.EncodeArrayStart(4) + } else { + yynn137 = 4 + for _, b := range yyq137 { + if b { + yynn137++ + } + } + r.EncodeMapStart(yynn137) + yynn137 = 0 + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("ResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("NonResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym141 := z.EncBinary() + _ = yym141 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.User)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("User")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym142 := z.EncBinary() + _ = yym142 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.User)) + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if x.Groups == nil { + r.EncodeNil() + } else { + yym144 := z.EncBinary() + _ = yym144 + if false { + } else { + z.F.EncSliceStringV(x.Groups, false, e) + } + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Groups")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Groups == nil { + r.EncodeNil() + } else { + yym145 := z.EncBinary() + _ = yym145 + if false { + } else { + z.F.EncSliceStringV(x.Groups, false, e) + } + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReviewSpec) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym146 := z.DecBinary() + _ = yym146 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct147 := r.ContainerType() + if yyct147 == codecSelferValueTypeMap1234 { + yyl147 := r.ReadMapStart() + if yyl147 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl147, d) + } + } else if yyct147 == codecSelferValueTypeArray1234 { + yyl147 := r.ReadArrayStart() + if yyl147 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl147, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys148Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys148Slc + var yyhl148 bool = l >= 0 + for yyj148 := 0; ; yyj148++ { + if yyhl148 { + if yyj148 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys148Slc = r.DecodeBytes(yys148Slc, true, true) + yys148 := string(yys148Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys148 { + case "ResourceAttributes": + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + case "NonResourceAttributes": + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + case "User": + if r.TryDecodeAsNil() { + x.User = "" + } else { + x.User = string(r.DecodeString()) + } + case "Groups": + if r.TryDecodeAsNil() { + x.Groups = nil + } else { + yyv152 := &x.Groups + yym153 := z.DecBinary() + _ = yym153 + if false { + } else { + z.F.DecSliceStringX(yyv152, false, d) + } + } + default: + z.DecStructFieldNotFound(-1, yys148) + } // end switch yys148 + } // end for yyj148 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj154 int + var yyb154 bool + var yyhl154 bool = l >= 0 + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.User = "" + } else { + x.User = string(r.DecodeString()) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Groups = nil + } else { + yyv158 := &x.Groups + yym159 := z.DecBinary() + _ = yym159 + if false { + } else { + z.F.DecSliceStringX(yyv158, false, d) + } + } + for { + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj154-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SelfSubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym160 := z.EncBinary() + _ = yym160 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep161 := !z.EncBinary() + yy2arr161 := z.EncBasicHandle().StructToArray + var yyq161 [2]bool + _, _, _ = yysep161, yyq161, yy2arr161 + const yyr161 bool = false + var yynn161 int + if yyr161 || yy2arr161 { + r.EncodeArrayStart(2) + } else { + yynn161 = 2 + for _, b := range yyq161 { + if b { + yynn161++ + } + } + r.EncodeMapStart(yynn161) + yynn161 = 0 + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("ResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("NonResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SelfSubjectAccessReviewSpec) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym164 := z.DecBinary() + _ = yym164 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct165 := r.ContainerType() + if yyct165 == codecSelferValueTypeMap1234 { + yyl165 := r.ReadMapStart() + if yyl165 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl165, d) + } + } else if yyct165 == codecSelferValueTypeArray1234 { + yyl165 := r.ReadArrayStart() + if yyl165 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl165, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SelfSubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys166Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys166Slc + var yyhl166 bool = l >= 0 + for yyj166 := 0; ; yyj166++ { + if yyhl166 { + if yyj166 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys166Slc = r.DecodeBytes(yys166Slc, true, true) + yys166 := string(yys166Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys166 { + case "ResourceAttributes": + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + case "NonResourceAttributes": + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys166) + } // end switch yys166 + } // end for yyj166 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SelfSubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj169 int + var yyb169 bool + var yyhl169 bool = l >= 0 + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + for { + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj169-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SubjectAccessReviewStatus) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym172 := z.EncBinary() + _ = yym172 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep173 := !z.EncBinary() + yy2arr173 := z.EncBasicHandle().StructToArray + var yyq173 [2]bool + _, _, _ = yysep173, yyq173, yy2arr173 + const yyr173 bool = false + var yynn173 int + if yyr173 || yy2arr173 { + r.EncodeArrayStart(2) + } else { + yynn173 = 2 + for _, b := range yyq173 { + if b { + yynn173++ + } + } + r.EncodeMapStart(yynn173) + yynn173 = 0 + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym175 := z.EncBinary() + _ = yym175 + if false { + } else { + r.EncodeBool(bool(x.Allowed)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Allowed")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym176 := z.EncBinary() + _ = yym176 + if false { + } else { + r.EncodeBool(bool(x.Allowed)) + } + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym178 := z.EncBinary() + _ = yym178 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("Reason")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym179 := z.EncBinary() + _ = yym179 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReviewStatus) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym180 := z.DecBinary() + _ = yym180 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct181 := r.ContainerType() + if yyct181 == codecSelferValueTypeMap1234 { + yyl181 := r.ReadMapStart() + if yyl181 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl181, d) + } + } else if yyct181 == codecSelferValueTypeArray1234 { + yyl181 := r.ReadArrayStart() + if yyl181 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl181, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReviewStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys182Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys182Slc + var yyhl182 bool = l >= 0 + for yyj182 := 0; ; yyj182++ { + if yyhl182 { + if yyj182 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys182Slc = r.DecodeBytes(yys182Slc, true, true) + yys182 := string(yys182Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys182 { + case "Allowed": + if r.TryDecodeAsNil() { + x.Allowed = false + } else { + x.Allowed = bool(r.DecodeBool()) + } + case "Reason": + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys182) + } // end switch yys182 + } // end for yyj182 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReviewStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj185 int + var yyb185 bool + var yyhl185 bool = l >= 0 + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Allowed = false + } else { + x.Allowed = bool(r.DecodeBool()) + } + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + for { + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj185-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} diff --git a/pkg/apis/authorization/types.go b/pkg/apis/authorization/types.go new file mode 100644 index 00000000000..5feb0e5468d --- /dev/null +++ b/pkg/apis/authorization/types.go @@ -0,0 +1,121 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 authorization + +import ( + "k8s.io/kubernetes/pkg/api/unversioned" +) + +// SubjectAccessReview checks whether or not a user or group can perform an action. Not filling in a +// spec.namespace means "in all namespaces". +type SubjectAccessReview struct { + unversioned.TypeMeta + + // Spec holds information about the request being evaluated + Spec SubjectAccessReviewSpec + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus +} + +// SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a +// spec.namespace means "in all namespaces". Self is a special case, because users should always be able +// to check whether they can perform an action +type SelfSubjectAccessReview struct { + unversioned.TypeMeta + + // Spec holds information about the request being evaluated. + Spec SelfSubjectAccessReviewSpec + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus +} + +// LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. +// Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions +// checking. +type LocalSubjectAccessReview struct { + unversioned.TypeMeta + + // Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace + // you made the request against. If empty, it is defaulted. + Spec SubjectAccessReviewSpec + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus +} + +// ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface +type ResourceAttributes struct { + // Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces + // "" (empty) is defaulted for LocalSubjectAccessReviews + // "" (empty) is empty for cluster-scoped resources + // "" (empty) means "all" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview + Namespace string + // Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. "*" means all. + Verb string + // Group is the API Group of the Resource. "*" means all. + Group string + // Version is the API Version of the Resource. "*" means all. + Version string + // Resource is one of the existing resource types. "*" means all. + Resource string + // Subresource is one of the existing resource types. "" means none. + Subresource string + // Name is the name of the resource being requested for a "get" or deleted for a "delete". "" (empty) means all. + Name string +} + +// NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface +type NonResourceAttributes struct { + // Path is the URL path of the request + Path string + // Verb is the standard HTTP verb + Verb string +} + +// SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAttributes +// and NonResourceAttributes must be set +type SubjectAccessReviewSpec struct { + // ResourceAttributes describes information for a resource access request + ResourceAttributes *ResourceAttributes + // NonResourceAttributes describes information for a non-resource access request + NonResourceAttributes *NonResourceAttributes + + // User is the user you're testing for. + // If you specify "User" but not "Group", then is it interpreted as "What if User were not a member of any groups + User string + // Groups is the groups you're testing for. + Groups []string +} + +// SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAttributes +// and NonResourceAttributes must be set +type SelfSubjectAccessReviewSpec struct { + // ResourceAttributes describes information for a resource access request + ResourceAttributes *ResourceAttributes + // NonResourceAttributes describes information for a non-resource access request + NonResourceAttributes *NonResourceAttributes +} + +// SubjectAccessReviewStatus +type SubjectAccessReviewStatus struct { + // Allowed is required. True if the action would be allowed, false otherwise. + Allowed bool + // Reason is optional. It indicates why a request was allowed or denied. + Reason string +} diff --git a/pkg/apis/authorization/v1beta1/conversion.go b/pkg/apis/authorization/v1beta1/conversion.go new file mode 100644 index 00000000000..0b45ed5fbab --- /dev/null +++ b/pkg/apis/authorization/v1beta1/conversion.go @@ -0,0 +1,30 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 ( + "k8s.io/kubernetes/pkg/runtime" +) + +func addConversionFuncs(scheme *runtime.Scheme) { + // Add non-generated conversion functions + err := scheme.AddConversionFuncs() + if err != nil { + // If one of the conversion functions is malformed, detect it immediately. + panic(err) + } +} diff --git a/pkg/apis/authorization/v1beta1/conversion_generated.go b/pkg/apis/authorization/v1beta1/conversion_generated.go new file mode 100644 index 00000000000..2a0daee203c --- /dev/null +++ b/pkg/apis/authorization/v1beta1/conversion_generated.go @@ -0,0 +1,29 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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. +*/ + +// DO NOT EDIT. THIS FILE IS AUTO-GENERATED BY $KUBEROOT/hack/update-generated-conversions.sh + +package v1beta1 + +import api "k8s.io/kubernetes/pkg/api" + +func init() { + err := api.Scheme.AddGeneratedConversionFuncs() + if err != nil { + // If one of the conversion functions is malformed, detect it immediately. + panic(err) + } +} diff --git a/pkg/apis/authorization/v1beta1/deep_copy_generated.go b/pkg/apis/authorization/v1beta1/deep_copy_generated.go new file mode 100644 index 00000000000..ccf024c8bff --- /dev/null +++ b/pkg/apis/authorization/v1beta1/deep_copy_generated.go @@ -0,0 +1,29 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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. +*/ + +// DO NOT EDIT. THIS FILE IS AUTO-GENERATED BY $KUBEROOT/hack/update-generated-deep-copies.sh. + +package v1beta1 + +import api "k8s.io/kubernetes/pkg/api" + +func init() { + err := api.Scheme.AddGeneratedDeepCopyFuncs() + if err != nil { + // if one of the deep copy functions is malformed, detect it immediately. + panic(err) + } +} diff --git a/pkg/apis/authorization/v1beta1/defaults.go b/pkg/apis/authorization/v1beta1/defaults.go new file mode 100644 index 00000000000..340f80755a2 --- /dev/null +++ b/pkg/apis/authorization/v1beta1/defaults.go @@ -0,0 +1,25 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 ( + "k8s.io/kubernetes/pkg/runtime" +) + +func addDefaultingFuncs(scheme *runtime.Scheme) { + scheme.AddDefaultingFuncs() +} diff --git a/pkg/apis/authorization/v1beta1/register.go b/pkg/apis/authorization/v1beta1/register.go new file mode 100644 index 00000000000..eee6eaa41c1 --- /dev/null +++ b/pkg/apis/authorization/v1beta1/register.go @@ -0,0 +1,51 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 ( + "k8s.io/kubernetes/pkg/api" + "k8s.io/kubernetes/pkg/api/unversioned" + "k8s.io/kubernetes/pkg/runtime" +) + +// GroupName is the group name use in this package +const GroupName = "authorization.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = unversioned.GroupVersion{Group: GroupName, Version: "v1beta1"} + +var Codec = runtime.CodecFor(api.Scheme, SchemeGroupVersion) + +func AddToScheme(scheme *runtime.Scheme) { + // Add the API to Scheme. + addKnownTypes(scheme) + addDefaultingFuncs(scheme) + addConversionFuncs(scheme) +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) { + scheme.AddKnownTypes(SchemeGroupVersion, + &SelfSubjectAccessReview{}, + &SubjectAccessReview{}, + &LocalSubjectAccessReview{}, + ) +} + +func (obj *LocalSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } +func (obj *SubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } +func (obj *SelfSubjectAccessReview) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta } diff --git a/pkg/apis/authorization/v1beta1/types.generated.go b/pkg/apis/authorization/v1beta1/types.generated.go new file mode 100644 index 00000000000..75ebcf8a789 --- /dev/null +++ b/pkg/apis/authorization/v1beta1/types.generated.go @@ -0,0 +1,2414 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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. +*/ + +// ************************************************************ +// DO NOT EDIT. +// THIS FILE IS AUTO-GENERATED BY codecgen. +// ************************************************************ + +package v1beta1 + +import ( + "errors" + "fmt" + codec1978 "github.com/ugorji/go/codec" + pkg1_unversioned "k8s.io/kubernetes/pkg/api/unversioned" + "reflect" + "runtime" +) + +const ( + // ----- content types ---- + codecSelferC_UTF81234 = 1 + codecSelferC_RAW1234 = 0 + // ----- value types used ---- + codecSelferValueTypeArray1234 = 10 + codecSelferValueTypeMap1234 = 9 + // ----- containerStateValues ---- + codecSelfer_containerMapKey1234 = 2 + codecSelfer_containerMapValue1234 = 3 + codecSelfer_containerMapEnd1234 = 4 + codecSelfer_containerArrayElem1234 = 6 + codecSelfer_containerArrayEnd1234 = 7 +) + +var ( + codecSelferBitsize1234 = uint8(reflect.TypeOf(uint(0)).Bits()) + codecSelferOnlyMapOrArrayEncodeToStructErr1234 = errors.New(`only encoded map or array can be decoded into a struct`) +) + +type codecSelfer1234 struct{} + +func init() { + if codec1978.GenVersion != 5 { + _, file, _, _ := runtime.Caller(0) + err := fmt.Errorf("codecgen version mismatch: current: %v, need %v. Re-generate file: %v", + 5, codec1978.GenVersion, file) + panic(err) + } + if false { // reference the types, but skip this branch at build/run time + var v0 pkg1_unversioned.TypeMeta + _ = v0 + } +} + +func (x *SubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym1 := z.EncBinary() + _ = yym1 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep2 := !z.EncBinary() + yy2arr2 := z.EncBasicHandle().StructToArray + var yyq2 [4]bool + _, _, _ = yysep2, yyq2, yy2arr2 + const yyr2 bool = false + yyq2[0] = x.Kind != "" + yyq2[1] = x.APIVersion != "" + yyq2[3] = true + var yynn2 int + if yyr2 || yy2arr2 { + r.EncodeArrayStart(4) + } else { + yynn2 = 1 + for _, b := range yyq2 { + if b { + yynn2++ + } + } + r.EncodeMapStart(yynn2) + yynn2 = 0 + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[0] { + yym4 := z.EncBinary() + _ = yym4 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym5 := z.EncBinary() + _ = yym5 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[1] { + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy10 := &x.Spec + yy10.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy11 := &x.Spec + yy11.CodecEncodeSelf(e) + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq2[3] { + yy13 := &x.Status + yy13.CodecEncodeSelf(e) + } else { + r.EncodeNil() + } + } else { + if yyq2[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy14 := &x.Status + yy14.CodecEncodeSelf(e) + } + } + if yyr2 || yy2arr2 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym15 := z.DecBinary() + _ = yym15 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct16 := r.ContainerType() + if yyct16 == codecSelferValueTypeMap1234 { + yyl16 := r.ReadMapStart() + if yyl16 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl16, d) + } + } else if yyct16 == codecSelferValueTypeArray1234 { + yyl16 := r.ReadArrayStart() + if yyl16 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl16, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys17Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys17Slc + var yyhl17 bool = l >= 0 + for yyj17 := 0; ; yyj17++ { + if yyhl17 { + if yyj17 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys17Slc = r.DecodeBytes(yys17Slc, true, true) + yys17 := string(yys17Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys17 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "spec": + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv20 := &x.Spec + yyv20.CodecDecodeSelf(d) + } + case "status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv21 := &x.Status + yyv21.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys17) + } // end switch yys17 + } // end for yyj17 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj22 int + var yyb22 bool + var yyhl22 bool = l >= 0 + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv25 := &x.Spec + yyv25.CodecDecodeSelf(d) + } + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv26 := &x.Status + yyv26.CodecDecodeSelf(d) + } + for { + yyj22++ + if yyhl22 { + yyb22 = yyj22 > l + } else { + yyb22 = r.CheckBreak() + } + if yyb22 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj22-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SelfSubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym27 := z.EncBinary() + _ = yym27 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep28 := !z.EncBinary() + yy2arr28 := z.EncBasicHandle().StructToArray + var yyq28 [4]bool + _, _, _ = yysep28, yyq28, yy2arr28 + const yyr28 bool = false + yyq28[0] = x.Kind != "" + yyq28[1] = x.APIVersion != "" + yyq28[3] = true + var yynn28 int + if yyr28 || yy2arr28 { + r.EncodeArrayStart(4) + } else { + yynn28 = 1 + for _, b := range yyq28 { + if b { + yynn28++ + } + } + r.EncodeMapStart(yynn28) + yynn28 = 0 + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq28[0] { + yym30 := z.EncBinary() + _ = yym30 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq28[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym31 := z.EncBinary() + _ = yym31 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq28[1] { + yym33 := z.EncBinary() + _ = yym33 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq28[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym34 := z.EncBinary() + _ = yym34 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy36 := &x.Spec + yy36.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy37 := &x.Spec + yy37.CodecEncodeSelf(e) + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq28[3] { + yy39 := &x.Status + yy39.CodecEncodeSelf(e) + } else { + r.EncodeNil() + } + } else { + if yyq28[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy40 := &x.Status + yy40.CodecEncodeSelf(e) + } + } + if yyr28 || yy2arr28 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SelfSubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym41 := z.DecBinary() + _ = yym41 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct42 := r.ContainerType() + if yyct42 == codecSelferValueTypeMap1234 { + yyl42 := r.ReadMapStart() + if yyl42 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl42, d) + } + } else if yyct42 == codecSelferValueTypeArray1234 { + yyl42 := r.ReadArrayStart() + if yyl42 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl42, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SelfSubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys43Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys43Slc + var yyhl43 bool = l >= 0 + for yyj43 := 0; ; yyj43++ { + if yyhl43 { + if yyj43 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys43Slc = r.DecodeBytes(yys43Slc, true, true) + yys43 := string(yys43Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys43 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "spec": + if r.TryDecodeAsNil() { + x.Spec = SelfSubjectAccessReviewSpec{} + } else { + yyv46 := &x.Spec + yyv46.CodecDecodeSelf(d) + } + case "status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv47 := &x.Status + yyv47.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys43) + } // end switch yys43 + } // end for yyj43 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SelfSubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj48 int + var yyb48 bool + var yyhl48 bool = l >= 0 + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SelfSubjectAccessReviewSpec{} + } else { + yyv51 := &x.Spec + yyv51.CodecDecodeSelf(d) + } + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv52 := &x.Status + yyv52.CodecDecodeSelf(d) + } + for { + yyj48++ + if yyhl48 { + yyb48 = yyj48 > l + } else { + yyb48 = r.CheckBreak() + } + if yyb48 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj48-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *LocalSubjectAccessReview) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym53 := z.EncBinary() + _ = yym53 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep54 := !z.EncBinary() + yy2arr54 := z.EncBasicHandle().StructToArray + var yyq54 [4]bool + _, _, _ = yysep54, yyq54, yy2arr54 + const yyr54 bool = false + yyq54[0] = x.Kind != "" + yyq54[1] = x.APIVersion != "" + yyq54[3] = true + var yynn54 int + if yyr54 || yy2arr54 { + r.EncodeArrayStart(4) + } else { + yynn54 = 1 + for _, b := range yyq54 { + if b { + yynn54++ + } + } + r.EncodeMapStart(yynn54) + yynn54 = 0 + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq54[0] { + yym56 := z.EncBinary() + _ = yym56 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq54[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("kind")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym57 := z.EncBinary() + _ = yym57 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) + } + } + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq54[1] { + yym59 := z.EncBinary() + _ = yym59 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq54[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym60 := z.EncBinary() + _ = yym60 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) + } + } + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy62 := &x.Spec + yy62.CodecEncodeSelf(e) + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("spec")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy63 := &x.Spec + yy63.CodecEncodeSelf(e) + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq54[3] { + yy65 := &x.Status + yy65.CodecEncodeSelf(e) + } else { + r.EncodeNil() + } + } else { + if yyq54[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("status")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy66 := &x.Status + yy66.CodecEncodeSelf(e) + } + } + if yyr54 || yy2arr54 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *LocalSubjectAccessReview) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym67 := z.DecBinary() + _ = yym67 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct68 := r.ContainerType() + if yyct68 == codecSelferValueTypeMap1234 { + yyl68 := r.ReadMapStart() + if yyl68 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl68, d) + } + } else if yyct68 == codecSelferValueTypeArray1234 { + yyl68 := r.ReadArrayStart() + if yyl68 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl68, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *LocalSubjectAccessReview) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys69Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys69Slc + var yyhl69 bool = l >= 0 + for yyj69 := 0; ; yyj69++ { + if yyhl69 { + if yyj69 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys69Slc = r.DecodeBytes(yys69Slc, true, true) + yys69 := string(yys69Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys69 { + case "kind": + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + case "apiVersion": + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + case "spec": + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv72 := &x.Spec + yyv72.CodecDecodeSelf(d) + } + case "status": + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv73 := &x.Status + yyv73.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys69) + } // end switch yys69 + } // end for yyj69 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *LocalSubjectAccessReview) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj74 int + var yyb74 bool + var yyhl74 bool = l >= 0 + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Kind = "" + } else { + x.Kind = string(r.DecodeString()) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.APIVersion = "" + } else { + x.APIVersion = string(r.DecodeString()) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Spec = SubjectAccessReviewSpec{} + } else { + yyv77 := &x.Spec + yyv77.CodecDecodeSelf(d) + } + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Status = SubjectAccessReviewStatus{} + } else { + yyv78 := &x.Status + yyv78.CodecDecodeSelf(d) + } + for { + yyj74++ + if yyhl74 { + yyb74 = yyj74 > l + } else { + yyb74 = r.CheckBreak() + } + if yyb74 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj74-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *ResourceAttributes) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym79 := z.EncBinary() + _ = yym79 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep80 := !z.EncBinary() + yy2arr80 := z.EncBasicHandle().StructToArray + var yyq80 [7]bool + _, _, _ = yysep80, yyq80, yy2arr80 + const yyr80 bool = false + yyq80[0] = x.Namespace != "" + yyq80[1] = x.Verb != "" + yyq80[2] = x.Group != "" + yyq80[3] = x.Version != "" + yyq80[4] = x.Resource != "" + yyq80[5] = x.Subresource != "" + yyq80[6] = x.Name != "" + var yynn80 int + if yyr80 || yy2arr80 { + r.EncodeArrayStart(7) + } else { + yynn80 = 0 + for _, b := range yyq80 { + if b { + yynn80++ + } + } + r.EncodeMapStart(yynn80) + yynn80 = 0 + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[0] { + yym82 := z.EncBinary() + _ = yym82 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Namespace)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("namespace")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym83 := z.EncBinary() + _ = yym83 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Namespace)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[1] { + yym85 := z.EncBinary() + _ = yym85 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("verb")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym86 := z.EncBinary() + _ = yym86 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[2] { + yym88 := z.EncBinary() + _ = yym88 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Group)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("group")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym89 := z.EncBinary() + _ = yym89 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Group)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[3] { + yym91 := z.EncBinary() + _ = yym91 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Version)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("version")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym92 := z.EncBinary() + _ = yym92 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Version)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[4] { + yym94 := z.EncBinary() + _ = yym94 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[4] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym95 := z.EncBinary() + _ = yym95 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Resource)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[5] { + yym97 := z.EncBinary() + _ = yym97 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Subresource)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[5] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("subresource")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym98 := z.EncBinary() + _ = yym98 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Subresource)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq80[6] { + yym100 := z.EncBinary() + _ = yym100 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Name)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq80[6] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("name")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym101 := z.EncBinary() + _ = yym101 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Name)) + } + } + } + if yyr80 || yy2arr80 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *ResourceAttributes) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym102 := z.DecBinary() + _ = yym102 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct103 := r.ContainerType() + if yyct103 == codecSelferValueTypeMap1234 { + yyl103 := r.ReadMapStart() + if yyl103 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl103, d) + } + } else if yyct103 == codecSelferValueTypeArray1234 { + yyl103 := r.ReadArrayStart() + if yyl103 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl103, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *ResourceAttributes) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys104Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys104Slc + var yyhl104 bool = l >= 0 + for yyj104 := 0; ; yyj104++ { + if yyhl104 { + if yyj104 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys104Slc = r.DecodeBytes(yys104Slc, true, true) + yys104 := string(yys104Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys104 { + case "namespace": + if r.TryDecodeAsNil() { + x.Namespace = "" + } else { + x.Namespace = string(r.DecodeString()) + } + case "verb": + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + case "group": + if r.TryDecodeAsNil() { + x.Group = "" + } else { + x.Group = string(r.DecodeString()) + } + case "version": + if r.TryDecodeAsNil() { + x.Version = "" + } else { + x.Version = string(r.DecodeString()) + } + case "resource": + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + case "subresource": + if r.TryDecodeAsNil() { + x.Subresource = "" + } else { + x.Subresource = string(r.DecodeString()) + } + case "name": + if r.TryDecodeAsNil() { + x.Name = "" + } else { + x.Name = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys104) + } // end switch yys104 + } // end for yyj104 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *ResourceAttributes) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj112 int + var yyb112 bool + var yyhl112 bool = l >= 0 + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Namespace = "" + } else { + x.Namespace = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Group = "" + } else { + x.Group = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Version = "" + } else { + x.Version = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Resource = "" + } else { + x.Resource = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Subresource = "" + } else { + x.Subresource = string(r.DecodeString()) + } + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Name = "" + } else { + x.Name = string(r.DecodeString()) + } + for { + yyj112++ + if yyhl112 { + yyb112 = yyj112 > l + } else { + yyb112 = r.CheckBreak() + } + if yyb112 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj112-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *NonResourceAttributes) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym120 := z.EncBinary() + _ = yym120 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep121 := !z.EncBinary() + yy2arr121 := z.EncBasicHandle().StructToArray + var yyq121 [2]bool + _, _, _ = yysep121, yyq121, yy2arr121 + const yyr121 bool = false + yyq121[0] = x.Path != "" + yyq121[1] = x.Verb != "" + var yynn121 int + if yyr121 || yy2arr121 { + r.EncodeArrayStart(2) + } else { + yynn121 = 0 + for _, b := range yyq121 { + if b { + yynn121++ + } + } + r.EncodeMapStart(yynn121) + yynn121 = 0 + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq121[0] { + yym123 := z.EncBinary() + _ = yym123 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Path)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq121[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("path")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym124 := z.EncBinary() + _ = yym124 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Path)) + } + } + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq121[1] { + yym126 := z.EncBinary() + _ = yym126 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq121[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("verb")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym127 := z.EncBinary() + _ = yym127 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) + } + } + } + if yyr121 || yy2arr121 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *NonResourceAttributes) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym128 := z.DecBinary() + _ = yym128 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct129 := r.ContainerType() + if yyct129 == codecSelferValueTypeMap1234 { + yyl129 := r.ReadMapStart() + if yyl129 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl129, d) + } + } else if yyct129 == codecSelferValueTypeArray1234 { + yyl129 := r.ReadArrayStart() + if yyl129 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl129, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *NonResourceAttributes) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys130Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys130Slc + var yyhl130 bool = l >= 0 + for yyj130 := 0; ; yyj130++ { + if yyhl130 { + if yyj130 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys130Slc = r.DecodeBytes(yys130Slc, true, true) + yys130 := string(yys130Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys130 { + case "path": + if r.TryDecodeAsNil() { + x.Path = "" + } else { + x.Path = string(r.DecodeString()) + } + case "verb": + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys130) + } // end switch yys130 + } // end for yyj130 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *NonResourceAttributes) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj133 int + var yyb133 bool + var yyhl133 bool = l >= 0 + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Path = "" + } else { + x.Path = string(r.DecodeString()) + } + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Verb = "" + } else { + x.Verb = string(r.DecodeString()) + } + for { + yyj133++ + if yyhl133 { + yyb133 = yyj133 > l + } else { + yyb133 = r.CheckBreak() + } + if yyb133 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj133-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym136 := z.EncBinary() + _ = yym136 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep137 := !z.EncBinary() + yy2arr137 := z.EncBasicHandle().StructToArray + var yyq137 [4]bool + _, _, _ = yysep137, yyq137, yy2arr137 + const yyr137 bool = false + yyq137[0] = x.ResourceAttributes != nil + yyq137[1] = x.NonResourceAttributes != nil + yyq137[2] = x.User != "" + yyq137[3] = len(x.Groups) != 0 + var yynn137 int + if yyr137 || yy2arr137 { + r.EncodeArrayStart(4) + } else { + yynn137 = 0 + for _, b := range yyq137 { + if b { + yynn137++ + } + } + r.EncodeMapStart(yynn137) + yynn137 = 0 + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq137[0] { + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq137[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq137[1] { + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq137[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("nonResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq137[2] { + yym141 := z.EncBinary() + _ = yym141 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.User)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq137[2] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("user")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym142 := z.EncBinary() + _ = yym142 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.User)) + } + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq137[3] { + if x.Groups == nil { + r.EncodeNil() + } else { + yym144 := z.EncBinary() + _ = yym144 + if false { + } else { + z.F.EncSliceStringV(x.Groups, false, e) + } + } + } else { + r.EncodeNil() + } + } else { + if yyq137[3] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("group")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Groups == nil { + r.EncodeNil() + } else { + yym145 := z.EncBinary() + _ = yym145 + if false { + } else { + z.F.EncSliceStringV(x.Groups, false, e) + } + } + } + } + if yyr137 || yy2arr137 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReviewSpec) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym146 := z.DecBinary() + _ = yym146 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct147 := r.ContainerType() + if yyct147 == codecSelferValueTypeMap1234 { + yyl147 := r.ReadMapStart() + if yyl147 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl147, d) + } + } else if yyct147 == codecSelferValueTypeArray1234 { + yyl147 := r.ReadArrayStart() + if yyl147 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl147, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys148Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys148Slc + var yyhl148 bool = l >= 0 + for yyj148 := 0; ; yyj148++ { + if yyhl148 { + if yyj148 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys148Slc = r.DecodeBytes(yys148Slc, true, true) + yys148 := string(yys148Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys148 { + case "resourceAttributes": + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + case "nonResourceAttributes": + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + case "user": + if r.TryDecodeAsNil() { + x.User = "" + } else { + x.User = string(r.DecodeString()) + } + case "group": + if r.TryDecodeAsNil() { + x.Groups = nil + } else { + yyv152 := &x.Groups + yym153 := z.DecBinary() + _ = yym153 + if false { + } else { + z.F.DecSliceStringX(yyv152, false, d) + } + } + default: + z.DecStructFieldNotFound(-1, yys148) + } // end switch yys148 + } // end for yyj148 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj154 int + var yyb154 bool + var yyhl154 bool = l >= 0 + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.User = "" + } else { + x.User = string(r.DecodeString()) + } + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Groups = nil + } else { + yyv158 := &x.Groups + yym159 := z.DecBinary() + _ = yym159 + if false { + } else { + z.F.DecSliceStringX(yyv158, false, d) + } + } + for { + yyj154++ + if yyhl154 { + yyb154 = yyj154 > l + } else { + yyb154 = r.CheckBreak() + } + if yyb154 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj154-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SelfSubjectAccessReviewSpec) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym160 := z.EncBinary() + _ = yym160 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep161 := !z.EncBinary() + yy2arr161 := z.EncBasicHandle().StructToArray + var yyq161 [2]bool + _, _, _ = yysep161, yyq161, yy2arr161 + const yyr161 bool = false + yyq161[0] = x.ResourceAttributes != nil + yyq161[1] = x.NonResourceAttributes != nil + var yynn161 int + if yyr161 || yy2arr161 { + r.EncodeArrayStart(2) + } else { + yynn161 = 0 + for _, b := range yyq161 { + if b { + yynn161++ + } + } + r.EncodeMapStart(yynn161) + yynn161 = 0 + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq161[0] { + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq161[0] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("resourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.ResourceAttributes == nil { + r.EncodeNil() + } else { + x.ResourceAttributes.CodecEncodeSelf(e) + } + } + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq161[1] { + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } else { + r.EncodeNil() + } + } else { + if yyq161[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("nonResourceAttributes")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.NonResourceAttributes == nil { + r.EncodeNil() + } else { + x.NonResourceAttributes.CodecEncodeSelf(e) + } + } + } + if yyr161 || yy2arr161 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SelfSubjectAccessReviewSpec) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym164 := z.DecBinary() + _ = yym164 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct165 := r.ContainerType() + if yyct165 == codecSelferValueTypeMap1234 { + yyl165 := r.ReadMapStart() + if yyl165 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl165, d) + } + } else if yyct165 == codecSelferValueTypeArray1234 { + yyl165 := r.ReadArrayStart() + if yyl165 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl165, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SelfSubjectAccessReviewSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys166Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys166Slc + var yyhl166 bool = l >= 0 + for yyj166 := 0; ; yyj166++ { + if yyhl166 { + if yyj166 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys166Slc = r.DecodeBytes(yys166Slc, true, true) + yys166 := string(yys166Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys166 { + case "resourceAttributes": + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + case "nonResourceAttributes": + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + default: + z.DecStructFieldNotFound(-1, yys166) + } // end switch yys166 + } // end for yyj166 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SelfSubjectAccessReviewSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj169 int + var yyb169 bool + var yyhl169 bool = l >= 0 + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.ResourceAttributes != nil { + x.ResourceAttributes = nil + } + } else { + if x.ResourceAttributes == nil { + x.ResourceAttributes = new(ResourceAttributes) + } + x.ResourceAttributes.CodecDecodeSelf(d) + } + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + if x.NonResourceAttributes != nil { + x.NonResourceAttributes = nil + } + } else { + if x.NonResourceAttributes == nil { + x.NonResourceAttributes = new(NonResourceAttributes) + } + x.NonResourceAttributes.CodecDecodeSelf(d) + } + for { + yyj169++ + if yyhl169 { + yyb169 = yyj169 > l + } else { + yyb169 = r.CheckBreak() + } + if yyb169 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj169-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} + +func (x *SubjectAccessReviewStatus) CodecEncodeSelf(e *codec1978.Encoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperEncoder(e) + _, _, _ = h, z, r + if x == nil { + r.EncodeNil() + } else { + yym172 := z.EncBinary() + _ = yym172 + if false { + } else if z.HasExtensions() && z.EncExt(x) { + } else { + yysep173 := !z.EncBinary() + yy2arr173 := z.EncBasicHandle().StructToArray + var yyq173 [2]bool + _, _, _ = yysep173, yyq173, yy2arr173 + const yyr173 bool = false + yyq173[1] = x.Reason != "" + var yynn173 int + if yyr173 || yy2arr173 { + r.EncodeArrayStart(2) + } else { + yynn173 = 1 + for _, b := range yyq173 { + if b { + yynn173++ + } + } + r.EncodeMapStart(yynn173) + yynn173 = 0 + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym175 := z.EncBinary() + _ = yym175 + if false { + } else { + r.EncodeBool(bool(x.Allowed)) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("allowed")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym176 := z.EncBinary() + _ = yym176 + if false { + } else { + r.EncodeBool(bool(x.Allowed)) + } + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq173[1] { + yym178 := z.EncBinary() + _ = yym178 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq173[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("reason")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym179 := z.EncBinary() + _ = yym179 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.Reason)) + } + } + } + if yyr173 || yy2arr173 { + z.EncSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + z.EncSendContainerState(codecSelfer_containerMapEnd1234) + } + } + } +} + +func (x *SubjectAccessReviewStatus) CodecDecodeSelf(d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + yym180 := z.DecBinary() + _ = yym180 + if false { + } else if z.HasExtensions() && z.DecExt(x) { + } else { + yyct181 := r.ContainerType() + if yyct181 == codecSelferValueTypeMap1234 { + yyl181 := r.ReadMapStart() + if yyl181 == 0 { + z.DecSendContainerState(codecSelfer_containerMapEnd1234) + } else { + x.codecDecodeSelfFromMap(yyl181, d) + } + } else if yyct181 == codecSelferValueTypeArray1234 { + yyl181 := r.ReadArrayStart() + if yyl181 == 0 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + } else { + x.codecDecodeSelfFromArray(yyl181, d) + } + } else { + panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) + } + } +} + +func (x *SubjectAccessReviewStatus) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yys182Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys182Slc + var yyhl182 bool = l >= 0 + for yyj182 := 0; ; yyj182++ { + if yyhl182 { + if yyj182 >= l { + break + } + } else { + if r.CheckBreak() { + break + } + } + z.DecSendContainerState(codecSelfer_containerMapKey1234) + yys182Slc = r.DecodeBytes(yys182Slc, true, true) + yys182 := string(yys182Slc) + z.DecSendContainerState(codecSelfer_containerMapValue1234) + switch yys182 { + case "allowed": + if r.TryDecodeAsNil() { + x.Allowed = false + } else { + x.Allowed = bool(r.DecodeBool()) + } + case "reason": + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + default: + z.DecStructFieldNotFound(-1, yys182) + } // end switch yys182 + } // end for yyj182 + z.DecSendContainerState(codecSelfer_containerMapEnd1234) +} + +func (x *SubjectAccessReviewStatus) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { + var h codecSelfer1234 + z, r := codec1978.GenHelperDecoder(d) + _, _, _ = h, z, r + var yyj185 int + var yyb185 bool + var yyhl185 bool = l >= 0 + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Allowed = false + } else { + x.Allowed = bool(r.DecodeBool()) + } + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.Reason = "" + } else { + x.Reason = string(r.DecodeString()) + } + for { + yyj185++ + if yyhl185 { + yyb185 = yyj185 > l + } else { + yyb185 = r.CheckBreak() + } + if yyb185 { + break + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + z.DecStructFieldNotFound(yyj185-1, "") + } + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) +} diff --git a/pkg/apis/authorization/v1beta1/types.go b/pkg/apis/authorization/v1beta1/types.go new file mode 100644 index 00000000000..0a8cb69a74a --- /dev/null +++ b/pkg/apis/authorization/v1beta1/types.go @@ -0,0 +1,120 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 ( + "k8s.io/kubernetes/pkg/api/unversioned" +) + +// SubjectAccessReview checks whether or not a user or group can perform an action. +type SubjectAccessReview struct { + unversioned.TypeMeta `json:",inline"` + + // Spec holds information about the request being evaluated + Spec SubjectAccessReviewSpec `json:"spec"` + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus `json:"status,omitempty"` +} + +// SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a +// spec.namespace means "in all namespaces". Self is a special case, because users should always be able +// to check whether they can perform an action +type SelfSubjectAccessReview struct { + unversioned.TypeMeta `json:",inline"` + + // Spec holds information about the request being evaluated. user and groups must be empty + Spec SelfSubjectAccessReviewSpec `json:"spec"` + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus `json:"status,omitempty"` +} + +// LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. +// Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions +// checking. +type LocalSubjectAccessReview struct { + unversioned.TypeMeta `json:",inline"` + + // Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace + // you made the request against. If empty, it is defaulted. + Spec SubjectAccessReviewSpec `json:"spec"` + + // Status is filled in by the server and indicates whether the request is allowed or not + Status SubjectAccessReviewStatus `json:"status,omitempty"` +} + +// ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface +type ResourceAttributes struct { + // Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces + // "" (empty) is defaulted for LocalSubjectAccessReviews + // "" (empty) is empty for cluster-scoped resources + // "" (empty) means "all" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview + Namespace string `json:"namespace,omitempty"` + // Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. "*" means all. + Verb string `json:"verb,omitempty"` + // Group is the API Group of the Resource. "*" means all. + Group string `json:"group,omitempty"` + // Version is the API Version of the Resource. "*" means all. + Version string `json:"version,omitempty"` + // Resource is one of the existing resource types. "*" means all. + Resource string `json:"resource,omitempty"` + // Subresource is one of the existing resource types. "" means none. + Subresource string `json:"subresource,omitempty"` + // Name is the name of the resource being requested for a "get" or deleted for a "delete". "" (empty) means all. + Name string `json:"name,omitempty"` +} + +// NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface +type NonResourceAttributes struct { + // Path is the URL path of the request + Path string `json:"path,omitempty"` + // Verb is the standard HTTP verb + Verb string `json:"verb,omitempty"` +} + +// SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes +// and NonResourceAuthorizationAttributes must be set +type SubjectAccessReviewSpec struct { + // ResourceAuthorizationAttributes describes information for a resource access request + ResourceAttributes *ResourceAttributes `json:"resourceAttributes,omitempty"` + // NonResourceAttributes describes information for a non-resource access request + NonResourceAttributes *NonResourceAttributes `json:"nonResourceAttributes,omitempty"` + + // User is the user you're testing for. + // If you specify "User" but not "Group", then is it interpreted as "What if User were not a member of any groups + User string `json:"user,omitempty"` + // Groups is the groups you're testing for. + Groups []string `json:"group,omitempty"` +} + +// SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes +// and NonResourceAuthorizationAttributes must be set +type SelfSubjectAccessReviewSpec struct { + // ResourceAuthorizationAttributes describes information for a resource access request + ResourceAttributes *ResourceAttributes `json:"resourceAttributes,omitempty"` + // NonResourceAttributes describes information for a non-resource access request + NonResourceAttributes *NonResourceAttributes `json:"nonResourceAttributes,omitempty"` +} + +// SubjectAccessReviewStatus +type SubjectAccessReviewStatus struct { + // Allowed is required. True if the action would be allowed, false otherwise. + Allowed bool `json:"allowed"` + // Reason is optional. It indicates why a request was allowed or denied. + Reason string `json:"reason,omitempty"` +} diff --git a/pkg/apis/authorization/v1beta1/types_swagger_doc_generated.go b/pkg/apis/authorization/v1beta1/types_swagger_doc_generated.go new file mode 100644 index 00000000000..681e962ed18 --- /dev/null +++ b/pkg/apis/authorization/v1beta1/types_swagger_doc_generated.go @@ -0,0 +1,117 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 + +// This file contains a collection of methods that can be used from go-resful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-generated-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_LocalSubjectAccessReview = map[string]string{ + "": "LocalSubjectAccessReview checks whether or not a user or group can perform an action in a given namespace. Having a namespace scoped resource makes it much easier to grant namespace scoped policy that includes permissions checking.", + "spec": "Spec holds information about the request being evaluated. spec.namespace must be equal to the namespace you made the request against. If empty, it is defaulted.", + "status": "Status is filled in by the server and indicates whether the request is allowed or not", +} + +func (LocalSubjectAccessReview) SwaggerDoc() map[string]string { + return map_LocalSubjectAccessReview +} + +var map_NonResourceAttributes = map[string]string{ + "": "NonResourceAttributes includes the authorization attributes available for non-resource requests to the Authorizer interface", + "path": "Path is the URL path of the request", + "verb": "Verb is the standard HTTP verb", +} + +func (NonResourceAttributes) SwaggerDoc() map[string]string { + return map_NonResourceAttributes +} + +var map_ResourceAttributes = map[string]string{ + "": "ResourceAttributes includes the authorization attributes available for resource requests to the Authorizer interface", + "namespace": "Namespace is the namespace of the action being requested. Currently, there is no distinction between no namespace and all namespaces \"\" (empty) is defaulted for LocalSubjectAccessReviews \"\" (empty) is empty for cluster-scoped resources \"\" (empty) means \"all\" for namespace scoped resources from a SubjectAccessReview or SelfSubjectAccessReview", + "verb": "Verb is a kubernetes resource API verb, like: get, list, watch, create, update, delete, proxy. \"*\" means all.", + "group": "Group is the API Group of the Resource. \"*\" means all.", + "version": "Version is the API Version of the Resource. \"*\" means all.", + "resource": "Resource is one of the existing resource types. \"*\" means all.", + "subresource": "Subresource is one of the existing resource types. \"\" means none.", + "name": "Name is the name of the resource being requested for a \"get\" or deleted for a \"delete\". \"\" (empty) means all.", +} + +func (ResourceAttributes) SwaggerDoc() map[string]string { + return map_ResourceAttributes +} + +var map_SelfSubjectAccessReview = map[string]string{ + "": "SelfSubjectAccessReview checks whether or the current user can perform an action. Not filling in a spec.namespace means \"in all namespaces\". Self is a special case, because users should always be able to check whether they can perform an action", + "spec": "Spec holds information about the request being evaluated. user and groups must be empty", + "status": "Status is filled in by the server and indicates whether the request is allowed or not", +} + +func (SelfSubjectAccessReview) SwaggerDoc() map[string]string { + return map_SelfSubjectAccessReview +} + +var map_SelfSubjectAccessReviewSpec = map[string]string{ + "": "SelfSubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "resourceAttributes": "ResourceAuthorizationAttributes describes information for a resource access request", + "nonResourceAttributes": "NonResourceAttributes describes information for a non-resource access request", +} + +func (SelfSubjectAccessReviewSpec) SwaggerDoc() map[string]string { + return map_SelfSubjectAccessReviewSpec +} + +var map_SubjectAccessReview = map[string]string{ + "": "SubjectAccessReview checks whether or not a user or group can perform an action.", + "spec": "Spec holds information about the request being evaluated", + "status": "Status is filled in by the server and indicates whether the request is allowed or not", +} + +func (SubjectAccessReview) SwaggerDoc() map[string]string { + return map_SubjectAccessReview +} + +var map_SubjectAccessReviewSpec = map[string]string{ + "": "SubjectAccessReviewSpec is a description of the access request. Exactly one of ResourceAuthorizationAttributes and NonResourceAuthorizationAttributes must be set", + "resourceAttributes": "ResourceAuthorizationAttributes describes information for a resource access request", + "nonResourceAttributes": "NonResourceAttributes describes information for a non-resource access request", + "user": "User is the user you're testing for. If you specify \"User\" but not \"Group\", then is it interpreted as \"What if User were not a member of any groups", + "group": "Groups is the groups you're testing for.", +} + +func (SubjectAccessReviewSpec) SwaggerDoc() map[string]string { + return map_SubjectAccessReviewSpec +} + +var map_SubjectAccessReviewStatus = map[string]string{ + "": "SubjectAccessReviewStatus", + "allowed": "Allowed is required. True if the action would be allowed, false otherwise.", + "reason": "Reason is optional. It indicates why a request was allowed or denied.", +} + +func (SubjectAccessReviewStatus) SwaggerDoc() map[string]string { + return map_SubjectAccessReviewStatus +} + +// AUTO-GENERATED FUNCTIONS END HERE diff --git a/pkg/apis/authorization/validation/validation.go b/pkg/apis/authorization/validation/validation.go new file mode 100644 index 00000000000..11a548f416d --- /dev/null +++ b/pkg/apis/authorization/validation/validation.go @@ -0,0 +1,64 @@ +/* +Copyright 2015 The Kubernetes Authors All rights reserved. + +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 validation + +import ( + authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" + "k8s.io/kubernetes/pkg/util/validation/field" +) + +func ValidateSubjectAccessReviewSpec(spec authorizationapi.SubjectAccessReviewSpec, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + if spec.ResourceAttributes != nil && spec.NonResourceAttributes != nil { + allErrs = append(allErrs, field.Invalid(fldPath.Child("nonResourceAttributes"), spec.NonResourceAttributes, `cannot be specified in combination with resourceAttributes`)) + } + if spec.ResourceAttributes == nil && spec.NonResourceAttributes == nil { + allErrs = append(allErrs, field.Invalid(fldPath.Child("resourceAttributes"), spec.NonResourceAttributes, `exactly one of nonResourceAttributes or resourceAttributes must be specified`)) + } + if len(spec.User) == 0 && len(spec.Groups) == 0 { + allErrs = append(allErrs, field.Invalid(fldPath.Child("user"), spec.User, `at least one of user or group must be specified`)) + } + + return allErrs +} + +func ValidateSelfSubjectAccessReviewSpec(spec authorizationapi.SelfSubjectAccessReviewSpec, fldPath *field.Path) field.ErrorList { + allErrs := field.ErrorList{} + if spec.ResourceAttributes != nil && spec.NonResourceAttributes != nil { + allErrs = append(allErrs, field.Invalid(fldPath.Child("nonResourceAttributes"), spec.NonResourceAttributes, `cannot be specified in combination with resourceAttributes`)) + } + if spec.ResourceAttributes == nil && spec.NonResourceAttributes == nil { + allErrs = append(allErrs, field.Invalid(fldPath.Child("resourceAttributes"), spec.NonResourceAttributes, `exactly one of nonResourceAttributes or resourceAttributes must be specified`)) + } + + return allErrs +} + +func ValidateSubjectAccessReview(sar *authorizationapi.SubjectAccessReview) field.ErrorList { + allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) + return allErrs +} + +func ValidateSelfSubjectAccessReview(sar *authorizationapi.SelfSubjectAccessReview) field.ErrorList { + allErrs := ValidateSelfSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) + return allErrs +} + +func ValidateLocalSubjectAccessReview(sar *authorizationapi.LocalSubjectAccessReview) field.ErrorList { + allErrs := ValidateSubjectAccessReviewSpec(sar.Spec, field.NewPath("spec")) + return allErrs +} diff --git a/pkg/apis/authorization/validation/validation_test.go b/pkg/apis/authorization/validation/validation_test.go new file mode 100644 index 00000000000..c2776c404ed --- /dev/null +++ b/pkg/apis/authorization/validation/validation_test.go @@ -0,0 +1,135 @@ +/* +Copyright 2014 The Kubernetes Authors All rights reserved. + +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 validation + +import ( + "strings" + "testing" + + authorizationapi "k8s.io/kubernetes/pkg/apis/authorization" + "k8s.io/kubernetes/pkg/util/validation/field" +) + +func TestValidateSARSpec(t *testing.T) { + successCases := []authorizationapi.SubjectAccessReviewSpec{ + {ResourceAttributes: &authorizationapi.ResourceAttributes{}, User: "me"}, + {NonResourceAttributes: &authorizationapi.NonResourceAttributes{}, Groups: []string{"my-group"}}, + } + for _, successCase := range successCases { + if errs := ValidateSubjectAccessReviewSpec(successCase, field.NewPath("spec")); len(errs) != 0 { + t.Errorf("expected success: %v", errs) + } + } + + errorCases := []struct { + name string + obj authorizationapi.SubjectAccessReviewSpec + msg string + }{ + { + name: "neither request", + obj: authorizationapi.SubjectAccessReviewSpec{User: "me"}, + msg: "exactly one of nonResourceAttributes or resourceAttributes must be specified", + }, + { + name: "both requests", + obj: authorizationapi.SubjectAccessReviewSpec{ + ResourceAttributes: &authorizationapi.ResourceAttributes{}, + NonResourceAttributes: &authorizationapi.NonResourceAttributes{}, + User: "me", + }, + msg: "cannot be specified in combination with resourceAttributes", + }, + { + name: "no subject", + obj: authorizationapi.SubjectAccessReviewSpec{ + ResourceAttributes: &authorizationapi.ResourceAttributes{}, + }, + msg: `spec.user: Invalid value: "": at least one of user or group must be specified`, + }, + } + + for _, c := range errorCases { + errs := ValidateSubjectAccessReviewSpec(c.obj, field.NewPath("spec")) + if len(errs) == 0 { + t.Errorf("%s: expected failure for %q", c.name, c.msg) + } else if !strings.Contains(errs[0].Error(), c.msg) { + t.Errorf("%s: unexpected error: %q, expected: %q", c.name, errs[0], c.msg) + } + + errs = ValidateSubjectAccessReview(&authorizationapi.SubjectAccessReview{Spec: c.obj}) + if len(errs) == 0 { + t.Errorf("%s: expected failure for %q", c.name, c.msg) + } else if !strings.Contains(errs[0].Error(), c.msg) { + t.Errorf("%s: unexpected error: %q, expected: %q", c.name, errs[0], c.msg) + } + errs = ValidateLocalSubjectAccessReview(&authorizationapi.LocalSubjectAccessReview{Spec: c.obj}) + if len(errs) == 0 { + t.Errorf("%s: expected failure for %q", c.name, c.msg) + } else if !strings.Contains(errs[0].Error(), c.msg) { + t.Errorf("%s: unexpected error: %q, expected: %q", c.name, errs[0], c.msg) + } + + } +} + +func TestValidateSelfSAR(t *testing.T) { + successCases := []authorizationapi.SelfSubjectAccessReviewSpec{ + {ResourceAttributes: &authorizationapi.ResourceAttributes{}}, + } + for _, successCase := range successCases { + if errs := ValidateSelfSubjectAccessReviewSpec(successCase, field.NewPath("spec")); len(errs) != 0 { + t.Errorf("expected success: %v", errs) + } + } + + errorCases := []struct { + name string + obj authorizationapi.SelfSubjectAccessReviewSpec + msg string + }{ + { + name: "neither request", + obj: authorizationapi.SelfSubjectAccessReviewSpec{}, + msg: "exactly one of nonResourceAttributes or resourceAttributes must be specified", + }, + { + name: "both requests", + obj: authorizationapi.SelfSubjectAccessReviewSpec{ + ResourceAttributes: &authorizationapi.ResourceAttributes{}, + NonResourceAttributes: &authorizationapi.NonResourceAttributes{}, + }, + msg: "cannot be specified in combination with resourceAttributes", + }, + } + + for _, c := range errorCases { + errs := ValidateSelfSubjectAccessReviewSpec(c.obj, field.NewPath("spec")) + if len(errs) == 0 { + t.Errorf("%s: expected failure for %q", c.name, c.msg) + } else if !strings.Contains(errs[0].Error(), c.msg) { + t.Errorf("%s: unexpected error: %q, expected: %q", c.name, errs[0], c.msg) + } + + errs = ValidateSelfSubjectAccessReview(&authorizationapi.SelfSubjectAccessReview{Spec: c.obj}) + if len(errs) == 0 { + t.Errorf("%s: expected failure for %q", c.name, c.msg) + } else if !strings.Contains(errs[0].Error(), c.msg) { + t.Errorf("%s: unexpected error: %q, expected: %q", c.name, errs[0], c.msg) + } + } +} diff --git a/pkg/client/unversioned/import_known_versions.go b/pkg/client/unversioned/import_known_versions.go index de3eea01535..1b4f4b6d163 100644 --- a/pkg/client/unversioned/import_known_versions.go +++ b/pkg/client/unversioned/import_known_versions.go @@ -22,6 +22,7 @@ import ( _ "k8s.io/kubernetes/pkg/api/install" "k8s.io/kubernetes/pkg/api/registered" + _ "k8s.io/kubernetes/pkg/apis/authorization/install" _ "k8s.io/kubernetes/pkg/apis/componentconfig/install" _ "k8s.io/kubernetes/pkg/apis/extensions/install" _ "k8s.io/kubernetes/pkg/apis/metrics/install" diff --git a/pkg/master/import_known_versions.go b/pkg/master/import_known_versions.go index f11e2473082..d9084e8653b 100644 --- a/pkg/master/import_known_versions.go +++ b/pkg/master/import_known_versions.go @@ -22,6 +22,7 @@ import ( _ "k8s.io/kubernetes/pkg/api/install" "k8s.io/kubernetes/pkg/api/registered" + _ "k8s.io/kubernetes/pkg/apis/authorization/install" _ "k8s.io/kubernetes/pkg/apis/componentconfig/install" _ "k8s.io/kubernetes/pkg/apis/extensions/install" )