From 62a2ab6f7076ee270376c1d6bcb8c70d99d8af62 Mon Sep 17 00:00:00 2001
From: Benjamin Jee
Date: Wed, 8 Jan 2025 15:58:02 -0800
Subject: [PATCH] Remove v1alpha2 shared types file
---
apis/v1alpha2/observabilitypolicy_types.go | 4 +-
apis/v1alpha2/shared_types.go | 28 ---------
apis/v1alpha2/zz_generated.deepcopy.go | 18 +-----
.../policies/observability/generator_test.go | 4 +-
.../policies/observability/validator_test.go | 3 +-
site/content/reference/api.md | 58 +------------------
6 files changed, 12 insertions(+), 103 deletions(-)
delete mode 100644 apis/v1alpha2/shared_types.go
diff --git a/apis/v1alpha2/observabilitypolicy_types.go b/apis/v1alpha2/observabilitypolicy_types.go
index 05bd555577..e431b9ec8e 100644
--- a/apis/v1alpha2/observabilitypolicy_types.go
+++ b/apis/v1alpha2/observabilitypolicy_types.go
@@ -3,6 +3,8 @@ package v1alpha2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
+
+ ngfAPIv1alpha1 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1"
)
// +genclient
@@ -100,7 +102,7 @@ type Tracing struct {
// +listType=map
// +listMapKey=key
// +kubebuilder:validation:MaxItems=64
- SpanAttributes []SpanAttribute `json:"spanAttributes,omitempty"`
+ SpanAttributes []ngfAPIv1alpha1.SpanAttribute `json:"spanAttributes,omitempty"`
}
// TraceStrategy defines the tracing strategy.
diff --git a/apis/v1alpha2/shared_types.go b/apis/v1alpha2/shared_types.go
deleted file mode 100644
index 660db423f6..0000000000
--- a/apis/v1alpha2/shared_types.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package v1alpha2
-
-// Duration is a string value representing a duration in time.
-// Duration can be specified in milliseconds (ms), seconds (s), minutes (m), hours (h).
-// A value without a suffix is seconds.
-// Examples: 120s, 50ms, 5m, 1h.
-//
-// +kubebuilder:validation:Pattern=`^[0-9]{1,4}(ms|s|m|h)?$`
-type Duration string
-
-// SpanAttribute is a key value pair to be added to a tracing span.
-type SpanAttribute struct {
- // Key is the key for a span attribute.
- // Format: must have all '"' escaped and must not contain any '$' or end with an unescaped '\'
- //
- // +kubebuilder:validation:MinLength=1
- // +kubebuilder:validation:MaxLength=255
- // +kubebuilder:validation:Pattern=`^([^"$\\]|\\[^$])*$`
- Key string `json:"key"`
-
- // Value is the value for a span attribute.
- // Format: must have all '"' escaped and must not contain any '$' or end with an unescaped '\'
- //
- // +kubebuilder:validation:MinLength=1
- // +kubebuilder:validation:MaxLength=255
- // +kubebuilder:validation:Pattern=`^([^"$\\]|\\[^$])*$`
- Value string `json:"value"`
-}
diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go
index cad2f37263..2435365a72 100644
--- a/apis/v1alpha2/zz_generated.deepcopy.go
+++ b/apis/v1alpha2/zz_generated.deepcopy.go
@@ -5,6 +5,7 @@
package v1alpha2
import (
+ "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
apisv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)
@@ -93,21 +94,6 @@ func (in *ObservabilityPolicySpec) DeepCopy() *ObservabilityPolicySpec {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *SpanAttribute) DeepCopyInto(out *SpanAttribute) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SpanAttribute.
-func (in *SpanAttribute) DeepCopy() *SpanAttribute {
- if in == nil {
- return nil
- }
- out := new(SpanAttribute)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Tracing) DeepCopyInto(out *Tracing) {
*out = *in
@@ -128,7 +114,7 @@ func (in *Tracing) DeepCopyInto(out *Tracing) {
}
if in.SpanAttributes != nil {
in, out := &in.SpanAttributes, &out.SpanAttributes
- *out = make([]SpanAttribute, len(*in))
+ *out = make([]v1alpha1.SpanAttribute, len(*in))
copy(*out, *in)
}
}
diff --git a/internal/mode/static/nginx/config/policies/observability/generator_test.go b/internal/mode/static/nginx/config/policies/observability/generator_test.go
index 13bab7a803..33552850ed 100644
--- a/internal/mode/static/nginx/config/policies/observability/generator_test.go
+++ b/internal/mode/static/nginx/config/policies/observability/generator_test.go
@@ -162,7 +162,7 @@ func TestGenerate(t *testing.T) {
policy: &ngfAPIv1alpha2.ObservabilityPolicy{
Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{
Tracing: &ngfAPIv1alpha2.Tracing{
- SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{
+ SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{
{Key: "test-key", Value: "test-value"},
},
},
@@ -212,7 +212,7 @@ func TestGenerate(t *testing.T) {
Strategy: ngfAPIv1alpha2.TraceStrategyRatio,
Context: context,
SpanName: spanName,
- SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{
+ SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{
{Key: "test-key", Value: "test-value"},
},
},
diff --git a/internal/mode/static/nginx/config/policies/observability/validator_test.go b/internal/mode/static/nginx/config/policies/observability/validator_test.go
index a8577e4892..0272bf6a37 100644
--- a/internal/mode/static/nginx/config/policies/observability/validator_test.go
+++ b/internal/mode/static/nginx/config/policies/observability/validator_test.go
@@ -8,6 +8,7 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
"sigs.k8s.io/gateway-api/apis/v1alpha2"
+ ngfAPIv1alpha1 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1"
ngfAPIv1alpha2 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha2"
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/conditions"
"github.com/nginxinc/nginx-gateway-fabric/internal/framework/helpers"
@@ -38,7 +39,7 @@ func createValidPolicy() *ngfAPIv1alpha2.ObservabilityPolicy {
Strategy: ngfAPIv1alpha2.TraceStrategyRatio,
Context: helpers.GetPointer(ngfAPIv1alpha2.TraceContextExtract),
SpanName: helpers.GetPointer("spanName"),
- SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{
+ SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{
{Key: "key", Value: "value"},
},
},
diff --git a/site/content/reference/api.md b/site/content/reference/api.md
index b80136afa6..77eafa4ac6 100644
--- a/site/content/reference/api.md
+++ b/site/content/reference/api.md
@@ -1829,7 +1829,8 @@ and the status of the SnippetsFilter with respect to each controller.
(Appears on:
Telemetry,
-Tracing)
+Tracing,
+Tracing)
SpanAttribute is a key value pair to be added to a tracing span.
@@ -2419,15 +2420,6 @@ sigs.k8s.io/gateway-api/apis/v1alpha2.PolicyStatus
-Duration
-(string
alias)
-
-
-
Duration is a string value representing a duration in time.
-Duration can be specified in milliseconds (ms), seconds (s), minutes (m), hours (h).
-A value without a suffix is seconds.
-Examples: 120s, 50ms, 5m, 1h.
-
ObservabilityPolicySpec
@@ -2479,50 +2471,6 @@ be unique across all targetRef entries in the ObservabilityPolicy.
-SpanAttribute
-
-
-
-(Appears on:
-Tracing)
-
-
-
SpanAttribute is a key value pair to be added to a tracing span.
-
-
-
-
-Field |
-Description |
-
-
-
-
-
-key
-
-string
-
- |
-
- Key is the key for a span attribute.
-Format: must have all ‘“’ escaped and must not contain any ‘$’ or end with an unescaped ‘\’
- |
-
-
-
-value
-
-string
-
- |
-
- Value is the value for a span attribute.
-Format: must have all ‘“’ escaped and must not contain any ‘$’ or end with an unescaped ‘\’
- |
-
-
-
TraceContext
(string
alias)
@@ -2659,7 +2607,7 @@ Examples of invalid names: some-$value, quoted-“value”-name, unescap
spanAttributes
-
+
[]SpanAttribute
|