|
| 1 | +/* |
| 2 | +Copyright 2025 Agentic Layer. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | +) |
| 22 | + |
| 23 | +// GuardrailProviderSpec defines the desired state of GuardrailProvider. |
| 24 | +type GuardrailProviderSpec struct { |
| 25 | + // Protocol defines the guardrail protocol used by this provider. |
| 26 | + // +kubebuilder:validation:Enum=openai-moderation;bedrock |
| 27 | + Protocol string `json:"protocol"` |
| 28 | + |
| 29 | + // TransportType defines the transport used to communicate with the guardrail backend. |
| 30 | + // Required when BackendRef is specified. |
| 31 | + // +kubebuilder:validation:Enum=http;grpc;envoy-ext-proc |
| 32 | + // +optional |
| 33 | + TransportType string `json:"transportType,omitempty"` |
| 34 | + |
| 35 | + // BackendRef references the Kubernetes Service acting as the guardrail backend. |
| 36 | + // When omitted, the provider uses the protocol's default managed endpoint |
| 37 | + // (e.g., the official OpenAI moderation API or AWS Bedrock). |
| 38 | + // +optional |
| 39 | + BackendRef *GuardrailBackendRef `json:"backendRef,omitempty"` |
| 40 | +} |
| 41 | + |
| 42 | +// GuardrailBackendRef references a Kubernetes Service acting as the guardrail backend. |
| 43 | +type GuardrailBackendRef struct { |
| 44 | + // Name is the name of the Kubernetes Service. |
| 45 | + // +kubebuilder:validation:MinLength=1 |
| 46 | + Name string `json:"name"` |
| 47 | + |
| 48 | + // Namespace is the namespace of the Kubernetes Service. |
| 49 | + // If not specified, defaults to the same namespace as the GuardrailProvider. |
| 50 | + // +optional |
| 51 | + Namespace string `json:"namespace,omitempty"` |
| 52 | + |
| 53 | + // Port is the port number of the Kubernetes Service. |
| 54 | + // +kubebuilder:validation:Minimum=1 |
| 55 | + // +kubebuilder:validation:Maximum=65535 |
| 56 | + Port int32 `json:"port"` |
| 57 | +} |
| 58 | + |
| 59 | +// GuardrailProviderStatus defines the observed state of GuardrailProvider. |
| 60 | +type GuardrailProviderStatus struct { |
| 61 | + // +operator-sdk:csv:customresourcedefinitions:type=status |
| 62 | + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` |
| 63 | +} |
| 64 | + |
| 65 | +// +kubebuilder:object:root=true |
| 66 | +// +kubebuilder:subresource:status |
| 67 | + |
| 68 | +// GuardrailProvider is the Schema for the guardrailproviders API. |
| 69 | +type GuardrailProvider struct { |
| 70 | + metav1.TypeMeta `json:",inline"` |
| 71 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 72 | + |
| 73 | + Spec GuardrailProviderSpec `json:"spec,omitempty"` |
| 74 | + Status GuardrailProviderStatus `json:"status,omitempty"` |
| 75 | +} |
| 76 | + |
| 77 | +// +kubebuilder:object:root=true |
| 78 | + |
| 79 | +// GuardrailProviderList contains a list of GuardrailProvider. |
| 80 | +type GuardrailProviderList struct { |
| 81 | + metav1.TypeMeta `json:",inline"` |
| 82 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 83 | + Items []GuardrailProvider `json:"items"` |
| 84 | +} |
| 85 | + |
| 86 | +func init() { |
| 87 | + SchemeBuilder.Register(&GuardrailProvider{}, &GuardrailProviderList{}) |
| 88 | +} |
0 commit comments