Skip to content

Commit 4240149

Browse files
committed
Update validation and attribute structure
1 parent 9f285d0 commit 4240149

File tree

3 files changed

+59
-20
lines changed

3 files changed

+59
-20
lines changed

apis/v1alpha1/nginxproxy_types.go

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ type Telemetry struct {
4747
//
4848
// +optional
4949
// +kubebuilder:validation:MaxLength=127
50+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
5051
ServiceName *string `json:"serviceName,omitempty"`
5152

5253
// SpanAttributes are custom key/value attributes that are added to each span.
5354
//
5455
// +optional
55-
// +kubebuilder:validation:MaxProperties=64
56-
SpanAttributes map[string]AttributeValue `json:"spanAttributes,omitempty"`
56+
// +kubebuilder:validation:MaxItems=64
57+
SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
5758
}
5859

5960
// TelemetryExporter specifies OpenTelemetry export parameters.
@@ -79,13 +80,23 @@ type TelemetryExporter struct {
7980
BatchCount *int32 `json:"batchCount,omitempty"`
8081

8182
// Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
82-
//
83+
// Format: alphanumeric hostname with optional http scheme and optional port.
8384
//nolint:lll
8485
// +kubebuilder:validation:Pattern=`^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$`
8586
Endpoint string `json:"endpoint"`
8687
}
8788

88-
// AttributeValue is a value paired with a key and attached to a tracing span.
89-
//
90-
// +kubebuilder:validation:MaxLength=255
91-
type AttributeValue string
89+
// SpanAttribute is a key value pair to be added to a tracing span.
90+
type SpanAttribute struct {
91+
// Key is the key for a span attribute.
92+
//
93+
// +kubebuilder:validation:MaxLength=255
94+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
95+
Key string `json:"key"`
96+
97+
// Value is the value for a span attribute.
98+
//
99+
// +kubebuilder:validation:MaxLength=255
100+
// +kubebuilder:validation:Pattern=`^[a-zA-Z0-9_-]+$`
101+
Value string `json:"value"`
102+
}

apis/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/gateway.nginx.org_nginxproxies.yaml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ spec:
6868
minimum: 0
6969
type: integer
7070
endpoint:
71-
description: Endpoint is the address of OTLP/gRPC endpoint
72-
that will accept telemetry data.
71+
description: |-
72+
Endpoint is the address of OTLP/gRPC endpoint that will accept telemetry data.
73+
Format: alphanumeric hostname with optional http scheme and optional port.
7374
pattern: ^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$
7475
type: string
7576
interval:
@@ -87,17 +88,31 @@ spec:
8788
Default is 'ngf:<gateway-namespace>:<gateway-name>'. If a value is provided by the user,
8889
then the default becomes a prefix to that value.
8990
maxLength: 127
91+
pattern: ^[a-zA-Z0-9_-]+$
9092
type: string
9193
spanAttributes:
92-
additionalProperties:
93-
description: AttributeValue is a value paired with a key and
94-
attached to a tracing span.
95-
maxLength: 255
96-
type: string
9794
description: SpanAttributes are custom key/value attributes that
9895
are added to each span.
99-
maxProperties: 64
100-
type: object
96+
items:
97+
description: SpanAttribute is a key value pair to be added to
98+
a tracing span.
99+
properties:
100+
key:
101+
description: Key is the key for a span attribute.
102+
maxLength: 255
103+
pattern: ^[a-zA-Z0-9_-]+$
104+
type: string
105+
value:
106+
description: Value is the value for a span attribute.
107+
maxLength: 255
108+
pattern: ^[a-zA-Z0-9_-]+$
109+
type: string
110+
required:
111+
- key
112+
- value
113+
type: object
114+
maxItems: 64
115+
type: array
101116
type: object
102117
type: object
103118
required:

0 commit comments

Comments
 (0)