Skip to content

Commit 090bfbc

Browse files
author
Erich Shan
committed
add fields to openAPIV3Schema
1 parent f63b75a commit 090bfbc

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
##################################################
44
SHELL = /bin/bash
55

6-
IMAGE_REGISTRY ?= ghcr.io
6+
IMAGE_REGISTRY ?= navigation-docker.artifactory.teslamotors.com
77
IMAGE_REPO ?= kedacore
8-
VERSION ?= main
8+
VERSION ?= header-based-routing
99

1010
IMAGE_OPERATOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-operator
1111
IMAGE_INTERCEPTOR ?= ${IMAGE_REGISTRY}/${IMAGE_REPO}/http-add-on-interceptor

config/crd/bases/http.keda.sh_httpscaledobjects.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ spec:
7878
items:
7979
type: string
8080
type: array
81+
headers:
82+
description: |-
83+
The custom headers used to route. Once Hosts and PathPrefixes have been matched,
84+
if at least one header in the http request matches at least one header
85+
in .spec.headers, it will be routed to the Service and Port specified in
86+
the scaleTargetRef. First header it matches with, it will be routed to.
87+
If the headers can't be matched, then use first one without .spec.headers supplied
88+
If that doesn't exist then routing will fail.
89+
items:
90+
type: object
91+
properties:
92+
name:
93+
type: string
94+
value:
95+
type: string
96+
required:
97+
- name
98+
- value
99+
type: array
100+
uniqueItems: true
81101
replicas:
82102
description: (optional) Replica information
83103
properties:

operator/apis/http/v1alpha1/httpscaledobject_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ type RateMetricSpec struct {
7676
Granularity metav1.Duration `json:"granularity" description:"Time granularity for rate calculation"`
7777
}
7878

79+
type Header struct {
80+
Name string `json:"name"`
81+
Value string `json:"value"`
82+
}
83+
7984
// HTTPScaledObjectSpec defines the desired state of HTTPScaledObject
8085
type HTTPScaledObjectSpec struct {
8186
// The hosts to route. All requests which the "Host" header
@@ -96,7 +101,7 @@ type HTTPScaledObjectSpec struct {
96101
// If the headers can't be matched, then use first one without .spec.headers supplied
97102
// If that doesn't exist then routing will fail.
98103
// +optional
99-
Headers map[string]string `json:"headers,omitempty"`
104+
Headers []Header `json:"headers,omitempty"`
100105
// The name of the deployment to route HTTP requests to (and to autoscale).
101106
// Including validation as a requirement to define either the PortName or the Port
102107
// +kubebuilder:validation:XValidation:rule="has(self.portName) != has(self.port)",message="must define either the 'portName' or the 'port'"

pkg/routing/tablememory.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ func (tm tableMemory) RouteWithHeaders(key Key, httpHeaders map[string][]string)
106106
// route to first httpso which has a matching header
107107
for _, httpso := range httpsoList.Items {
108108
if httpso.Spec.Headers != nil {
109-
for k, v1 := range httpso.Spec.Headers {
110-
if headerValues, exists := httpHeaders[k]; exists {
111-
for _, v2 := range headerValues {
112-
if v1 == v2 {
109+
for _, header := range httpso.Spec.Headers {
110+
if headerValues, exists := httpHeaders[header.Name]; exists {
111+
for _, v := range headerValues {
112+
if header.Value == v {
113113
return httpso
114114
}
115115
}

0 commit comments

Comments
 (0)