Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,4 @@ formatters:
- third_party$
- builtin$
- examples$
- api/v1alpha1/ai_policy.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea on why this was necessary?

Copy link
Contributor Author

@Rachael-Graham Rachael-Graham Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - gofmt was changing the spaces in any codeblocks in the comment to tabs, and adding extra empty lines within the codeblocks that was breaking the yaml. I think gofmt has special handling for indented text in comments - it assumes they're code examples and applies Go formatting like tabs instead of spaces. but it ends up breaking them
I added api/v1alpha1/ai_policy.go to the formatting exclusions in .golangci.yaml to preserve the yaml anytime someone generates the code. but idk if this the best solution long term. I could at the very least add a comment here explaining?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment here would be useful. also, should we just exclude everything in the api/v1alpha1 directory?

62 changes: 26 additions & 36 deletions api/v1alpha1/ai_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,20 @@ import (
// and appends `Describe the painting as if you were a famous art critic from the 17th century.`
// to each request that is sent to the `openai` HTTPRoute.
// ```yaml
//
// name: openai-opt
// namespace: kgateway-system
//
// spec:
//
// targetRefs:
// - group: gateway.networking.k8s.io
// kind: HTTPRoute
// name: openai
// ai:
// promptEnrichment:
// prepend:
// - role: SYSTEM
// content: "Answer all questions in French."
// append:
// - role: USER
// content: "Describe the painting as if you were a famous art critic from the 17th century."
//
// targetRefs:
// - group: gateway.networking.k8s.io
// kind: HTTPRoute
// name: openai
// options:
// ai:
// promptEnrichment:
// prepend:
// - role: SYSTEM
// content: "Answer all questions in French."
// append:
// - role: USER
// content: "Describe the painting as if you were a famous art critic from the 17th century."
// ```
type AIPromptEnrichment struct {
// A list of messages to be prepended to the prompt sent by the client.
Expand Down Expand Up @@ -203,21 +198,19 @@ type PromptguardResponse struct {
// the string "credit card", and masks any credit card numbers in the response.
// ```yaml
// promptGuard:
//
// request:
// - response:
// message: "Rejected due to inappropriate content"
// regex:
// action: REJECT
// matches:
// - pattern: "credit card"
// name: "CC"
// response:
// - regex:
// builtins:
// - CREDIT_CARD
// action: MASK
//
// request:
// customResponse:
// message: "Rejected due to inappropriate content"
// regex:
// action: REJECT
// matches:
// - pattern: "credit card"
// name: "CC"
// response:
// regex:
// builtins:
// - CREDIT_CARD
// action: MASK
// ```
// +kubebuilder:validation:AtLeastOneOf=request;response
type AIPromptGuard struct {
Expand Down Expand Up @@ -245,7 +238,6 @@ type AIPromptGuard struct {
// defaults:
// - field: "system"
// value: "answer all questions in French"
//
// ```
//
// Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -264,11 +256,9 @@ type AIPromptGuard struct {
// defaults:
// - field: "custom_integer_list"
// value: [1,2,3]
//
// overrides:
// - field: "custom_string_list"
// value: ["one","two","three"]
//
// ```
//
// Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down
10 changes: 5 additions & 5 deletions api/v1alpha1/gateway_parameters_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ type EnvoyBootstrap struct {
// the values are one of "trace", "debug", "info", "warn", "error",
// "critical", or "off", e.g.
//
// ```yaml
// componentLogLevels:
// upstream: debug
// connection: trace
// ```
// ```yaml
// componentLogLevels:
// upstream: debug
// connection: trace
// ```
//
// These will be converted to the `--component-log-level` Envoy argument
// value. See
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -267,11 +266,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down Expand Up @@ -318,7 +315,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -337,11 +333,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down Expand Up @@ -2314,7 +2308,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -2333,11 +2326,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down Expand Up @@ -2383,7 +2374,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -2402,11 +2392,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -111,11 +110,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down Expand Up @@ -161,7 +158,6 @@ spec:
defaults:
- field: "system"
value: "answer all questions in French"

```

Example: Setting a default temperature and overriding `max_tokens`:
Expand All @@ -180,11 +176,9 @@ spec:
defaults:
- field: "custom_integer_list"
value: [1,2,3]

overrides:
- field: "custom_string_list"
value: ["one","two","three"]

```

Note: The `field` values correspond to keys in the JSON request body, not fields in this CRD.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,23 @@ spec:
componentLogLevels:
additionalProperties:
type: string
description: "Envoy log levels for specific components.
The keys are component names and\nthe values are one
of \"trace\", \"debug\", \"info\", \"warn\", \"error\",\n\"critical\",
or \"off\", e.g.\n\n\t```yaml\n\tcomponentLogLevels:\n\t
\ upstream: debug\n\t connection: trace\n\t```\n\nThese
will be converted to the `--component-log-level` Envoy
argument\nvalue. See\nhttps://www.envoyproxy.io/docs/envoy/latest/start/quick-start/run-envoy#debugging-envoy\nfor
more information.\n\nNote: the keys and values cannot
be empty, but they are not otherwise validated."
description: |-
Envoy log levels for specific components. The keys are component names and
the values are one of "trace", "debug", "info", "warn", "error",
"critical", or "off", e.g.

```yaml
componentLogLevels:
upstream: debug
connection: trace
```

These will be converted to the `--component-log-level` Envoy argument
value. See
https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/run-envoy#debugging-envoy
for more information.

Note: the keys and values cannot be empty, but they are not otherwise validated.
type: object
logLevel:
description: |-
Expand Down