Skip to content

Commit 4839284

Browse files
committed
style: run precommit
Signed-off-by: John Panos <[email protected]>
1 parent c51fedf commit 4839284

16 files changed

+205
-157
lines changed

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/response-cache/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ metadata:
5454
spec:
5555
responseCache:
5656
enabled: true
57-
ttl: 1h # Cache TTL (default: 1h)
58-
respectCacheControl: true # Honor HTTP Cache-Control headers (default: true)
57+
ttl: 1h # Cache TTL (default: 1h)
58+
respectCacheControl: true # Honor HTTP Cache-Control headers (default: true)
5959
# ... rest of config
6060
```
6161

@@ -78,18 +78,18 @@ When `respectCacheControl: true` (default), the gateway honors standard HTTP Cac
7878

7979
### Request Headers (Client Control)
8080

81-
| Header | Behavior |
82-
|--------|----------|
81+
| Header | Behavior |
82+
| ------------------------- | ------------------------------------------------- |
8383
| `Cache-Control: no-cache` | Bypass cache lookup, but still cache the response |
84-
| `Cache-Control: no-store` | Bypass cache entirely (no lookup, no store) |
84+
| `Cache-Control: no-store` | Bypass cache entirely (no lookup, no store) |
8585

8686
### Response Headers (Backend Control)
8787

88-
| Header | Behavior |
89-
|--------|----------|
90-
| `Cache-Control: no-store` | Do not cache this response |
91-
| `Cache-Control: no-cache` | Do not cache this response |
92-
| `Cache-Control: private` | Do not cache (shared cache should not store) |
88+
| Header | Behavior |
89+
| -------------------------- | -------------------------------------------------- |
90+
| `Cache-Control: no-store` | Do not cache this response |
91+
| `Cache-Control: no-cache` | Do not cache this response |
92+
| `Cache-Control: private` | Do not cache (shared cache should not store) |
9393
| `Cache-Control: max-age=N` | Use N seconds as TTL instead of configured default |
9494

9595
### Examples

examples/response-cache/redis.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ metadata:
2424
app: redis
2525
spec:
2626
ports:
27-
- name: redis
28-
port: 6379
27+
- name: redis
28+
port: 6379
2929
selector:
3030
app: redis
3131
---
@@ -45,17 +45,17 @@ spec:
4545
app: redis
4646
spec:
4747
containers:
48-
- image: redis:alpine
49-
imagePullPolicy: IfNotPresent
50-
name: redis
51-
ports:
52-
- name: redis
53-
containerPort: 6379
54-
resources:
55-
requests:
56-
memory: "64Mi"
57-
cpu: "50m"
58-
limits:
59-
memory: "256Mi"
60-
cpu: "200m"
48+
- image: redis:alpine
49+
imagePullPolicy: IfNotPresent
50+
name: redis
51+
ports:
52+
- name: redis
53+
containerPort: 6379
54+
resources:
55+
requests:
56+
memory: "64Mi"
57+
cpu: "50m"
58+
limits:
59+
memory: "256Mi"
60+
cpu: "200m"
6161
restartPolicy: Always

examples/response-cache/response-cache.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ metadata:
2323
spec:
2424
gatewayClassName: eg
2525
listeners:
26-
- name: http
27-
protocol: HTTP
28-
port: 8080
26+
- name: http
27+
protocol: HTTP
28+
port: 8080
2929
---
3030
apiVersion: aigateway.envoyproxy.io/v1alpha1
3131
kind: AIGatewayRoute
@@ -34,9 +34,9 @@ metadata:
3434
namespace: default
3535
spec:
3636
parentRefs:
37-
- name: ai-gateway-with-cache
38-
kind: Gateway
39-
group: gateway.networking.k8s.io
37+
- name: ai-gateway-with-cache
38+
kind: Gateway
39+
group: gateway.networking.k8s.io
4040
# Response caching configuration
4141
responseCache:
4242
# Enable response caching for this route
@@ -52,13 +52,13 @@ spec:
5252
# - Response "Cache-Control: max-age=N" overrides TTL
5353
respectCacheControl: true
5454
rules:
55-
- matches:
56-
- headers:
57-
- type: Exact
58-
name: x-ai-eg-model
59-
value: gpt-4o-mini
60-
backendRefs:
61-
- name: openai-backend
55+
- matches:
56+
- headers:
57+
- type: Exact
58+
name: x-ai-eg-model
59+
value: gpt-4o-mini
60+
backendRefs:
61+
- name: openai-backend
6262
---
6363
apiVersion: aigateway.envoyproxy.io/v1alpha1
6464
kind: AIServiceBackend
@@ -80,9 +80,9 @@ metadata:
8080
namespace: default
8181
spec:
8282
targetRefs:
83-
- group: aigateway.envoyproxy.io
84-
kind: AIServiceBackend
85-
name: openai-backend
83+
- group: aigateway.envoyproxy.io
84+
kind: AIServiceBackend
85+
name: openai-backend
8686
type: APIKey
8787
apiKey:
8888
secretRef:
@@ -96,9 +96,9 @@ metadata:
9696
namespace: default
9797
spec:
9898
endpoints:
99-
- fqdn:
100-
hostname: api.openai.com
101-
port: 443
99+
- fqdn:
100+
hostname: api.openai.com
101+
port: 443
102102
---
103103
apiVersion: gateway.networking.k8s.io/v1alpha3
104104
kind: BackendTLSPolicy
@@ -107,9 +107,9 @@ metadata:
107107
namespace: default
108108
spec:
109109
targetRefs:
110-
- group: gateway.envoyproxy.io
111-
kind: Backend
112-
name: openai-backend
110+
- group: gateway.envoyproxy.io
111+
kind: Backend
112+
name: openai-backend
113113
validation:
114114
wellKnownCACertificates: System
115115
hostname: api.openai.com

internal/cache/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestHashBody(t *testing.T) {
3434
for _, tt := range tests {
3535
t.Run(tt.name, func(t *testing.T) {
3636
result := HashBody(tt.body)
37-
require.True(t, len(result) > len(KeyPrefix), "hash should be longer than prefix")
37+
require.Greater(t, len(result), len(KeyPrefix), "hash should be longer than prefix")
3838
require.Contains(t, result, KeyPrefix, "hash should contain prefix")
3939

4040
// Verify determinism

internal/cache/cachecontrol.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"time"
1212
)
1313

14-
// CacheDirectives holds parsed Cache-Control header directives.
15-
type CacheDirectives struct {
14+
// Directives holds parsed Cache-Control header directives.
15+
type Directives struct {
1616
// NoCache indicates the response should not be served from cache without revalidation.
1717
// For requests: bypass cache lookup but still cache the response.
1818
// For responses: treat as no-store for simplicity (no revalidation support).
@@ -38,9 +38,9 @@ type CacheDirectives struct {
3838
// - private: do not store in shared cache
3939
// - max-age=N: use N seconds as TTL
4040
//
41-
// Example: "no-cache, max-age=3600" -> CacheDirectives{NoCache: true, MaxAge: 1h}
42-
func ParseCacheControl(value string) CacheDirectives {
43-
var d CacheDirectives
41+
// Example: "no-cache, max-age=3600" -> Directives{NoCache: true, MaxAge: 1h}
42+
func ParseCacheControl(value string) Directives {
43+
var d Directives
4444
if value == "" {
4545
return d
4646
}
@@ -74,12 +74,12 @@ func ParseCacheControl(value string) CacheDirectives {
7474

7575
// ShouldSkipCacheLookup returns true if the request Cache-Control directives
7676
// indicate that cache lookup should be skipped.
77-
func (d CacheDirectives) ShouldSkipCacheLookup() bool {
77+
func (d Directives) ShouldSkipCacheLookup() bool {
7878
return d.NoStore || d.NoCache
7979
}
8080

8181
// ShouldSkipCacheStore returns true if the directives indicate that
8282
// the response should not be stored in cache.
83-
func (d CacheDirectives) ShouldSkipCacheStore() bool {
83+
func (d Directives) ShouldSkipCacheStore() bool {
8484
return d.NoStore || d.NoCache || d.Private
8585
}

0 commit comments

Comments
 (0)