From dba4b9fed5e6af3121c8c358121fe31e890b9387 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Wed, 15 Jan 2025 17:43:06 -0800 Subject: [PATCH] less conflict with #100 Signed-off-by: Takeshi Yoneda --- api/v1alpha1/api.go | 8 ++++---- api/v1alpha1/zz_generated.deepcopy.go | 8 ++++---- internal/controller/sink_test.go | 6 +++--- tests/controller/controller_test.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/v1alpha1/api.go b/api/v1alpha1/api.go index 9e05b36df..c30891c34 100644 --- a/api/v1alpha1/api.go +++ b/api/v1alpha1/api.go @@ -53,7 +53,7 @@ type AIGatewayRouteSpec struct { // // +kubebuilder:validation:Required // +kubebuilder:validation:XValidation:rule="self.schema == 'OpenAI'" - APISchema VersionedAPISchema `json:"inputSchema"` + APISchema LLMAPISchema `json:"inputSchema"` // Rules is the list of AIGatewayRouteRule that this AIGatewayRoute will match the traffic to. // Each rule is a subset of the HTTPRoute in the Gateway API (https://gateway-api.sigs.k8s.io/api-types/httproute/). // @@ -215,7 +215,7 @@ type AIServiceBackendSpec struct { // This is required to be set. // // +kubebuilder:validation:Required - APISchema VersionedAPISchema `json:"outputSchema"` + APISchema LLMAPISchema `json:"outputSchema"` // BackendRef is the reference to the Backend resource that this AIServiceBackend corresponds to. // // A backend can be of either k8s Service or Backend resource of Envoy Gateway. @@ -232,14 +232,14 @@ type AIServiceBackendSpec struct { BackendSecurityPolicyRef *gwapiv1.LocalObjectReference `json:"backendSecurityPolicyRef,omitempty"` } -// VersionedAPISchema defines the API schema of either AIGatewayRoute (the input) or AIServiceBackend (the output). +// LLMAPISchema defines the API schema of either AIGatewayRoute (the input) or AIServiceBackend (the output). // // This allows the ai-gateway to understand the input and perform the necessary transformation // depending on the API schema pair (input, output). // // Note that this is vendor specific, and the stability of the API schema is not guaranteed by // the ai-gateway, but by the vendor via proper versioning. -type VersionedAPISchema struct { +type LLMAPISchema struct { // Schema is the API schema of the AIGatewayRoute or AIServiceBackend. // // +kubebuilder:validation:Enum=OpenAI;AWSBedrock diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 2f01dbef3..2f4573515 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -458,16 +458,16 @@ func (in *BackendSecurityPolicySpec) DeepCopy() *BackendSecurityPolicySpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VersionedAPISchema) DeepCopyInto(out *VersionedAPISchema) { +func (in *LLMAPISchema) DeepCopyInto(out *LLMAPISchema) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionedAPISchema. -func (in *VersionedAPISchema) DeepCopy() *VersionedAPISchema { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LLMAPISchema. +func (in *LLMAPISchema) DeepCopy() *LLMAPISchema { if in == nil { return nil } - out := new(VersionedAPISchema) + out := new(LLMAPISchema) in.DeepCopyInto(out) return out } diff --git a/internal/controller/sink_test.go b/internal/controller/sink_test.go index 95e52bf04..6732f34ae 100644 --- a/internal/controller/sink_test.go +++ b/internal/controller/sink_test.go @@ -61,7 +61,7 @@ func TestConfigSink_syncLLMRoute(t *testing.T) { BackendRefs: []aigv1a1.AIGatewayRouteRuleBackendRef{{Name: "apple", Weight: 1}, {Name: "orange", Weight: 1}}, }, }, - APISchema: aigv1a1.VersionedAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v123"}, + APISchema: aigv1a1.LLMAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v123"}, }, } err := fakeClient.Create(context.Background(), route, &client.CreateOptions{}) @@ -215,7 +215,7 @@ func Test_updateExtProcConfigMap(t *testing.T) { { ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns"}, Spec: aigv1a1.AIServiceBackendSpec{ - APISchema: aigv1a1.VersionedAPISchema{ + APISchema: aigv1a1.LLMAPISchema{ Schema: aigv1a1.APISchemaAWSBedrock, }, BackendRef: egv1a1.BackendRef{ @@ -255,7 +255,7 @@ func Test_updateExtProcConfigMap(t *testing.T) { route: &aigv1a1.AIGatewayRoute{ ObjectMeta: metav1.ObjectMeta{Name: "myroute", Namespace: "ns"}, Spec: aigv1a1.AIGatewayRouteSpec{ - APISchema: aigv1a1.VersionedAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v123"}, + APISchema: aigv1a1.LLMAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v123"}, Rules: []aigv1a1.AIGatewayRouteRule{ { BackendRefs: []aigv1a1.AIGatewayRouteRuleBackendRef{ diff --git a/tests/controller/controller_test.go b/tests/controller/controller_test.go index 8e9fee4e9..aea8e82f5 100644 --- a/tests/controller/controller_test.go +++ b/tests/controller/controller_test.go @@ -32,7 +32,7 @@ import ( "github.com/envoyproxy/ai-gateway/tests" ) -var defaultSchema = aigv1a1.VersionedAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v1"} +var defaultSchema = aigv1a1.LLMAPISchema{Schema: aigv1a1.APISchemaOpenAI, Version: "v1"} func extProcName(aiGatewayRouteName string) string { return fmt.Sprintf("ai-gateway-ai-gateway-route-extproc-%s", aiGatewayRouteName)