-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Address review comments on Guard/GuardrailProvider CRDs #80
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7e75905
Initial plan
Copilot e4ffdb1
feat: introduce Guard and GuardrailProvider CRDs with AiGateway integ…
Copilot a4730cf
feat: address PR review comments - use standard object references, ad…
Copilot 5d379a0
fix: add Guard and GuardrailProvider CRDs to kustomization to fix e2e…
Copilot 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 hidden or 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 hidden or 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 hidden or 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,77 @@ | ||
| /* | ||
| Copyright 2025 Agentic Layer. | ||
|
|
||
| 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 ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // GuardSpec defines the desired state of Guard. | ||
| type GuardSpec struct { | ||
| // Name is the identifier of the guard as known by the referenced GuardrailProvider. | ||
| // +kubebuilder:validation:MinLength=1 | ||
| Name string `json:"name"` | ||
|
|
||
| // Version is the version of the guard at the provider (if supported). | ||
| // +optional | ||
| Version string `json:"version,omitempty"` | ||
|
|
||
| // Mode defines when the guard is applied relative to the LLM call. | ||
| // +kubebuilder:validation:Enum=pre_call;post_call;during_call | ||
| Mode string `json:"mode"` | ||
|
|
||
| // Description provides a human-readable description of the guard's purpose. | ||
| // This field is for documentation purposes only and has no effect on the guard's behavior. | ||
| // +optional | ||
| Description string `json:"description,omitempty"` | ||
|
|
||
| // ProviderRef references the GuardrailProvider that hosts this guard. | ||
| // If Namespace is not specified, defaults to the same namespace as the Guard. | ||
| ProviderRef corev1.ObjectReference `json:"providerRef"` | ||
| } | ||
|
|
||
| // GuardStatus defines the observed state of Guard. | ||
| type GuardStatus struct { | ||
| // +operator-sdk:csv:customresourcedefinitions:type=status | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // Guard is the Schema for the guards API. | ||
| type Guard struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec GuardSpec `json:"spec,omitempty"` | ||
| Status GuardStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // GuardList contains a list of Guard. | ||
| type GuardList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []Guard `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&Guard{}, &GuardList{}) | ||
| } |
This file contains hidden or 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,95 @@ | ||
| /* | ||
| Copyright 2025 Agentic Layer. | ||
|
|
||
| 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 ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // GuardrailProviderSpec defines the desired state of GuardrailProvider. | ||
| type GuardrailProviderSpec struct { | ||
| // Protocol defines the guardrail protocol used by this provider. | ||
| // +kubebuilder:validation:Enum=openai-moderation;bedrock | ||
| Protocol string `json:"protocol"` | ||
|
|
||
| // ApiKeySecretRef references a Kubernetes Secret containing the API key for the guardrail provider. | ||
| // The secret must contain the key specified in the SecretKeySelector. | ||
| // +optional | ||
| ApiKeySecretRef *corev1.SecretKeySelector `json:"apiKeySecretRef,omitempty"` | ||
|
|
||
| // TransportType defines the transport used to communicate with the guardrail backend. | ||
| // Required when BackendRef is specified. | ||
| // +kubebuilder:validation:Enum=http;grpc;envoy-ext-proc | ||
| // +optional | ||
| TransportType string `json:"transportType,omitempty"` | ||
|
|
||
| // BackendRef references the Kubernetes Service acting as the guardrail backend. | ||
| // When omitted, the provider uses the protocol's default managed endpoint | ||
| // (e.g., the official OpenAI moderation API or AWS Bedrock). | ||
| // Mutually exclusive with ExternalUrl. | ||
| // +optional | ||
| BackendRef *GuardrailBackendRef `json:"backendRef,omitempty"` | ||
g3force marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // ExternalUrl specifies an external URL for the guardrail backend. | ||
| // Use this to point to an external guardrail service outside the cluster. | ||
| // Mutually exclusive with BackendRef. | ||
| // +optional | ||
| // +kubebuilder:validation:Format=uri | ||
| ExternalUrl string `json:"externalUrl,omitempty"` | ||
| } | ||
|
|
||
| // GuardrailBackendRef references a Kubernetes Service acting as the guardrail backend. | ||
| type GuardrailBackendRef struct { | ||
g3force marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| corev1.ObjectReference `json:",inline"` | ||
|
|
||
| // Port is the port number of the Kubernetes Service. | ||
| // +kubebuilder:validation:Minimum=1 | ||
| // +kubebuilder:validation:Maximum=65535 | ||
| Port int32 `json:"port"` | ||
| } | ||
|
|
||
| // GuardrailProviderStatus defines the observed state of GuardrailProvider. | ||
| type GuardrailProviderStatus struct { | ||
| // +operator-sdk:csv:customresourcedefinitions:type=status | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
|
|
||
| // GuardrailProvider is the Schema for the guardrailproviders API. | ||
| type GuardrailProvider struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
|
||
| Spec GuardrailProviderSpec `json:"spec,omitempty"` | ||
| Status GuardrailProviderStatus `json:"status,omitempty"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
|
|
||
| // GuardrailProviderList contains a list of GuardrailProvider. | ||
| type GuardrailProviderList struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| metav1.ListMeta `json:"metadata,omitempty"` | ||
| Items []GuardrailProvider `json:"items"` | ||
| } | ||
|
|
||
| func init() { | ||
| SchemeBuilder.Register(&GuardrailProvider{}, &GuardrailProviderList{}) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.