-
Notifications
You must be signed in to change notification settings - Fork 397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
api: lua support in EnvoyExtensionPolicy #4932
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright Envoy Gateway Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// The full text of the Apache license is available in the LICENSE file at | ||
// the root of the repo. | ||
|
||
package v1alpha1 | ||
|
||
import gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" | ||
|
||
// LuaValueType defines the types of values for Lua supported by Envoy Gateway. | ||
// +kubebuilder:validation:Enum=Inline;ValueRef | ||
type LuaValueType string | ||
|
||
const ( | ||
// LuaValueTypeInline defines the "Inline" Lua type. | ||
LuaValueTypeInline LuaValueType = "Inline" | ||
|
||
// LuaValueTypeValueRef defines the "ValueRef" Lua type. | ||
LuaValueTypeValueRef LuaValueType = "ValueRef" | ||
) | ||
|
||
// Lua defines a Lua extension | ||
// Only one of Inline or ValueRef must be set | ||
// | ||
// +kubebuilder:validation:XValidation:rule="(self.type == 'Inline' && has(self.inline) && !has(self.valueRef)) || (self.type == 'ValueRef' && !has(self.inline) && has(self.valueRef))",message="Exactly one of inline or valueRef must be set with correct type." | ||
type Lua struct { | ||
// Type is the type of method to use to read the Lua value. | ||
// Valid values are Inline and ValueRef, default is Inline. | ||
// | ||
// +kubebuilder:default=Inline | ||
// +unionDiscriminator | ||
// +required | ||
Type LuaValueType `json:"type"` | ||
// Inline contains the source code as an inline string. | ||
// | ||
// +optional | ||
// +unionMember | ||
Inline *string `json:"inline,omitempty"` | ||
// ValueRef has the source code specified as a local object reference. | ||
// Only a reference to ConfigMap is supported. | ||
zirain marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// The value of key `lua` in the ConfigMap will be used. | ||
// If the key is not found, the first value in the ConfigMap will be used. | ||
// | ||
// +kubebuilder:validation:XValidation:rule="self.kind == 'ConfigMap' && (!has(self.group) || self.group == '')",message="Only a reference to an object of kind ConfigMap belonging to default core API group is supported." | ||
// +optional | ||
// +unionMember | ||
ValueRef *gwapiv1.LocalObjectReference `json:"valueRef,omitempty"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also needs a
Type
enum here e.g.gateway/api/v1alpha1/shared_types.go
Line 723 in 10a31f1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arkodg I was kind of making it work by allowing only one of both value types, but added a type as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we've followed https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/1027-api-unions/README.md to implement unions in most places of the API to getter better schema for validation