diff --git a/go.mod b/go.mod index 304bf95d3..948e53de9 100644 --- a/go.mod +++ b/go.mod @@ -14,10 +14,10 @@ require ( k8s.io/api v0.29.2 k8s.io/apimachinery v0.29.2 k8s.io/client-go v0.29.2 - knative.dev/eventing v0.41.1-0.20240611091249-c60bcd048fd3 + knative.dev/eventing v0.41.1-0.20240612160448-8da4543f0d1e knative.dev/hack v0.0.0-20240607132042-09143140a254 knative.dev/pkg v0.0.0-20240610120318-15e6cdf2f386 - knative.dev/serving v0.41.1-0.20240611132024-227975c8e431 + knative.dev/serving v0.41.1-0.20240611143228-2e5d17e9fc8b ) require ( @@ -97,6 +97,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apiextensions-apiserver v0.29.2 // indirect + k8s.io/apiserver v0.29.2 // indirect k8s.io/code-generator v0.29.2 // indirect k8s.io/gengo v0.0.0-20240129211411-f967bbeff4b4 // indirect k8s.io/klog/v2 v2.120.1 // indirect diff --git a/go.sum b/go.sum index afc3dc662..652352d90 100644 --- a/go.sum +++ b/go.sum @@ -708,6 +708,8 @@ k8s.io/apiextensions-apiserver v0.29.2 h1:UK3xB5lOWSnhaCk0RFZ0LUacPZz9RY4wi/yt2I k8s.io/apiextensions-apiserver v0.29.2/go.mod h1:aLfYjpA5p3OwtqNXQFkhJ56TB+spV8Gc4wfMhUA3/b8= k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +k8s.io/apiserver v0.29.2 h1:+Z9S0dSNr+CjnVXQePG8TcBWHr3Q7BmAr7NraHvsMiQ= +k8s.io/apiserver v0.29.2/go.mod h1:B0LieKVoyU7ykQvPFm7XSdIHaCHSzCzQWPFa5bqbeMQ= k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg= k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA= k8s.io/code-generator v0.29.2 h1:c9/iw2KnNpw2IRV+wwuG/Wns2TjPSgjWzbbjTevyiHI= @@ -721,16 +723,16 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/eventing v0.41.1-0.20240611091249-c60bcd048fd3 h1:7bEWWwqii6HSTL+mQllc3b+6clIsh84cF/ufCVxVszU= -knative.dev/eventing v0.41.1-0.20240611091249-c60bcd048fd3/go.mod h1:PQpuuOYjAl6rW74U+1CgcKP9IyKhk7XhS8aAu9zWQG0= +knative.dev/eventing v0.41.1-0.20240612160448-8da4543f0d1e h1:qp+hRVd6Yq+ZNAFeizvvCaSU4Mwu0w9ZOgYWkwTvwMo= +knative.dev/eventing v0.41.1-0.20240612160448-8da4543f0d1e/go.mod h1:PQpuuOYjAl6rW74U+1CgcKP9IyKhk7XhS8aAu9zWQG0= knative.dev/hack v0.0.0-20240607132042-09143140a254 h1:1YFnu3U6dWZg0oxm6GU8kEdA9A+BvSWKJO7sg3N0kq8= knative.dev/hack v0.0.0-20240607132042-09143140a254/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/networking v0.0.0-20240607132834-85e269dff522 h1:zDtZStHJI3La7jSHUAjN4Jgv0/Yynl51kuchlVLHqzA= knative.dev/networking v0.0.0-20240607132834-85e269dff522/go.mod h1:WS5A291Vy2unZ1L54ZSKBkz/gVzVmIy15cCcdA6PRN4= knative.dev/pkg v0.0.0-20240610120318-15e6cdf2f386 h1:nxFTT6DrXr70Zi2BK8nc57ts0/smyavd/uBRBbtqg94= knative.dev/pkg v0.0.0-20240610120318-15e6cdf2f386/go.mod h1:l7R8/SteYph0mZDsVgq3fVs4mWp1DaYx9BJJX68U6ik= -knative.dev/serving v0.41.1-0.20240611132024-227975c8e431 h1:WpRFAI/iIxIP60FFXCL0tKoIDgUacM2sYA9kLyPIk3c= -knative.dev/serving v0.41.1-0.20240611132024-227975c8e431/go.mod h1:Z58WxiVmEynF1kX8cK4fYmNprj8IkPLl2mEHdvuP6nc= +knative.dev/serving v0.41.1-0.20240611143228-2e5d17e9fc8b h1:GlQkX+LuU5K4YVQfDKV1vWLZDAuKzxb2OnwxUFAFJBY= +knative.dev/serving v0.41.1-0.20240611143228-2e5d17e9fc8b/go.mod h1:Z58WxiVmEynF1kX8cK4fYmNprj8IkPLl2mEHdvuP6nc= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/vendor/k8s.io/apimachinery/pkg/util/rand/rand.go b/vendor/k8s.io/apimachinery/pkg/util/rand/rand.go new file mode 100644 index 000000000..82a473bb1 --- /dev/null +++ b/vendor/k8s.io/apimachinery/pkg/util/rand/rand.go @@ -0,0 +1,127 @@ +/* +Copyright 2015 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package rand provides utilities related to randomization. +package rand + +import ( + "math/rand" + "sync" + "time" +) + +var rng = struct { + sync.Mutex + rand *rand.Rand +}{ + rand: rand.New(rand.NewSource(time.Now().UnixNano())), +} + +// Int returns a non-negative pseudo-random int. +func Int() int { + rng.Lock() + defer rng.Unlock() + return rng.rand.Int() +} + +// Intn generates an integer in range [0,max). +// By design this should panic if input is invalid, <= 0. +func Intn(max int) int { + rng.Lock() + defer rng.Unlock() + return rng.rand.Intn(max) +} + +// IntnRange generates an integer in range [min,max). +// By design this should panic if input is invalid, <= 0. +func IntnRange(min, max int) int { + rng.Lock() + defer rng.Unlock() + return rng.rand.Intn(max-min) + min +} + +// IntnRange generates an int64 integer in range [min,max). +// By design this should panic if input is invalid, <= 0. +func Int63nRange(min, max int64) int64 { + rng.Lock() + defer rng.Unlock() + return rng.rand.Int63n(max-min) + min +} + +// Seed seeds the rng with the provided seed. +func Seed(seed int64) { + rng.Lock() + defer rng.Unlock() + + rng.rand = rand.New(rand.NewSource(seed)) +} + +// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n) +// from the default Source. +func Perm(n int) []int { + rng.Lock() + defer rng.Unlock() + return rng.rand.Perm(n) +} + +const ( + // We omit vowels from the set of available characters to reduce the chances + // of "bad words" being formed. + alphanums = "bcdfghjklmnpqrstvwxz2456789" + // No. of bits required to index into alphanums string. + alphanumsIdxBits = 5 + // Mask used to extract last alphanumsIdxBits of an int. + alphanumsIdxMask = 1<>= alphanumsIdxBits + remaining-- + } + return string(b) +} + +// SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and +// ensures that strings generated from hash functions appear consistent throughout the API. +func SafeEncodeString(s string) string { + r := make([]byte, len(s)) + for i, b := range []rune(s) { + r[i] = alphanums[(int(b) % len(alphanums))] + } + return string(r) +} diff --git a/vendor/k8s.io/apiserver/LICENSE b/vendor/k8s.io/apiserver/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/vendor/k8s.io/apiserver/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + 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. diff --git a/vendor/k8s.io/apiserver/pkg/storage/names/generate.go b/vendor/k8s.io/apiserver/pkg/storage/names/generate.go new file mode 100644 index 000000000..0b8afff0e --- /dev/null +++ b/vendor/k8s.io/apiserver/pkg/storage/names/generate.go @@ -0,0 +1,54 @@ +/* +Copyright 2014 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package names + +import ( + "fmt" + + utilrand "k8s.io/apimachinery/pkg/util/rand" +) + +// NameGenerator generates names for objects. Some backends may have more information +// available to guide selection of new names and this interface hides those details. +type NameGenerator interface { + // GenerateName generates a valid name from the base name, adding a random suffix to + // the base. If base is valid, the returned name must also be valid. The generator is + // responsible for knowing the maximum valid name length. + GenerateName(base string) string +} + +// simpleNameGenerator generates random names. +type simpleNameGenerator struct{} + +// SimpleNameGenerator is a generator that returns the name plus a random suffix of five alphanumerics +// when a name is requested. The string is guaranteed to not exceed the length of a standard Kubernetes +// name (63 characters) +var SimpleNameGenerator NameGenerator = simpleNameGenerator{} + +const ( + // TODO: make this flexible for non-core resources with alternate naming rules. + maxNameLength = 63 + randomLength = 5 + MaxGeneratedNameLength = maxNameLength - randomLength +) + +func (simpleNameGenerator) GenerateName(base string) string { + if len(base) > MaxGeneratedNameLength { + base = base[:MaxGeneratedNameLength] + } + return fmt.Sprintf("%s%s", base, utilrand.String(randomLength)) +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/doc.go new file mode 100644 index 000000000..1f2222463 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 is the v1alpha1 version of the API. +// +k8s:deepcopy-gen=package +// +groupName=eventing.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_conversion.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_conversion.go new file mode 100644 index 000000000..ed74482e2 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_conversion.go @@ -0,0 +1,34 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertTo implements apis.Convertible +func (ep *EventPolicy) ConvertTo(ctx context.Context, obj apis.Convertible) error { + return fmt.Errorf("v1alpha1 is the highest known version, got: %T", obj) +} + +// ConvertFrom implements apis.Convertible +func (ep *EventPolicy) ConvertFrom(ctx context.Context, obj apis.Convertible) error { + return fmt.Errorf("v1alpha1 is the highest known version, got: %T", obj) +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_defaults.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_defaults.go new file mode 100644 index 000000000..3e52f5bd4 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_defaults.go @@ -0,0 +1,31 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +func (ep *EventPolicy) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, ep.ObjectMeta) + ep.Spec.SetDefaults(ctx) +} + +func (ets *EventPolicySpec) SetDefaults(ctx context.Context) { +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_lifecycle.go new file mode 100644 index 000000000..30c8575ea --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_lifecycle.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "knative.dev/pkg/apis" +) + +var eventPolicyCondSet = apis.NewLivingConditionSet() + +const ( + EventPolicyConditionReady = apis.ConditionReady +) + +// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface. +func (*EventPolicy) GetConditionSet() apis.ConditionSet { + return eventPolicyCondSet +} + +// GetCondition returns the condition currently associated with the given type, or nil. +func (et *EventPolicyStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return eventPolicyCondSet.Manage(et).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (et *EventPolicyStatus) IsReady() bool { + return et.GetTopLevelCondition().IsTrue() +} + +// GetTopLevelCondition returns the top level Condition. +func (et *EventPolicyStatus) GetTopLevelCondition() *apis.Condition { + return eventPolicyCondSet.Manage(et).GetTopLevelCondition() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (et *EventPolicyStatus) InitializeConditions() { + eventPolicyCondSet.Manage(et).InitializeConditions() +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_types.go new file mode 100644 index 000000000..53d626534 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_types.go @@ -0,0 +1,168 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +genreconciler +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// EventPolicy represents a policy for addressable resources (Broker, Channel, sinks). +type EventPolicy struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the EventPolicy. + Spec EventPolicySpec `json:"spec,omitempty"` + + // Status represents the current state of the EventPolicy. + // This data may be out of date. + // +optional + Status EventPolicyStatus `json:"status,omitempty"` +} + +var ( + // Check that EventPolicy can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*EventPolicy)(nil) + _ apis.Defaultable = (*EventPolicy)(nil) + + // Check that EventPolicy can return its spec untyped. + _ apis.HasSpec = (*EventPolicy)(nil) + + _ runtime.Object = (*EventPolicy)(nil) + + // Check that we can create OwnerReferences to an EventPolicy. + _ kmeta.OwnerRefable = (*EventPolicy)(nil) + + // Check that the type conforms to the duck Knative Resource shape. + _ duckv1.KRShaped = (*EventPolicy)(nil) +) + +type EventPolicySpec struct { + // To lists all resources for which this policy applies. + // Resources in this list must act like an ingress and have an audience. + // The resources are part of the same namespace as the EventPolicy. + // An empty list means it applies to all resources in the EventPolicies namespace + // +optional + To []EventPolicySpecTo `json:"to,omitempty"` + + // From is the list of sources or oidc identities, which are allowed to send events to the targets (.spec.to). + From []EventPolicySpecFrom `json:"from,omitempty"` +} + +type EventPolicySpecTo struct { + // Ref contains the direct reference to a target + // +optional + Ref *EventPolicyToReference `json:"ref,omitempty"` + + // Selector contains a selector to group targets + // +optional + Selector *EventPolicySelector `json:"selector,omitempty"` +} + +type EventPolicySpecFrom struct { + // Ref contains a direct reference to a resource which is allowed to send events to the target. + // +optional + Ref *EventPolicyFromReference `json:"ref,omitempty"` + + // Sub sets the OIDC identity name to be allowed to send events to the target. + // It is also possible to set a glob-like pattern to match any suffix. + // +optional + Sub *string `json:"sub,omitempty"` +} + +type EventPolicyToReference struct { + // API version of the referent. + APIVersion string `json:"apiVersion,omitempty"` + + // Kind of the referent. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` + + // Name of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name"` +} + +type EventPolicyFromReference struct { + // API version of the referent. + APIVersion string `json:"apiVersion,omitempty"` + + // Kind of the referent. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + Kind string `json:"kind"` + + // Name of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name"` + + // Namespace of the referent. + // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + // This is optional field, it gets defaulted to the object holding it if left out. + // +optional + Namespace string `json:"namespace,omitempty"` +} + +type EventPolicySelector struct { + *metav1.LabelSelector `json:",inline"` + *metav1.TypeMeta `json:",inline"` +} + +// EventPolicyStatus represents the current state of a EventPolicy. +type EventPolicyStatus struct { + // inherits duck/v1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1.Status `json:",inline"` + + // From is the list of resolved oidc identities from .spec.from + From []string `json:"from,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// EventPolicyList is a collection of EventPolicy. +type EventPolicyList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []EventPolicy `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for EventPolicy +func (ep *EventPolicy) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("EventPolicy") +} + +// GetUntypedSpec returns the spec of the EventPolicy. +func (ep *EventPolicy) GetUntypedSpec() interface{} { + return ep.Spec +} + +// GetStatus retrieves the status of the EventPolicy. Implements the KRShaped interface. +func (ep *EventPolicy) GetStatus() *duckv1.Status { + return &ep.Status.Status +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_validation.go new file mode 100644 index 000000000..6c4eafb5c --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventpolicy_validation.go @@ -0,0 +1,86 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" +) + +func (ep *EventPolicy) Validate(ctx context.Context) *apis.FieldError { + return ep.Spec.Validate(ctx).ViaField("spec") +} + +func (ets *EventPolicySpec) Validate(ctx context.Context) *apis.FieldError { + var err *apis.FieldError + for i, f := range ets.From { + if f.Ref == nil && (f.Sub == nil || *f.Sub == "") { + err = err.Also(apis.ErrMissingOneOf("ref", "sub").ViaFieldIndex("from", i)) + } + if f.Ref != nil && f.Sub != nil { + err = err.Also(apis.ErrMultipleOneOf("ref", "sub").ViaFieldIndex("from", i)) + } + err = err.Also(f.Ref.Validate().ViaField("ref").ViaFieldIndex("from", i)) + } + + for i, t := range ets.To { + if t.Ref == nil && t.Selector == nil { + err = err.Also(apis.ErrMissingOneOf("ref", "selector").ViaFieldIndex("to", i)) + } + if t.Ref != nil && t.Selector != nil { + err = err.Also(apis.ErrMultipleOneOf("ref", "selector").ViaFieldIndex("to", i)) + } + if t.Ref != nil { + err = err.Also(t.Ref.Validate().ViaField("ref").ViaFieldIndex("to", i)) + } + } + + return err +} + +func (r *EventPolicyFromReference) Validate() *apis.FieldError { + if r == nil { + return nil + } + + var err *apis.FieldError + if r.Kind == "" { + err = err.Also(apis.ErrMissingField("kind")) + } + if r.APIVersion == "" { + err = err.Also(apis.ErrMissingField("apiVersion")) + } + if r.Name == "" { + err = err.Also(apis.ErrMissingField("name")) + } + return err +} + +func (r *EventPolicyToReference) Validate() *apis.FieldError { + var err *apis.FieldError + if r.Kind == "" { + err = err.Also(apis.ErrMissingField("kind")) + } + if r.APIVersion == "" { + err = err.Also(apis.ErrMissingField("apiVersion")) + } + if r.Name == "" { + err = err.Also(apis.ErrMissingField("name")) + } + return err +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/register.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/register.go new file mode 100644 index 000000000..c6f3e98cd --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/register.go @@ -0,0 +1,53 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + "knative.dev/eventing/pkg/apis/eventing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: eventing.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &EventPolicy{}, + &EventPolicyList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 000000000..998b577ca --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,250 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicy) DeepCopyInto(out *EventPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicy. +func (in *EventPolicy) DeepCopy() *EventPolicy { + if in == nil { + return nil + } + out := new(EventPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EventPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicyFromReference) DeepCopyInto(out *EventPolicyFromReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicyFromReference. +func (in *EventPolicyFromReference) DeepCopy() *EventPolicyFromReference { + if in == nil { + return nil + } + out := new(EventPolicyFromReference) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicyList) DeepCopyInto(out *EventPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]EventPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicyList. +func (in *EventPolicyList) DeepCopy() *EventPolicyList { + if in == nil { + return nil + } + out := new(EventPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EventPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicySelector) DeepCopyInto(out *EventPolicySelector) { + *out = *in + if in.LabelSelector != nil { + in, out := &in.LabelSelector, &out.LabelSelector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + if in.TypeMeta != nil { + in, out := &in.TypeMeta, &out.TypeMeta + *out = new(v1.TypeMeta) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicySelector. +func (in *EventPolicySelector) DeepCopy() *EventPolicySelector { + if in == nil { + return nil + } + out := new(EventPolicySelector) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicySpec) DeepCopyInto(out *EventPolicySpec) { + *out = *in + if in.To != nil { + in, out := &in.To, &out.To + *out = make([]EventPolicySpecTo, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.From != nil { + in, out := &in.From, &out.From + *out = make([]EventPolicySpecFrom, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicySpec. +func (in *EventPolicySpec) DeepCopy() *EventPolicySpec { + if in == nil { + return nil + } + out := new(EventPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicySpecFrom) DeepCopyInto(out *EventPolicySpecFrom) { + *out = *in + if in.Ref != nil { + in, out := &in.Ref, &out.Ref + *out = new(EventPolicyFromReference) + **out = **in + } + if in.Sub != nil { + in, out := &in.Sub, &out.Sub + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicySpecFrom. +func (in *EventPolicySpecFrom) DeepCopy() *EventPolicySpecFrom { + if in == nil { + return nil + } + out := new(EventPolicySpecFrom) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicySpecTo) DeepCopyInto(out *EventPolicySpecTo) { + *out = *in + if in.Ref != nil { + in, out := &in.Ref, &out.Ref + *out = new(EventPolicyToReference) + **out = **in + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(EventPolicySelector) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicySpecTo. +func (in *EventPolicySpecTo) DeepCopy() *EventPolicySpecTo { + if in == nil { + return nil + } + out := new(EventPolicySpecTo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicyStatus) DeepCopyInto(out *EventPolicyStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.From != nil { + in, out := &in.From, &out.From + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicyStatus. +func (in *EventPolicyStatus) DeepCopy() *EventPolicyStatus { + if in == nil { + return nil + } + out := new(EventPolicyStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventPolicyToReference) DeepCopyInto(out *EventPolicyToReference) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventPolicyToReference. +func (in *EventPolicyToReference) DeepCopy() *EventPolicyToReference { + if in == nil { + return nil + } + out := new(EventPolicyToReference) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/eventing/pkg/apis/feature/features.go b/vendor/knative.dev/eventing/pkg/apis/feature/features.go index e01195bb5..982ca8c67 100644 --- a/vendor/knative.dev/eventing/pkg/apis/feature/features.go +++ b/vendor/knative.dev/eventing/pkg/apis/feature/features.go @@ -45,6 +45,24 @@ const ( // - Addressables should advertise both HTTP and HTTPS endpoints // - Producers should prefer to send events to HTTPS endpoints, if available Permissive Flag = "Permissive" + + // AuthorizationAllowAll is a value for AuthorizationDefaultMode that indicates to allow all + // OIDC subjects by default. + // This configuration is applied when there is no EventPolicy with a "to" referencing a given + // resource. + AuthorizationAllowAll Flag = "Allow-All" + + // AuthorizationDenyAll is a value for AuthorizationDefaultMode that indicates to deny all + // OIDC subjects by default. + // This configuration is applied when there is no EventPolicy with a "to" referencing a given + // resource. + AuthorizationDenyAll Flag = "Deny-All" + + // AuthorizationAllowSameNamespace is a value for AuthorizationDefaultMode that indicates to allow + // OIDC subjects with the same namespace as a given resource. + // This configuration is applied when there is no EventPolicy with a "to" referencing a given + // resource. + AuthorizationAllowSameNamespace Flag = "Allow-Same-Namespace" ) // Flags is a map containing all the enabled/disabled flags for the experimental features. @@ -53,15 +71,16 @@ type Flags map[string]Flag func newDefaults() Flags { return map[string]Flag{ - KReferenceGroup: Disabled, - DeliveryRetryAfter: Disabled, - DeliveryTimeout: Enabled, - KReferenceMapping: Disabled, - NewTriggerFilters: Enabled, - TransportEncryption: Disabled, - OIDCAuthentication: Disabled, - EvenTypeAutoCreate: Disabled, - NewAPIServerFilters: Disabled, + KReferenceGroup: Disabled, + DeliveryRetryAfter: Disabled, + DeliveryTimeout: Enabled, + KReferenceMapping: Disabled, + NewTriggerFilters: Enabled, + TransportEncryption: Disabled, + OIDCAuthentication: Disabled, + EvenTypeAutoCreate: Disabled, + NewAPIServerFilters: Disabled, + AuthorizationDefaultMode: AuthorizationAllowSameNamespace, } } @@ -103,6 +122,18 @@ func (e Flags) IsCrossNamespaceEventLinks() bool { return e != nil && e[CrossNamespaceEventLinks] == Enabled } +func (e Flags) IsAuthorizationDefaultModeAllowAll() bool { + return e != nil && e[AuthorizationDefaultMode] == AuthorizationAllowAll +} + +func (e Flags) IsAuthorizationDefaultModeDenyAll() bool { + return e != nil && e[AuthorizationDefaultMode] == AuthorizationDenyAll +} + +func (e Flags) IsAuthorizationDefaultModeSameNamespace() bool { + return e != nil && e[AuthorizationDefaultMode] == AuthorizationAllowSameNamespace +} + func (e Flags) String() string { return fmt.Sprintf("%+v", map[string]Flag(e)) } @@ -142,10 +173,16 @@ func NewFlagsConfigFromMap(data map[string]string) (Flags, error) { flags[sanitizedKey] = Disabled } else if strings.EqualFold(v, string(Enabled)) { flags[sanitizedKey] = Enabled - } else if k == TransportEncryption && strings.EqualFold(v, string(Permissive)) { + } else if sanitizedKey == TransportEncryption && strings.EqualFold(v, string(Permissive)) { flags[sanitizedKey] = Permissive - } else if k == TransportEncryption && strings.EqualFold(v, string(Strict)) { + } else if sanitizedKey == TransportEncryption && strings.EqualFold(v, string(Strict)) { flags[sanitizedKey] = Strict + } else if sanitizedKey == AuthorizationDefaultMode && strings.EqualFold(v, string(AuthorizationAllowAll)) { + flags[sanitizedKey] = AuthorizationAllowAll + } else if sanitizedKey == AuthorizationDefaultMode && strings.EqualFold(v, string(AuthorizationDenyAll)) { + flags[sanitizedKey] = AuthorizationDenyAll + } else if sanitizedKey == AuthorizationDefaultMode && strings.EqualFold(v, string(AuthorizationAllowSameNamespace)) { + flags[sanitizedKey] = AuthorizationAllowSameNamespace } else if strings.Contains(k, NodeSelectorLabel) { flags[sanitizedKey] = Flag(v) } else { diff --git a/vendor/knative.dev/eventing/pkg/apis/feature/flag_names.go b/vendor/knative.dev/eventing/pkg/apis/feature/flag_names.go index cd937554c..99abc2076 100644 --- a/vendor/knative.dev/eventing/pkg/apis/feature/flag_names.go +++ b/vendor/knative.dev/eventing/pkg/apis/feature/flag_names.go @@ -28,4 +28,5 @@ const ( NodeSelectorLabel = "apiserversources-nodeselector-" CrossNamespaceEventLinks = "cross-namespace-event-links" NewAPIServerFilters = "new-apiserversource-filters" + AuthorizationDefaultMode = "default-authorization-mode" ) diff --git a/vendor/knative.dev/eventing/pkg/apis/sinks/register.go b/vendor/knative.dev/eventing/pkg/apis/sinks/register.go index b37303c50..676fa75e8 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sinks/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sinks/register.go @@ -17,7 +17,10 @@ limitations under the License. package sinks import ( + "context" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/kubernetes" ) const ( @@ -31,3 +34,21 @@ var ( Resource: "jobsinks", } ) + +type Config struct { + KubeClient kubernetes.Interface +} + +type configKey struct{} + +func WithConfig(ctx context.Context, cfg *Config) context.Context { + return context.WithValue(ctx, configKey{}, cfg) +} + +func GetConfig(ctx context.Context) *Config { + v := ctx.Value(configKey{}) + if v == nil { + panic("Missing value for config") + } + return v.(*Config) +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sinks/v1alpha1/job_sink_validation.go b/vendor/knative.dev/eventing/pkg/apis/sinks/v1alpha1/job_sink_validation.go index 0fe178dc6..7ed631ba3 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sinks/v1alpha1/job_sink_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/sinks/v1alpha1/job_sink_validation.go @@ -19,10 +19,15 @@ package v1alpha1 import ( "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apiserver/pkg/storage/names" "knative.dev/pkg/apis" + + "knative.dev/eventing/pkg/apis/sinks" ) func (sink *JobSink) Validate(ctx context.Context) *apis.FieldError { + ctx = apis.WithinParent(ctx, sink.ObjectMeta) return sink.Spec.Validate(ctx).ViaField("spec") } @@ -33,5 +38,20 @@ func (sink *JobSinkSpec) Validate(ctx context.Context) *apis.FieldError { return errs.Also(apis.ErrMissingOneOf("job")) } + if sink.Job != nil { + job := sink.Job.DeepCopy() + job.Name = names.SimpleNameGenerator.GenerateName(apis.ParentMeta(ctx).Name) + _, err := sinks.GetConfig(ctx).KubeClient. + BatchV1(). + Jobs(apis.ParentMeta(ctx).Namespace). + Create(ctx, job, metav1.CreateOptions{ + DryRun: []string{metav1.DryRunAll}, + FieldValidation: metav1.FieldValidationStrict, + }) + if err != nil { + return apis.ErrGeneric(err.Error(), "job") + } + } + return errs } diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/clientset.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/clientset.go index 169fc4b74..0ca8d7350 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/clientset.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/clientset.go @@ -26,6 +26,7 @@ import ( rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" eventingv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1" + eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" eventingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1" eventingv1beta2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta2" eventingv1beta3 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta3" @@ -38,6 +39,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface + EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface EventingV1beta1() eventingv1beta1.EventingV1beta1Interface EventingV1beta2() eventingv1beta2.EventingV1beta2Interface EventingV1beta3() eventingv1beta3.EventingV1beta3Interface @@ -52,15 +54,21 @@ type Interface interface { // Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient - eventingV1beta1 *eventingv1beta1.EventingV1beta1Client - eventingV1beta2 *eventingv1beta2.EventingV1beta2Client - eventingV1beta3 *eventingv1beta3.EventingV1beta3Client - eventingV1 *eventingv1.EventingV1Client - flowsV1 *flowsv1.FlowsV1Client - messagingV1 *messagingv1.MessagingV1Client - sinksV1alpha1 *sinksv1alpha1.SinksV1alpha1Client - sourcesV1beta2 *sourcesv1beta2.SourcesV1beta2Client - sourcesV1 *sourcesv1.SourcesV1Client + eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client + eventingV1beta1 *eventingv1beta1.EventingV1beta1Client + eventingV1beta2 *eventingv1beta2.EventingV1beta2Client + eventingV1beta3 *eventingv1beta3.EventingV1beta3Client + eventingV1 *eventingv1.EventingV1Client + flowsV1 *flowsv1.FlowsV1Client + messagingV1 *messagingv1.MessagingV1Client + sinksV1alpha1 *sinksv1alpha1.SinksV1alpha1Client + sourcesV1beta2 *sourcesv1beta2.SourcesV1beta2Client + sourcesV1 *sourcesv1.SourcesV1Client +} + +// EventingV1alpha1 retrieves the EventingV1alpha1Client +func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface { + return c.eventingV1alpha1 } // EventingV1beta1 retrieves the EventingV1beta1Client @@ -152,6 +160,10 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, var cs Clientset var err error + cs.eventingV1alpha1, err = eventingv1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } cs.eventingV1beta1, err = eventingv1beta1.NewForConfigAndClient(&configShallowCopy, httpClient) if err != nil { return nil, err @@ -209,6 +221,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { // New creates a new Clientset for the given RESTClient. func New(c rest.Interface) *Clientset { var cs Clientset + cs.eventingV1alpha1 = eventingv1alpha1.New(c) cs.eventingV1beta1 = eventingv1beta1.New(c) cs.eventingV1beta2 = eventingv1beta2.New(c) cs.eventingV1beta3 = eventingv1beta3.New(c) diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/clientset_generated.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/clientset_generated.go index 8c17bc626..ce9c36494 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -27,6 +27,8 @@ import ( clientset "knative.dev/eventing/pkg/client/clientset/versioned" eventingv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1" fakeeventingv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1/fake" + eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" + fakeeventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake" eventingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1" fakeeventingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake" eventingv1beta2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta2" @@ -95,6 +97,11 @@ var ( _ testing.FakeClient = &Clientset{} ) +// EventingV1alpha1 retrieves the EventingV1alpha1Client +func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface { + return &fakeeventingv1alpha1.FakeEventingV1alpha1{Fake: &c.Fake} +} + // EventingV1beta1 retrieves the EventingV1beta1Client func (c *Clientset) EventingV1beta1() eventingv1beta1.EventingV1beta1Interface { return &fakeeventingv1beta1.FakeEventingV1beta1{Fake: &c.Fake} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/register.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/register.go index fdd99cc38..69946bd6e 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/register.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/fake/register.go @@ -25,6 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" + eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" eventingv1beta2 "knative.dev/eventing/pkg/apis/eventing/v1beta2" eventingv1beta3 "knative.dev/eventing/pkg/apis/eventing/v1beta3" @@ -39,6 +40,7 @@ var scheme = runtime.NewScheme() var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + eventingv1alpha1.AddToScheme, eventingv1beta1.AddToScheme, eventingv1beta2.AddToScheme, eventingv1beta3.AddToScheme, diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go index 447af7253..e037c6c17 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go @@ -25,6 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" + eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" eventingv1beta2 "knative.dev/eventing/pkg/apis/eventing/v1beta2" eventingv1beta3 "knative.dev/eventing/pkg/apis/eventing/v1beta3" @@ -39,6 +40,7 @@ var Scheme = runtime.NewScheme() var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ + eventingv1alpha1.AddToScheme, eventingv1beta1.AddToScheme, eventingv1beta2.AddToScheme, eventingv1beta3.AddToScheme, diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go new file mode 100644 index 000000000..0b13fd8e0 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go new file mode 100644 index 000000000..e901caf43 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go @@ -0,0 +1,107 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "net/http" + + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +type EventingV1alpha1Interface interface { + RESTClient() rest.Interface + EventPoliciesGetter +} + +// EventingV1alpha1Client is used to interact with features provided by the eventing.knative.dev group. +type EventingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *EventingV1alpha1Client) EventPolicies(namespace string) EventPolicyInterface { + return newEventPolicies(c, namespace) +} + +// NewForConfig creates a new EventingV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*EventingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new EventingV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*EventingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &EventingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new EventingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *EventingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new EventingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *EventingV1alpha1Client { + return &EventingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *EventingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventpolicy.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventpolicy.go new file mode 100644 index 000000000..bb510ab6e --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventpolicy.go @@ -0,0 +1,195 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// EventPoliciesGetter has a method to return a EventPolicyInterface. +// A group's client should implement this interface. +type EventPoliciesGetter interface { + EventPolicies(namespace string) EventPolicyInterface +} + +// EventPolicyInterface has methods to work with EventPolicy resources. +type EventPolicyInterface interface { + Create(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.CreateOptions) (*v1alpha1.EventPolicy, error) + Update(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (*v1alpha1.EventPolicy, error) + UpdateStatus(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (*v1alpha1.EventPolicy, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.EventPolicy, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.EventPolicyList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.EventPolicy, err error) + EventPolicyExpansion +} + +// eventPolicies implements EventPolicyInterface +type eventPolicies struct { + client rest.Interface + ns string +} + +// newEventPolicies returns a EventPolicies +func newEventPolicies(c *EventingV1alpha1Client, namespace string) *eventPolicies { + return &eventPolicies{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the eventPolicy, and returns the corresponding eventPolicy object, and an error if there is any. +func (c *eventPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.EventPolicy, err error) { + result = &v1alpha1.EventPolicy{} + err = c.client.Get(). + Namespace(c.ns). + Resource("eventpolicies"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of EventPolicies that match those selectors. +func (c *eventPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.EventPolicyList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.EventPolicyList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("eventpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested eventPolicies. +func (c *eventPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("eventpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a eventPolicy and creates it. Returns the server's representation of the eventPolicy, and an error, if there is any. +func (c *eventPolicies) Create(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.CreateOptions) (result *v1alpha1.EventPolicy, err error) { + result = &v1alpha1.EventPolicy{} + err = c.client.Post(). + Namespace(c.ns). + Resource("eventpolicies"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(eventPolicy). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a eventPolicy and updates it. Returns the server's representation of the eventPolicy, and an error, if there is any. +func (c *eventPolicies) Update(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (result *v1alpha1.EventPolicy, err error) { + result = &v1alpha1.EventPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("eventpolicies"). + Name(eventPolicy.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(eventPolicy). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *eventPolicies) UpdateStatus(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (result *v1alpha1.EventPolicy, err error) { + result = &v1alpha1.EventPolicy{} + err = c.client.Put(). + Namespace(c.ns). + Resource("eventpolicies"). + Name(eventPolicy.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(eventPolicy). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the eventPolicy and deletes it. Returns an error if one occurs. +func (c *eventPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("eventpolicies"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *eventPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("eventpolicies"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched eventPolicy. +func (c *eventPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.EventPolicy, err error) { + result = &v1alpha1.EventPolicy{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("eventpolicies"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go new file mode 100644 index 000000000..40528db3a --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go new file mode 100644 index 000000000..958cd8661 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" +) + +type FakeEventingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeEventingV1alpha1) EventPolicies(namespace string) v1alpha1.EventPolicyInterface { + return &FakeEventPolicies{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeEventingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventpolicy.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventpolicy.go new file mode 100644 index 000000000..a31bc8200 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventpolicy.go @@ -0,0 +1,141 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +// FakeEventPolicies implements EventPolicyInterface +type FakeEventPolicies struct { + Fake *FakeEventingV1alpha1 + ns string +} + +var eventpoliciesResource = v1alpha1.SchemeGroupVersion.WithResource("eventpolicies") + +var eventpoliciesKind = v1alpha1.SchemeGroupVersion.WithKind("EventPolicy") + +// Get takes name of the eventPolicy, and returns the corresponding eventPolicy object, and an error if there is any. +func (c *FakeEventPolicies) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.EventPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(eventpoliciesResource, c.ns, name), &v1alpha1.EventPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventPolicy), err +} + +// List takes label and field selectors, and returns the list of EventPolicies that match those selectors. +func (c *FakeEventPolicies) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.EventPolicyList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(eventpoliciesResource, eventpoliciesKind, c.ns, opts), &v1alpha1.EventPolicyList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.EventPolicyList{ListMeta: obj.(*v1alpha1.EventPolicyList).ListMeta} + for _, item := range obj.(*v1alpha1.EventPolicyList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested eventPolicies. +func (c *FakeEventPolicies) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(eventpoliciesResource, c.ns, opts)) + +} + +// Create takes the representation of a eventPolicy and creates it. Returns the server's representation of the eventPolicy, and an error, if there is any. +func (c *FakeEventPolicies) Create(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.CreateOptions) (result *v1alpha1.EventPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(eventpoliciesResource, c.ns, eventPolicy), &v1alpha1.EventPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventPolicy), err +} + +// Update takes the representation of a eventPolicy and updates it. Returns the server's representation of the eventPolicy, and an error, if there is any. +func (c *FakeEventPolicies) Update(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (result *v1alpha1.EventPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(eventpoliciesResource, c.ns, eventPolicy), &v1alpha1.EventPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventPolicy), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeEventPolicies) UpdateStatus(ctx context.Context, eventPolicy *v1alpha1.EventPolicy, opts v1.UpdateOptions) (*v1alpha1.EventPolicy, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(eventpoliciesResource, "status", c.ns, eventPolicy), &v1alpha1.EventPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventPolicy), err +} + +// Delete takes name of the eventPolicy and deletes it. Returns an error if one occurs. +func (c *FakeEventPolicies) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(eventpoliciesResource, c.ns, name, opts), &v1alpha1.EventPolicy{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeEventPolicies) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(eventpoliciesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.EventPolicyList{}) + return err +} + +// Patch applies the patch and returns the patched eventPolicy. +func (c *FakeEventPolicies) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.EventPolicy, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(eventpoliciesResource, c.ns, name, pt, data, subresources...), &v1alpha1.EventPolicy{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventPolicy), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go new file mode 100644 index 000000000..d5bd1a045 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2021 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type EventPolicyExpansion interface{} diff --git a/vendor/modules.txt b/vendor/modules.txt index 27a885186..0c8eb6cd1 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -561,6 +561,7 @@ k8s.io/apimachinery/pkg/util/managedfields/internal k8s.io/apimachinery/pkg/util/mergepatch k8s.io/apimachinery/pkg/util/naming k8s.io/apimachinery/pkg/util/net +k8s.io/apimachinery/pkg/util/rand k8s.io/apimachinery/pkg/util/runtime k8s.io/apimachinery/pkg/util/sets k8s.io/apimachinery/pkg/util/strategicpatch @@ -573,6 +574,9 @@ k8s.io/apimachinery/pkg/version k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/reflect +# k8s.io/apiserver v0.29.2 +## explicit; go 1.21 +k8s.io/apiserver/pkg/storage/names # k8s.io/client-go v0.29.2 ## explicit; go 1.21 k8s.io/client-go/applyconfigurations/admissionregistration/v1 @@ -966,7 +970,7 @@ k8s.io/utils/pointer k8s.io/utils/ptr k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/eventing v0.41.1-0.20240611091249-c60bcd048fd3 +# knative.dev/eventing v0.41.1-0.20240612160448-8da4543f0d1e ## explicit; go 1.21 knative.dev/eventing/pkg/adapter/v2 knative.dev/eventing/pkg/adapter/v2/test @@ -977,6 +981,7 @@ knative.dev/eventing/pkg/apis/duck knative.dev/eventing/pkg/apis/duck/v1 knative.dev/eventing/pkg/apis/eventing knative.dev/eventing/pkg/apis/eventing/v1 +knative.dev/eventing/pkg/apis/eventing/v1alpha1 knative.dev/eventing/pkg/apis/eventing/v1beta1 knative.dev/eventing/pkg/apis/eventing/v1beta2 knative.dev/eventing/pkg/apis/eventing/v1beta3 @@ -998,6 +1003,8 @@ knative.dev/eventing/pkg/client/clientset/versioned/fake knative.dev/eventing/pkg/client/clientset/versioned/scheme knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1 knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1/fake +knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1 +knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1 knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta2 @@ -1094,7 +1101,7 @@ knative.dev/pkg/webhook/psbinding knative.dev/pkg/webhook/resourcesemantics knative.dev/pkg/webhook/resourcesemantics/defaulting knative.dev/pkg/webhook/resourcesemantics/validation -# knative.dev/serving v0.41.1-0.20240611132024-227975c8e431 +# knative.dev/serving v0.41.1-0.20240611143228-2e5d17e9fc8b ## explicit; go 1.21 knative.dev/serving/pkg/apis/autoscaling knative.dev/serving/pkg/apis/autoscaling/v1alpha1