diff --git a/apis/v1alpha2/policy_methods.go b/apis/v1alpha2/policy_methods.go new file mode 100644 index 000000000..8fc6dc768 --- /dev/null +++ b/apis/v1alpha2/policy_methods.go @@ -0,0 +1,21 @@ +package v1alpha2 + +import ( + "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +// FIXME(kate-osborn): https://github.com/nginxinc/nginx-gateway-fabric/issues/1939. +// Figure out a way to generate these methods for all our policies. +// These methods implement the policies.Policy interface which extends client.Object to add the following methods. + +func (p *ObservabilityPolicy) GetTargetRefs() []v1alpha2.LocalPolicyTargetReference { + return p.Spec.TargetRefs +} + +func (p *ObservabilityPolicy) GetPolicyStatus() v1alpha2.PolicyStatus { + return p.Status +} + +func (p *ObservabilityPolicy) SetPolicyStatus(status v1alpha2.PolicyStatus) { + p.Status = status +} diff --git a/internal/mode/static/manager.go b/internal/mode/static/manager.go index afb056017..a527b0ac1 100644 --- a/internal/mode/static/manager.go +++ b/internal/mode/static/manager.go @@ -34,7 +34,8 @@ import ( gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/controller" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/filter" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/controller/index" @@ -83,7 +84,8 @@ func init() { utilruntime.Must(gatewayv1alpha2.Install(scheme)) utilruntime.Must(apiv1.AddToScheme(scheme)) utilruntime.Must(discoveryV1.AddToScheme(scheme)) - utilruntime.Must(ngfAPI.AddToScheme(scheme)) + utilruntime.Must(ngfAPIv1alpha1.AddToScheme(scheme)) + utilruntime.Must(ngfAPIv1alpha2.AddToScheme(scheme)) utilruntime.Must(apiext.AddToScheme(scheme)) utilruntime.Must(appsv1.AddToScheme(scheme)) } @@ -314,15 +316,15 @@ func createPolicyManager( ) *policies.CompositeValidator { cfgs := []policies.ManagerConfig{ { - GVK: mustExtractGVK(&ngfAPI.ClientSettingsPolicy{}), + GVK: mustExtractGVK(&ngfAPIv1alpha1.ClientSettingsPolicy{}), Validator: clientsettings.NewValidator(validator), }, { - GVK: mustExtractGVK(&ngfAPI.ObservabilityPolicy{}), + GVK: mustExtractGVK(&ngfAPIv1alpha2.ObservabilityPolicy{}), Validator: observability.NewValidator(validator), }, { - GVK: mustExtractGVK(&ngfAPI.UpstreamSettingsPolicy{}), + GVK: mustExtractGVK(&ngfAPIv1alpha1.UpstreamSettingsPolicy{}), Validator: upstreamsettings.NewValidator(validator), }, } @@ -483,7 +485,7 @@ func registerControllers( }, }, { - objectType: &ngfAPI.NginxProxy{}, + objectType: &ngfAPIv1alpha1.NginxProxy{}, options: []controller.Option{ controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}), }, @@ -495,19 +497,19 @@ func registerControllers( }, }, { - objectType: &ngfAPI.ClientSettingsPolicy{}, + objectType: &ngfAPIv1alpha1.ClientSettingsPolicy{}, options: []controller.Option{ controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}), }, }, { - objectType: &ngfAPI.ObservabilityPolicy{}, + objectType: &ngfAPIv1alpha2.ObservabilityPolicy{}, options: []controller.Option{ controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}), }, }, { - objectType: &ngfAPI.UpstreamSettingsPolicy{}, + objectType: &ngfAPIv1alpha1.UpstreamSettingsPolicy{}, options: []controller.Option{ controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}), }, @@ -540,7 +542,7 @@ func registerControllers( if cfg.ConfigName != "" { controllerRegCfgs = append(controllerRegCfgs, ctlrCfg{ - objectType: &ngfAPI.NginxGateway{}, + objectType: &ngfAPIv1alpha1.NginxGateway{}, options: []controller.Option{ controller.WithNamespacedNameFilter(filter.CreateSingleResourceFilter(controlConfigNSName)), }, @@ -559,7 +561,7 @@ func registerControllers( if cfg.SnippetsFilters { controllerRegCfgs = append(controllerRegCfgs, ctlrCfg{ - objectType: &ngfAPI.SnippetsFilter{}, + objectType: &ngfAPIv1alpha1.SnippetsFilter{}, options: []controller.Option{ controller.WithK8sPredicate(k8spredicate.GenerationChangedPredicate{}), }, @@ -744,11 +746,11 @@ func prepareFirstEventBatchPreparerArgs(cfg config.Config) ([]client.Object, []c &discoveryV1.EndpointSliceList{}, &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, &gatewayv1.GRPCRouteList{}, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, partialObjectMetadataList, } @@ -764,7 +766,7 @@ func prepareFirstEventBatchPreparerArgs(cfg config.Config) ([]client.Object, []c if cfg.SnippetsFilters { objectLists = append( objectLists, - &ngfAPI.SnippetsFilterList{}, + &ngfAPIv1alpha1.SnippetsFilterList{}, ) } @@ -792,7 +794,7 @@ func setInitialConfig( ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() - var conf ngfAPI.NginxGateway + var conf ngfAPIv1alpha1.NginxGateway // Polling to wait for CRD to exist if the Deployment is created first. if err := wait.PollUntilContextCancel( ctx, diff --git a/internal/mode/static/manager_test.go b/internal/mode/static/manager_test.go index 0f2d802d3..90e31df92 100644 --- a/internal/mode/static/manager_test.go +++ b/internal/mode/static/manager_test.go @@ -19,7 +19,8 @@ import ( gatewayv1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3" gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/mode/static/config" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" ) @@ -62,12 +63,12 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { &gatewayv1.HTTPRouteList{}, &gatewayv1.GatewayList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, &gatewayv1.GRPCRouteList{}, partialObjectMetadataList, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, }, }, { @@ -92,12 +93,12 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { &discoveryV1.EndpointSliceList{}, &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, &gatewayv1.GRPCRouteList{}, partialObjectMetadataList, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, }, }, { @@ -123,14 +124,14 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { &discoveryV1.EndpointSliceList{}, &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, partialObjectMetadataList, &gatewayv1alpha3.BackendTLSPolicyList{}, &gatewayv1alpha2.TLSRouteList{}, &gatewayv1.GRPCRouteList{}, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, }, }, { @@ -155,13 +156,13 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { &discoveryV1.EndpointSliceList{}, &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, partialObjectMetadataList, &gatewayv1.GRPCRouteList{}, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.SnippetsFilterList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.SnippetsFilterList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, }, }, { @@ -187,15 +188,15 @@ func TestPrepareFirstEventBatchPreparerArgs(t *testing.T) { &discoveryV1.EndpointSliceList{}, &gatewayv1.HTTPRouteList{}, &gatewayv1beta1.ReferenceGrantList{}, - &ngfAPI.NginxProxyList{}, + &ngfAPIv1alpha1.NginxProxyList{}, partialObjectMetadataList, &gatewayv1alpha3.BackendTLSPolicyList{}, &gatewayv1alpha2.TLSRouteList{}, &gatewayv1.GRPCRouteList{}, - &ngfAPI.ClientSettingsPolicyList{}, - &ngfAPI.ObservabilityPolicyList{}, - &ngfAPI.SnippetsFilterList{}, - &ngfAPI.UpstreamSettingsPolicyList{}, + &ngfAPIv1alpha1.ClientSettingsPolicyList{}, + &ngfAPIv1alpha2.ObservabilityPolicyList{}, + &ngfAPIv1alpha1.SnippetsFilterList{}, + &ngfAPIv1alpha1.UpstreamSettingsPolicyList{}, }, }, } diff --git a/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go b/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go index 395f0dd90..d67845f80 100644 --- a/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go +++ b/internal/mode/static/nginx/config/policies/clientsettings/generator_test.go @@ -5,7 +5,8 @@ import ( . "github.com/onsi/gomega" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" @@ -14,12 +15,12 @@ import ( func TestGenerate(t *testing.T) { t.Parallel() - maxSize := helpers.GetPointer[ngfAPI.Size]("10m") - bodyTimeout := helpers.GetPointer[ngfAPI.Duration]("600ms") + maxSize := helpers.GetPointer[ngfAPIv1alpha1.Size]("10m") + bodyTimeout := helpers.GetPointer[ngfAPIv1alpha1.Duration]("600ms") keepaliveRequests := helpers.GetPointer[int32](900) - keepaliveTime := helpers.GetPointer[ngfAPI.Duration]("50s") - keepaliveServerTimeout := helpers.GetPointer[ngfAPI.Duration]("30s") - keepaliveHeaderTimeout := helpers.GetPointer[ngfAPI.Duration]("60s") + keepaliveTime := helpers.GetPointer[ngfAPIv1alpha1.Duration]("50s") + keepaliveServerTimeout := helpers.GetPointer[ngfAPIv1alpha1.Duration]("30s") + keepaliveHeaderTimeout := helpers.GetPointer[ngfAPIv1alpha1.Duration]("60s") tests := []struct { name string @@ -28,9 +29,9 @@ func TestGenerate(t *testing.T) { }{ { name: "body max size populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - Body: &ngfAPI.ClientBody{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + Body: &ngfAPIv1alpha1.ClientBody{ MaxSize: maxSize, }, }, @@ -41,9 +42,9 @@ func TestGenerate(t *testing.T) { }, { name: "body timeout populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - Body: &ngfAPI.ClientBody{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + Body: &ngfAPIv1alpha1.ClientBody{ Timeout: bodyTimeout, }, }, @@ -54,9 +55,9 @@ func TestGenerate(t *testing.T) { }, { name: "keepalive requests populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - KeepAlive: &ngfAPI.ClientKeepAlive{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ Requests: keepaliveRequests, }, }, @@ -67,9 +68,9 @@ func TestGenerate(t *testing.T) { }, { name: "keepalive time populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - KeepAlive: &ngfAPI.ClientKeepAlive{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ Time: keepaliveTime, }, }, @@ -80,10 +81,10 @@ func TestGenerate(t *testing.T) { }, { name: "keepalive timeout server populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - KeepAlive: &ngfAPI.ClientKeepAlive{ - Timeout: &ngfAPI.ClientKeepAliveTimeout{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ + Timeout: &ngfAPIv1alpha1.ClientKeepAliveTimeout{ Server: keepaliveServerTimeout, }, }, @@ -95,10 +96,10 @@ func TestGenerate(t *testing.T) { }, { name: "keepalive timeout server and header populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - KeepAlive: &ngfAPI.ClientKeepAlive{ - Timeout: &ngfAPI.ClientKeepAliveTimeout{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ + Timeout: &ngfAPIv1alpha1.ClientKeepAliveTimeout{ Server: keepaliveServerTimeout, Header: keepaliveHeaderTimeout, }, @@ -111,10 +112,10 @@ func TestGenerate(t *testing.T) { }, { name: "keepalive timeout header populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - KeepAlive: &ngfAPI.ClientKeepAlive{ - Timeout: &ngfAPI.ClientKeepAliveTimeout{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ + Timeout: &ngfAPIv1alpha1.ClientKeepAliveTimeout{ Header: keepaliveHeaderTimeout, }, }, @@ -124,16 +125,16 @@ func TestGenerate(t *testing.T) { }, { name: "all fields populated", - policy: &ngfAPI.ClientSettingsPolicy{ - Spec: ngfAPI.ClientSettingsPolicySpec{ - Body: &ngfAPI.ClientBody{ + policy: &ngfAPIv1alpha1.ClientSettingsPolicy{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + Body: &ngfAPIv1alpha1.ClientBody{ MaxSize: maxSize, Timeout: bodyTimeout, }, - KeepAlive: &ngfAPI.ClientKeepAlive{ + KeepAlive: &ngfAPIv1alpha1.ClientKeepAlive{ Requests: keepaliveRequests, Time: keepaliveTime, - Timeout: &ngfAPI.ClientKeepAliveTimeout{ + Timeout: &ngfAPIv1alpha1.ClientKeepAliveTimeout{ Server: keepaliveServerTimeout, Header: keepaliveHeaderTimeout, }, @@ -186,18 +187,18 @@ func TestGenerateNoPolicies(t *testing.T) { resFiles := generator.GenerateForServer([]policies.Policy{}, http.Server{}) g.Expect(resFiles).To(BeEmpty()) - resFiles = generator.GenerateForServer([]policies.Policy{&ngfAPI.ObservabilityPolicy{}}, http.Server{}) + resFiles = generator.GenerateForServer([]policies.Policy{&ngfAPIv1alpha2.ObservabilityPolicy{}}, http.Server{}) g.Expect(resFiles).To(BeEmpty()) resFiles = generator.GenerateForLocation([]policies.Policy{}, http.Location{}) g.Expect(resFiles).To(BeEmpty()) - resFiles = generator.GenerateForLocation([]policies.Policy{&ngfAPI.ObservabilityPolicy{}}, http.Location{}) + resFiles = generator.GenerateForLocation([]policies.Policy{&ngfAPIv1alpha2.ObservabilityPolicy{}}, http.Location{}) g.Expect(resFiles).To(BeEmpty()) resFiles = generator.GenerateForInternalLocation([]policies.Policy{}) g.Expect(resFiles).To(BeEmpty()) - resFiles = generator.GenerateForInternalLocation([]policies.Policy{&ngfAPI.ObservabilityPolicy{}}) + resFiles = generator.GenerateForInternalLocation([]policies.Policy{&ngfAPIv1alpha2.ObservabilityPolicy{}}) g.Expect(resFiles).To(BeEmpty()) } diff --git a/internal/mode/static/nginx/config/policies/observability/generator.go b/internal/mode/static/nginx/config/policies/observability/generator.go index 3e86827fe..ca31f9016 100644 --- a/internal/mode/static/nginx/config/policies/observability/generator.go +++ b/internal/mode/static/nginx/config/policies/observability/generator.go @@ -4,7 +4,7 @@ import ( "fmt" "text/template" - ngfAPI "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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" @@ -83,7 +83,7 @@ func (g Generator) GenerateForLocation(pols []policies.Policy, location http.Loc includeGlobalAttrs bool, ) policies.GenerateResultFiles { for _, pol := range pols { - obs, ok := pol.(*ngfAPI.ObservabilityPolicy) + obs, ok := pol.(*ngfAPIv1alpha2.ObservabilityPolicy) if !ok { continue } @@ -118,7 +118,7 @@ func (g Generator) GenerateForLocation(pols []policies.Policy, location http.Loc // being specified in the external location that redirects to the internal location. func (g Generator) GenerateForInternalLocation(pols []policies.Policy) policies.GenerateResultFiles { for _, pol := range pols { - obs, ok := pol.(*ngfAPI.ObservabilityPolicy) + obs, ok := pol.(*ngfAPIv1alpha2.ObservabilityPolicy) if !ok { continue } @@ -139,13 +139,13 @@ func (g Generator) GenerateForInternalLocation(pols []policies.Policy) policies. return nil } -func getStrategy(obs *ngfAPI.ObservabilityPolicy) string { +func getStrategy(obs *ngfAPIv1alpha2.ObservabilityPolicy) string { var strategy string if obs.Spec.Tracing != nil { switch obs.Spec.Tracing.Strategy { - case ngfAPI.TraceStrategyParent: + case ngfAPIv1alpha2.TraceStrategyParent: strategy = "$otel_parent_sampled" - case ngfAPI.TraceStrategyRatio: + case ngfAPIv1alpha2.TraceStrategyRatio: strategy = "on" if obs.Spec.Tracing.Ratio != nil { if *obs.Spec.Tracing.Ratio > 0 { 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 bee1df4e8..13bab7a80 100644 --- a/internal/mode/static/nginx/config/policies/observability/generator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/generator_test.go @@ -6,7 +6,8 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" @@ -18,7 +19,7 @@ func TestGenerate(t *testing.T) { t.Parallel() ratio := helpers.GetPointer[int32](25) zeroRatio := helpers.GetPointer[int32](0) - context := helpers.GetPointer[ngfAPI.TraceContext](ngfAPI.TraceContextExtract) + context := helpers.GetPointer[ngfAPIv1alpha2.TraceContext](ngfAPIv1alpha2.TraceContextExtract) spanName := helpers.GetPointer("my-span") tests := []struct { @@ -31,10 +32,10 @@ func TestGenerate(t *testing.T) { }{ { name: "strategy set to default ratio", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, }, }, }, @@ -50,14 +51,14 @@ func TestGenerate(t *testing.T) { }, { name: "strategy set to custom ratio", - policy: &ngfAPI.ObservabilityPolicy{ + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "test-policy", Namespace: "test-namespace", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Ratio: ratio, }, }, @@ -74,14 +75,14 @@ func TestGenerate(t *testing.T) { }, { name: "strategy set to zero ratio", - policy: &ngfAPI.ObservabilityPolicy{ + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "test-policy", Namespace: "test-namespace", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Ratio: zeroRatio, }, }, @@ -98,10 +99,10 @@ func TestGenerate(t *testing.T) { }, { name: "strategy set to parent", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyParent, + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyParent, }, }, }, @@ -117,9 +118,9 @@ func TestGenerate(t *testing.T) { }, { name: "context is set", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Context: context, }, }, @@ -138,9 +139,9 @@ func TestGenerate(t *testing.T) { }, { name: "spanName is set", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ SpanName: spanName, }, }, @@ -158,10 +159,10 @@ func TestGenerate(t *testing.T) { }, { name: "span attributes set", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - SpanAttributes: []ngfAPI.SpanAttribute{ + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ {Key: "test-key", Value: "test-value"}, }, }, @@ -181,9 +182,9 @@ func TestGenerate(t *testing.T) { }, { name: "global span attributes set", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{}, + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{}, }, }, telemetryConf: dataplane.Telemetry{ @@ -205,13 +206,13 @@ func TestGenerate(t *testing.T) { }, { name: "all fields populated", - policy: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + policy: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Context: context, SpanName: spanName, - SpanAttributes: []ngfAPI.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ {Key: "test-key", Value: "test-value"}, }, }, @@ -290,12 +291,12 @@ func TestGenerateNoPolicies(t *testing.T) { resFiles := generator.GenerateForLocation([]policies.Policy{}, http.Location{}) g.Expect(resFiles).To(BeEmpty()) - resFiles = generator.GenerateForLocation([]policies.Policy{&ngfAPI.ClientSettingsPolicy{}}, http.Location{}) + resFiles = generator.GenerateForLocation([]policies.Policy{&ngfAPIv1alpha1.ClientSettingsPolicy{}}, http.Location{}) g.Expect(resFiles).To(BeEmpty()) resFiles = generator.GenerateForInternalLocation([]policies.Policy{}) g.Expect(resFiles).To(BeEmpty()) - resFiles = generator.GenerateForInternalLocation([]policies.Policy{&ngfAPI.ClientSettingsPolicy{}}) + resFiles = generator.GenerateForInternalLocation([]policies.Policy{&ngfAPIv1alpha1.ClientSettingsPolicy{}}) g.Expect(resFiles).To(BeEmpty()) } diff --git a/internal/mode/static/nginx/config/policies/observability/validator.go b/internal/mode/static/nginx/config/policies/observability/validator.go index b93902d95..5f1e6ed04 100644 --- a/internal/mode/static/nginx/config/policies/observability/validator.go +++ b/internal/mode/static/nginx/config/policies/observability/validator.go @@ -4,7 +4,7 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - ngfAPI "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" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/kinds" @@ -29,7 +29,7 @@ func (v *Validator) Validate( policy policies.Policy, globalSettings *policies.GlobalSettings, ) []conditions.Condition { - obs := helpers.MustCastObject[*ngfAPI.ObservabilityPolicy](policy) + obs := helpers.MustCastObject[*ngfAPIv1alpha2.ObservabilityPolicy](policy) if globalSettings == nil || !globalSettings.NginxProxyValid { return []conditions.Condition{ @@ -62,13 +62,13 @@ func (v *Validator) Validate( // Conflicts returns true if the two ObservabilityPolicies conflict. func (v *Validator) Conflicts(polA, polB policies.Policy) bool { - a := helpers.MustCastObject[*ngfAPI.ObservabilityPolicy](polA) - b := helpers.MustCastObject[*ngfAPI.ObservabilityPolicy](polB) + a := helpers.MustCastObject[*ngfAPIv1alpha2.ObservabilityPolicy](polA) + b := helpers.MustCastObject[*ngfAPIv1alpha2.ObservabilityPolicy](polB) return a.Spec.Tracing != nil && b.Spec.Tracing != nil } -func (v *Validator) validateSettings(spec ngfAPI.ObservabilityPolicySpec) error { +func (v *Validator) validateSettings(spec ngfAPIv1alpha2.ObservabilityPolicySpec) error { var allErrs field.ErrorList fieldPath := field.NewPath("spec") @@ -76,7 +76,7 @@ func (v *Validator) validateSettings(spec ngfAPI.ObservabilityPolicySpec) error tracePath := fieldPath.Child("tracing") switch spec.Tracing.Strategy { - case ngfAPI.TraceStrategyRatio, ngfAPI.TraceStrategyParent: + case ngfAPIv1alpha2.TraceStrategyRatio, ngfAPIv1alpha2.TraceStrategyParent: default: allErrs = append( allErrs, @@ -84,18 +84,18 @@ func (v *Validator) validateSettings(spec ngfAPI.ObservabilityPolicySpec) error tracePath.Child("strategy"), spec.Tracing.Strategy, []string{ - string(ngfAPI.TraceStrategyRatio), - string(ngfAPI.TraceStrategyParent), + string(ngfAPIv1alpha2.TraceStrategyRatio), + string(ngfAPIv1alpha2.TraceStrategyParent), }), ) } if spec.Tracing.Context != nil { switch *spec.Tracing.Context { - case ngfAPI.TraceContextExtract, - ngfAPI.TraceContextInject, - ngfAPI.TraceContextPropagate, - ngfAPI.TraceContextIgnore: + case ngfAPIv1alpha2.TraceContextExtract, + ngfAPIv1alpha2.TraceContextInject, + ngfAPIv1alpha2.TraceContextPropagate, + ngfAPIv1alpha2.TraceContextIgnore: default: allErrs = append( allErrs, @@ -103,10 +103,10 @@ func (v *Validator) validateSettings(spec ngfAPI.ObservabilityPolicySpec) error tracePath.Child("context"), spec.Tracing.Context, []string{ - string(ngfAPI.TraceContextExtract), - string(ngfAPI.TraceContextInject), - string(ngfAPI.TraceContextPropagate), - string(ngfAPI.TraceContextIgnore), + string(ngfAPIv1alpha2.TraceContextExtract), + string(ngfAPIv1alpha2.TraceContextInject), + string(ngfAPIv1alpha2.TraceContextPropagate), + string(ngfAPIv1alpha2.TraceContextIgnore), }), ) } 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 53aa9c19e..a8577e489 100644 --- a/internal/mode/static/nginx/config/policies/observability/validator_test.go +++ b/internal/mode/static/nginx/config/policies/observability/validator_test.go @@ -8,7 +8,7 @@ import ( gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" - ngfAPI "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" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/kinds" @@ -19,14 +19,14 @@ import ( staticConds "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions" ) -type policyModFunc func(policy *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy +type policyModFunc func(policy *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy -func createValidPolicy() *ngfAPI.ObservabilityPolicy { - return &ngfAPI.ObservabilityPolicy{ +func createValidPolicy() *ngfAPIv1alpha2.ObservabilityPolicy { + return &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Namespace: "default", }, - Spec: ngfAPI.ObservabilityPolicySpec{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ TargetRefs: []v1alpha2.LocalPolicyTargetReference{ { Group: gatewayv1.GroupName, @@ -34,11 +34,11 @@ func createValidPolicy() *ngfAPI.ObservabilityPolicy { Name: "route", }, }, - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, - Context: helpers.GetPointer(ngfAPI.TraceContextExtract), + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, + Context: helpers.GetPointer(ngfAPIv1alpha2.TraceContextExtract), SpanName: helpers.GetPointer("spanName"), - SpanAttributes: []ngfAPI.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha2.SpanAttribute{ {Key: "key", Value: "value"}, }, }, @@ -47,7 +47,7 @@ func createValidPolicy() *ngfAPI.ObservabilityPolicy { } } -func createModifiedPolicy(mod policyModFunc) *ngfAPI.ObservabilityPolicy { +func createModifiedPolicy(mod policyModFunc) *ngfAPIv1alpha2.ObservabilityPolicy { return mod(createValidPolicy()) } @@ -60,7 +60,7 @@ func TestValidator_Validate(t *testing.T) { tests := []struct { name string - policy *ngfAPI.ObservabilityPolicy + policy *ngfAPIv1alpha2.ObservabilityPolicy globalSettings *policies.GlobalSettings expConditions []conditions.Condition }{ @@ -89,7 +89,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid target ref; unsupported group", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.TargetRefs[0].Group = "Unsupported" return p }), @@ -101,7 +101,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid target ref; unsupported kind", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.TargetRefs[0].Kind = "Unsupported" return p }), @@ -113,7 +113,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid strategy", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.Tracing.Strategy = "invalid" return p }), @@ -125,8 +125,8 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid context", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { - p.Spec.Tracing.Context = helpers.GetPointer[ngfAPI.TraceContext]("invalid") + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { + p.Spec.Tracing.Context = helpers.GetPointer[ngfAPIv1alpha2.TraceContext]("invalid") return p }), globalSettings: globalSettings, @@ -137,7 +137,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid span name", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.Tracing.SpanName = helpers.GetPointer("invalid$$$") return p }), @@ -150,7 +150,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid span attribute key", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.Tracing.SpanAttributes[0].Key = "invalid$$$" return p }), @@ -163,7 +163,7 @@ func TestValidator_Validate(t *testing.T) { }, { name: "invalid span attribute value", - policy: createModifiedPolicy(func(p *ngfAPI.ObservabilityPolicy) *ngfAPI.ObservabilityPolicy { + policy: createModifiedPolicy(func(p *ngfAPIv1alpha2.ObservabilityPolicy) *ngfAPIv1alpha2.ObservabilityPolicy { p.Spec.Tracing.SpanAttributes[0].Value = "invalid$$$" return p }), @@ -211,33 +211,33 @@ func TestValidator_ValidatePanics(t *testing.T) { func TestValidator_Conflicts(t *testing.T) { t.Parallel() tests := []struct { - polA *ngfAPI.ObservabilityPolicy - polB *ngfAPI.ObservabilityPolicy + polA *ngfAPIv1alpha2.ObservabilityPolicy + polB *ngfAPIv1alpha2.ObservabilityPolicy name string conflicts bool }{ { name: "no conflicts", - polA: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{}, + polA: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{}, }, }, - polB: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{}, + polB: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{}, }, conflicts: false, }, { name: "conflicts", - polA: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{}, + polA: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{}, }, }, - polB: &ngfAPI.ObservabilityPolicy{ - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{}, + polB: &ngfAPIv1alpha2.ObservabilityPolicy{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{}, }, }, conflicts: true, diff --git a/internal/mode/static/nginx/config/policies/upstreamsettings/processor_test.go b/internal/mode/static/nginx/config/policies/upstreamsettings/processor_test.go index b7c785376..535178a5e 100644 --- a/internal/mode/static/nginx/config/policies/upstreamsettings/processor_test.go +++ b/internal/mode/static/nginx/config/policies/upstreamsettings/processor_test.go @@ -6,7 +6,8 @@ import ( . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/http" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" @@ -23,18 +24,18 @@ func TestProcess(t *testing.T) { { name: "all fields populated", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - ZoneSize: helpers.GetPointer[ngfAPI.Size]("2m"), - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + ZoneSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("2m"), + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Connections: helpers.GetPointer(int32(1)), Requests: helpers.GetPointer(int32(1)), - Time: helpers.GetPointer[ngfAPI.Duration]("5s"), - Timeout: helpers.GetPointer[ngfAPI.Duration]("10s"), + Time: helpers.GetPointer[ngfAPIv1alpha1.Duration]("5s"), + Timeout: helpers.GetPointer[ngfAPIv1alpha1.Duration]("10s"), }), }, }, @@ -52,13 +53,13 @@ func TestProcess(t *testing.T) { { name: "zone size set", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - ZoneSize: helpers.GetPointer[ngfAPI.Size]("2m"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + ZoneSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("2m"), }, }, }, @@ -69,13 +70,13 @@ func TestProcess(t *testing.T) { { name: "keep alive connections set", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Connections: helpers.GetPointer(int32(1)), }), }, @@ -90,13 +91,13 @@ func TestProcess(t *testing.T) { { name: "keep alive requests set", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Requests: helpers.GetPointer(int32(1)), }), }, @@ -111,14 +112,14 @@ func TestProcess(t *testing.T) { { name: "keep alive time set", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Time: helpers.GetPointer[ngfAPI.Duration]("5s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Time: helpers.GetPointer[ngfAPIv1alpha1.Duration]("5s"), }), }, }, @@ -132,14 +133,14 @@ func TestProcess(t *testing.T) { { name: "keep alive timeout set", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Timeout: helpers.GetPointer[ngfAPI.Duration]("10s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Timeout: helpers.GetPointer[ngfAPIv1alpha1.Duration]("10s"), }), }, }, @@ -153,12 +154,12 @@ func TestProcess(t *testing.T) { { name: "no fields populated", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{}, + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{}, }, }, expUpstreamSettings: UpstreamSettings{}, @@ -166,56 +167,56 @@ func TestProcess(t *testing.T) { { name: "multiple UpstreamSettingsPolicies", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-zonesize", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - ZoneSize: helpers.GetPointer[ngfAPI.Size]("2m"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + ZoneSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("2m"), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-connections", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Connections: helpers.GetPointer(int32(1)), }), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-requests", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Requests: helpers.GetPointer(int32(1)), }), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-time", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Time: helpers.GetPointer[ngfAPI.Duration]("5s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Time: helpers.GetPointer[ngfAPIv1alpha1.Duration]("5s"), }), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-timeout", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Timeout: helpers.GetPointer[ngfAPI.Duration]("10s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Timeout: helpers.GetPointer[ngfAPIv1alpha1.Duration]("10s"), }), }, }, @@ -233,78 +234,78 @@ func TestProcess(t *testing.T) { { name: "multiple UpstreamSettingsPolicies along with other policies", policies: []policies.Policy{ - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-zonesize", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - ZoneSize: helpers.GetPointer[ngfAPI.Size]("2m"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + ZoneSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("2m"), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-connections", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Connections: helpers.GetPointer(int32(1)), }), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-requests", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ Requests: helpers.GetPointer(int32(1)), }), }, }, - &ngfAPI.ClientSettingsPolicy{ + &ngfAPIv1alpha1.ClientSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "client-settings-policy", Namespace: "test", }, - Spec: ngfAPI.ClientSettingsPolicySpec{ - Body: &ngfAPI.ClientBody{ - MaxSize: helpers.GetPointer[ngfAPI.Size]("1m"), + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ + Body: &ngfAPIv1alpha1.ClientBody{ + MaxSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("1m"), }, }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-time", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Time: helpers.GetPointer[ngfAPI.Duration]("5s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Time: helpers.GetPointer[ngfAPIv1alpha1.Duration]("5s"), }), }, }, - &ngfAPI.UpstreamSettingsPolicy{ + &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp-keepalive-timeout", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - KeepAlive: helpers.GetPointer(ngfAPI.UpstreamKeepAlive{ - Timeout: helpers.GetPointer[ngfAPI.Duration]("10s"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + KeepAlive: helpers.GetPointer(ngfAPIv1alpha1.UpstreamKeepAlive{ + Timeout: helpers.GetPointer[ngfAPIv1alpha1.Duration]("10s"), }), }, }, - &ngfAPI.ObservabilityPolicy{ + &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "observability-policy", Namespace: "test", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, Ratio: helpers.GetPointer(int32(1)), }, }, diff --git a/internal/mode/static/state/change_processor.go b/internal/mode/static/state/change_processor.go index 82edbcc7b..ebe2d304e 100644 --- a/internal/mode/static/state/change_processor.go +++ b/internal/mode/static/state/change_processor.go @@ -16,7 +16,8 @@ import ( "sigs.k8s.io/gateway-api/apis/v1alpha3" "sigs.k8s.io/gateway-api/apis/v1beta1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/gatewayclass" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/kinds" ngftypes "github.com/nginxinc/nginx-gateway-fabric/internal/framework/types" @@ -108,11 +109,11 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { CRDMetadata: make(map[types.NamespacedName]*metav1.PartialObjectMetadata), BackendTLSPolicies: make(map[types.NamespacedName]*v1alpha3.BackendTLSPolicy), ConfigMaps: make(map[types.NamespacedName]*apiv1.ConfigMap), - NginxProxies: make(map[types.NamespacedName]*ngfAPI.NginxProxy), + NginxProxies: make(map[types.NamespacedName]*ngfAPIv1alpha1.NginxProxy), GRPCRoutes: make(map[types.NamespacedName]*v1.GRPCRoute), TLSRoutes: make(map[types.NamespacedName]*v1alpha2.TLSRoute), NGFPolicies: make(map[graph.PolicyKey]policies.Policy), - SnippetsFilters: make(map[types.NamespacedName]*ngfAPI.SnippetsFilter), + SnippetsFilters: make(map[types.NamespacedName]*ngfAPIv1alpha1.SnippetsFilter), } processor := &ChangeProcessorImpl{ @@ -202,22 +203,22 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { predicate: annotationChangedPredicate{annotation: gatewayclass.BundleVersionAnnotation}, }, { - gvk: cfg.MustExtractGVK(&ngfAPI.NginxProxy{}), + gvk: cfg.MustExtractGVK(&ngfAPIv1alpha1.NginxProxy{}), store: newObjectStoreMapAdapter(clusterStore.NginxProxies), predicate: funcPredicate{stateChanged: isReferenced}, }, { - gvk: cfg.MustExtractGVK(&ngfAPI.ClientSettingsPolicy{}), + gvk: cfg.MustExtractGVK(&ngfAPIv1alpha1.ClientSettingsPolicy{}), store: commonPolicyObjectStore, predicate: funcPredicate{stateChanged: isNGFPolicyRelevant}, }, { - gvk: cfg.MustExtractGVK(&ngfAPI.ObservabilityPolicy{}), + gvk: cfg.MustExtractGVK(&ngfAPIv1alpha2.ObservabilityPolicy{}), store: commonPolicyObjectStore, predicate: funcPredicate{stateChanged: isNGFPolicyRelevant}, }, { - gvk: cfg.MustExtractGVK(&ngfAPI.UpstreamSettingsPolicy{}), + gvk: cfg.MustExtractGVK(&ngfAPIv1alpha1.UpstreamSettingsPolicy{}), store: commonPolicyObjectStore, predicate: funcPredicate{stateChanged: isNGFPolicyRelevant}, }, @@ -227,7 +228,7 @@ func NewChangeProcessorImpl(cfg ChangeProcessorConfig) *ChangeProcessorImpl { predicate: nil, }, { - gvk: cfg.MustExtractGVK(&ngfAPI.SnippetsFilter{}), + gvk: cfg.MustExtractGVK(&ngfAPIv1alpha1.SnippetsFilter{}), store: newObjectStoreMapAdapter(clusterStore.SnippetsFilters), predicate: nil, // we always want to write status to SnippetsFilters so we don't filter them out }, diff --git a/internal/mode/static/state/change_processor_test.go b/internal/mode/static/state/change_processor_test.go index 03d86a377..e4f05b3c3 100644 --- a/internal/mode/static/state/change_processor_test.go +++ b/internal/mode/static/state/change_processor_test.go @@ -19,7 +19,8 @@ import ( "sigs.k8s.io/gateway-api/apis/v1alpha3" "sigs.k8s.io/gateway-api/apis/v1beta1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/controller/index" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/gatewayclass" @@ -326,7 +327,8 @@ func createScheme() *runtime.Scheme { utilruntime.Must(apiv1.AddToScheme(scheme)) utilruntime.Must(discoveryV1.AddToScheme(scheme)) utilruntime.Must(apiext.AddToScheme(scheme)) - utilruntime.Must(ngfAPI.AddToScheme(scheme)) + utilruntime.Must(ngfAPIv1alpha1.AddToScheme(scheme)) + utilruntime.Must(ngfAPIv1alpha2.AddToScheme(scheme)) return scheme } @@ -2291,28 +2293,28 @@ var _ = Describe("ChangeProcessor", func() { Describe("NginxProxy resource changes", Ordered, func() { paramGC := gc.DeepCopy() paramGC.Spec.ParametersRef = &v1beta1.ParametersReference{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.NginxProxy, Name: "np", } - np := &ngfAPI.NginxProxy{ + np := &ngfAPIv1alpha1.NginxProxy{ ObjectMeta: metav1.ObjectMeta{ Name: "np", }, } - npUpdated := &ngfAPI.NginxProxy{ + npUpdated := &ngfAPIv1alpha1.NginxProxy{ ObjectMeta: metav1.ObjectMeta{ Name: "np", }, - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{ - Exporter: &ngfAPI.TelemetryExporter{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{ + Exporter: &ngfAPIv1alpha1.TelemetryExporter{ Endpoint: "my-svc:123", BatchSize: helpers.GetPointer(int32(512)), BatchCount: helpers.GetPointer(int32(4)), - Interval: helpers.GetPointer(ngfAPI.Duration("5s")), + Interval: helpers.GetPointer(ngfAPIv1alpha1.Duration("5s")), }, }, }, @@ -2347,9 +2349,9 @@ var _ = Describe("ChangeProcessor", func() { gw *v1.Gateway route *v1.HTTPRoute svc *apiv1.Service - csp, cspUpdated *ngfAPI.ClientSettingsPolicy - obs, obsUpdated *ngfAPI.ObservabilityPolicy - usp, uspUpdated *ngfAPI.UpstreamSettingsPolicy + csp, cspUpdated *ngfAPIv1alpha1.ClientSettingsPolicy + obs, obsUpdated *ngfAPIv1alpha2.ObservabilityPolicy + usp, uspUpdated *ngfAPIv1alpha1.UpstreamSettingsPolicy cspKey, obsKey, uspKey graph.PolicyKey ) @@ -2384,41 +2386,41 @@ var _ = Describe("ChangeProcessor", func() { }, } - csp = &ngfAPI.ClientSettingsPolicy{ + csp = &ngfAPIv1alpha1.ClientSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "csp", Namespace: "test", }, - Spec: ngfAPI.ClientSettingsPolicySpec{ + Spec: ngfAPIv1alpha1.ClientSettingsPolicySpec{ TargetRef: v1alpha2.LocalPolicyTargetReference{ Group: v1.GroupName, Kind: kinds.Gateway, Name: "gw", }, - Body: &ngfAPI.ClientBody{ - MaxSize: helpers.GetPointer[ngfAPI.Size]("10m"), + Body: &ngfAPIv1alpha1.ClientBody{ + MaxSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("10m"), }, }, } cspUpdated = csp.DeepCopy() - cspUpdated.Spec.Body.MaxSize = helpers.GetPointer[ngfAPI.Size]("20m") + cspUpdated.Spec.Body.MaxSize = helpers.GetPointer[ngfAPIv1alpha1.Size]("20m") cspKey = graph.PolicyKey{ NsName: types.NamespacedName{Name: "csp", Namespace: "test"}, GVK: schema.GroupVersionKind{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.ClientSettingsPolicy, Version: "v1alpha1", }, } - obs = &ngfAPI.ObservabilityPolicy{ + obs = &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obs", Namespace: "test", }, - Spec: ngfAPI.ObservabilityPolicySpec{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ TargetRefs: []v1alpha2.LocalPolicyTargetReference{ { Group: v1.GroupName, @@ -2426,31 +2428,31 @@ var _ = Describe("ChangeProcessor", func() { Name: "hr-1", }, }, - Tracing: &ngfAPI.Tracing{ - Strategy: ngfAPI.TraceStrategyRatio, + Tracing: &ngfAPIv1alpha2.Tracing{ + Strategy: ngfAPIv1alpha2.TraceStrategyRatio, }, }, } obsUpdated = obs.DeepCopy() - obsUpdated.Spec.Tracing.Strategy = ngfAPI.TraceStrategyParent + obsUpdated.Spec.Tracing.Strategy = ngfAPIv1alpha2.TraceStrategyParent obsKey = graph.PolicyKey{ NsName: types.NamespacedName{Name: "obs", Namespace: "test"}, GVK: schema.GroupVersionKind{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.ObservabilityPolicy, - Version: "v1alpha1", + Version: "v1alpha2", }, } - usp = &ngfAPI.UpstreamSettingsPolicy{ + usp = &ngfAPIv1alpha1.UpstreamSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "usp", Namespace: "test", }, - Spec: ngfAPI.UpstreamSettingsPolicySpec{ - ZoneSize: helpers.GetPointer[ngfAPI.Size]("10m"), + Spec: ngfAPIv1alpha1.UpstreamSettingsPolicySpec{ + ZoneSize: helpers.GetPointer[ngfAPIv1alpha1.Size]("10m"), TargetRefs: []v1alpha2.LocalPolicyTargetReference{ { Group: "core", @@ -2462,12 +2464,12 @@ var _ = Describe("ChangeProcessor", func() { } uspUpdated = usp.DeepCopy() - uspUpdated.Spec.ZoneSize = helpers.GetPointer[ngfAPI.Size]("20m") + uspUpdated.Spec.ZoneSize = helpers.GetPointer[ngfAPIv1alpha1.Size]("20m") uspKey = graph.PolicyKey{ NsName: types.NamespacedName{Name: "usp", Namespace: "test"}, GVK: schema.GroupVersionKind{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.UpstreamSettingsPolicy, Version: "v1alpha1", }, @@ -2531,9 +2533,9 @@ var _ = Describe("ChangeProcessor", func() { }) When("the policy is deleted", func() { It("removes the policy from the graph", func() { - processor.CaptureDeleteChange(&ngfAPI.ClientSettingsPolicy{}, client.ObjectKeyFromObject(csp)) - processor.CaptureDeleteChange(&ngfAPI.ObservabilityPolicy{}, client.ObjectKeyFromObject(obs)) - processor.CaptureDeleteChange(&ngfAPI.UpstreamSettingsPolicy{}, client.ObjectKeyFromObject(usp)) + processor.CaptureDeleteChange(&ngfAPIv1alpha1.ClientSettingsPolicy{}, client.ObjectKeyFromObject(csp)) + processor.CaptureDeleteChange(&ngfAPIv1alpha2.ObservabilityPolicy{}, client.ObjectKeyFromObject(obs)) + processor.CaptureDeleteChange(&ngfAPIv1alpha1.UpstreamSettingsPolicy{}, client.ObjectKeyFromObject(usp)) changed, graph := processor.Process() Expect(changed).To(Equal(state.ClusterStateChange)) @@ -2548,34 +2550,34 @@ var _ = Describe("ChangeProcessor", func() { Namespace: "test", } - sf := &ngfAPI.SnippetsFilter{ + sf := &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: sfNsName.Name, Namespace: sfNsName.Namespace, }, - Spec: ngfAPI.SnippetsFilterSpec{ - Snippets: []ngfAPI.Snippet{ + Spec: ngfAPIv1alpha1.SnippetsFilterSpec{ + Snippets: []ngfAPIv1alpha1.Snippet{ { - Context: ngfAPI.NginxContextMain, + Context: ngfAPIv1alpha1.NginxContextMain, Value: "main snippet", }, }, }, } - sfUpdated := &ngfAPI.SnippetsFilter{ + sfUpdated := &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: sfNsName.Name, Namespace: sfNsName.Namespace, }, - Spec: ngfAPI.SnippetsFilterSpec{ - Snippets: []ngfAPI.Snippet{ + Spec: ngfAPIv1alpha1.SnippetsFilterSpec{ + Snippets: []ngfAPIv1alpha1.Snippet{ { - Context: ngfAPI.NginxContextMain, + Context: ngfAPIv1alpha1.NginxContextMain, Value: "main snippet", }, { - Context: ngfAPI.NginxContextHTTP, + Context: ngfAPIv1alpha1.NginxContextHTTP, Value: "http snippet", }, }, @@ -2631,7 +2633,7 @@ var _ = Describe("ChangeProcessor", func() { secret, secretUpdated, unrelatedSecret, barSecret, barSecretUpdated *apiv1.Secret cm, cmUpdated, unrelatedCM *apiv1.ConfigMap btls, btlsUpdated *v1alpha3.BackendTLSPolicy - np, npUpdated *ngfAPI.NginxProxy + np, npUpdated *ngfAPIv1alpha1.NginxProxy ) BeforeEach(OncePerOrdered, func() { @@ -2930,12 +2932,12 @@ var _ = Describe("ChangeProcessor", func() { btlsUpdated = btls.DeepCopy() npNsName = types.NamespacedName{Name: "np-1"} - np = &ngfAPI.NginxProxy{ + np = &ngfAPIv1alpha1.NginxProxy{ ObjectMeta: metav1.ObjectMeta{ Name: npNsName.Name, }, - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{ ServiceName: helpers.GetPointer("my-svc"), }, }, @@ -3010,7 +3012,7 @@ var _ = Describe("ChangeProcessor", func() { processor.CaptureDeleteChange(&v1beta1.ReferenceGrant{}, rgNsName) processor.CaptureDeleteChange(&v1alpha3.BackendTLSPolicy{}, btlsNsName) processor.CaptureDeleteChange(&apiv1.ConfigMap{}, cmNsName) - processor.CaptureDeleteChange(&ngfAPI.NginxProxy{}, npNsName) + processor.CaptureDeleteChange(&ngfAPIv1alpha1.NginxProxy{}, npNsName) // these are non-changing changes processor.CaptureUpsertChange(gw2) diff --git a/internal/mode/static/state/dataplane/configuration.go b/internal/mode/static/state/dataplane/configuration.go index cafcbc0db..54c622c55 100644 --- a/internal/mode/static/state/dataplane/configuration.go +++ b/internal/mode/static/state/dataplane/configuration.go @@ -13,7 +13,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" v1 "sigs.k8s.io/gateway-api/apis/v1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/graph" @@ -62,7 +63,7 @@ func BuildConfiguration( Telemetry: buildTelemetry(g), BaseHTTPConfig: baseHTTPConfig, Logging: buildLogging(g), - MainSnippets: buildSnippetsForContext(g.SnippetsFilters, ngfAPI.NginxContextMain), + MainSnippets: buildSnippetsForContext(g.SnippetsFilters, ngfAPIv1alpha1.NginxContextMain), AuxiliarySecrets: buildAuxiliarySecrets(g.PlusSecrets), } @@ -809,7 +810,7 @@ func buildTelemetry(g *graph.Graph) Telemetry { // logic in this function ratioMap := make(map[string]int32) for _, pol := range g.NGFPolicies { - if obsPol, ok := pol.Source.(*ngfAPI.ObservabilityPolicy); ok { + if obsPol, ok := pol.Source.(*ngfAPIv1alpha2.ObservabilityPolicy); ok { if obsPol.Spec.Tracing != nil && obsPol.Spec.Tracing.Ratio != nil && *obsPol.Spec.Tracing.Ratio > 0 { ratioName := CreateRatioVarName(*obsPol.Spec.Tracing.Ratio) ratioMap[ratioName] = *obsPol.Spec.Tracing.Ratio @@ -825,7 +826,7 @@ func buildTelemetry(g *graph.Graph) Telemetry { return tel } -func setSpanAttributes(spanAttributes []ngfAPI.SpanAttribute) []SpanAttribute { +func setSpanAttributes(spanAttributes []ngfAPIv1alpha1.SpanAttribute) []SpanAttribute { spanAttrs := make([]SpanAttribute, 0, len(spanAttributes)) for _, spanAttr := range spanAttributes { sa := SpanAttribute{ @@ -850,7 +851,7 @@ func buildBaseHTTPConfig(g *graph.Graph) BaseHTTPConfig { // HTTP2 should be enabled by default HTTP2: true, IPFamily: Dual, - Snippets: buildSnippetsForContext(g.SnippetsFilters, ngfAPI.NginxContextHTTP), + Snippets: buildSnippetsForContext(g.SnippetsFilters, ngfAPIv1alpha1.NginxContextHTTP), } if g.NginxProxy == nil || !g.NginxProxy.Valid { return baseConfig @@ -862,9 +863,9 @@ func buildBaseHTTPConfig(g *graph.Graph) BaseHTTPConfig { if g.NginxProxy.Source.Spec.IPFamily != nil { switch *g.NginxProxy.Source.Spec.IPFamily { - case ngfAPI.IPv4: + case ngfAPIv1alpha1.IPv4: baseConfig.IPFamily = IPv4 - case ngfAPI.IPv6: + case ngfAPIv1alpha1.IPv6: baseConfig.IPFamily = IPv6 } } @@ -872,9 +873,9 @@ func buildBaseHTTPConfig(g *graph.Graph) BaseHTTPConfig { if g.NginxProxy.Source.Spec.RewriteClientIP != nil { if g.NginxProxy.Source.Spec.RewriteClientIP.Mode != nil { switch *g.NginxProxy.Source.Spec.RewriteClientIP.Mode { - case ngfAPI.RewriteClientIPModeProxyProtocol: + case ngfAPIv1alpha1.RewriteClientIPModeProxyProtocol: baseConfig.RewriteClientIPSettings.Mode = RewriteIPModeProxyProtocol - case ngfAPI.RewriteClientIPModeXForwardedFor: + case ngfAPIv1alpha1.RewriteClientIPModeXForwardedFor: baseConfig.RewriteClientIPSettings.Mode = RewriteIPModeXForwardedFor } } @@ -893,7 +894,7 @@ func buildBaseHTTPConfig(g *graph.Graph) BaseHTTPConfig { return baseConfig } -func createSnippetName(nc ngfAPI.NginxContext, nsname types.NamespacedName) string { +func createSnippetName(nc ngfAPIv1alpha1.NginxContext, nsname types.NamespacedName) string { return fmt.Sprintf( "SnippetsFilter_%s_%s_%s", nc, @@ -904,7 +905,7 @@ func createSnippetName(nc ngfAPI.NginxContext, nsname types.NamespacedName) stri func buildSnippetsForContext( snippetFilters map[types.NamespacedName]*graph.SnippetsFilter, - nc ngfAPI.NginxContext, + nc ngfAPIv1alpha1.NginxContext, ) []Snippet { if len(snippetFilters) == 0 { return nil @@ -950,7 +951,7 @@ func buildPolicies(graphPolicies []*graph.Policy) []policies.Policy { return finalPolicies } -func convertAddresses(addresses []ngfAPI.Address) []string { +func convertAddresses(addresses []ngfAPIv1alpha1.Address) []string { trustedAddresses := make([]string, len(addresses)) for i, addr := range addresses { trustedAddresses[i] = addr.Value diff --git a/internal/mode/static/state/dataplane/configuration_test.go b/internal/mode/static/state/dataplane/configuration_test.go index 037bcd7d9..55a5438b2 100644 --- a/internal/mode/static/state/dataplane/configuration_test.go +++ b/internal/mode/static/state/dataplane/configuration_test.go @@ -19,7 +19,8 @@ import ( "sigs.k8s.io/gateway-api/apis/v1alpha2" "sigs.k8s.io/gateway-api/apis/v1alpha3" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/helpers" "github.com/nginxinc/nginx-gateway-fabric/internal/framework/kinds" "github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/nginx/config/policies" @@ -337,7 +338,7 @@ func TestBuildConfiguration(t *testing.T) { ) sf1 := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "sf", Namespace: "test", @@ -345,16 +346,16 @@ func TestBuildConfiguration(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "location snippet", - ngfAPI.NginxContextHTTPServer: "server snippet", - ngfAPI.NginxContextMain: "main snippet", - ngfAPI.NginxContextHTTP: "http snippet", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "location snippet", + ngfAPIv1alpha1.NginxContextHTTPServer: "server snippet", + ngfAPIv1alpha1.NginxContextMain: "main snippet", + ngfAPIv1alpha1.NginxContextHTTP: "http snippet", }, } sfNotReferenced := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "sf-not-referenced", Namespace: "test", @@ -362,9 +363,9 @@ func TestBuildConfiguration(t *testing.T) { }, Valid: true, Referenced: false, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextMain: "main snippet no ref", - ngfAPI.NginxContextHTTP: "http snippet no ref", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextMain: "main snippet no ref", + ngfAPIv1alpha1.NginxContextHTTP: "http snippet no ref", }, } @@ -377,7 +378,7 @@ func TestBuildConfiguration(t *testing.T) { extRefFilter := graph.Filter{ FilterType: graph.FilterExtensionRef, ExtensionRef: &v1.LocalObjectReference{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.SnippetsFilter, Name: "sf", }, @@ -393,14 +394,14 @@ func TestBuildConfiguration(t *testing.T) { expExtRefFilter := SnippetsFilter{ LocationSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServerLocation, + ngfAPIv1alpha1.NginxContextHTTPServerLocation, client.ObjectKeyFromObject(extRefFilter.ResolvedExtensionRef.SnippetsFilter.Source), ), Contents: "location snippet", }, ServerSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServer, + ngfAPIv1alpha1.NginxContextHTTPServer, client.ObjectKeyFromObject(extRefFilter.ResolvedExtensionRef.SnippetsFilter.Source), ), Contents: "server snippet", @@ -826,39 +827,39 @@ func TestBuildConfiguration(t *testing.T) { } nginxProxy := &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{ - Exporter: &ngfAPI.TelemetryExporter{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{ + Exporter: &ngfAPIv1alpha1.TelemetryExporter{ Endpoint: "my-otel.svc:4563", BatchSize: helpers.GetPointer(int32(512)), BatchCount: helpers.GetPointer(int32(4)), - Interval: helpers.GetPointer(ngfAPI.Duration("5s")), + Interval: helpers.GetPointer(ngfAPIv1alpha1.Duration("5s")), }, ServiceName: helpers.GetPointer("my-svc"), }, DisableHTTP2: true, - IPFamily: helpers.GetPointer(ngfAPI.Dual), + IPFamily: helpers.GetPointer(ngfAPIv1alpha1.Dual), }, }, Valid: true, } nginxProxyIPv4 := &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{}, - IPFamily: helpers.GetPointer(ngfAPI.IPv4), + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{}, + IPFamily: helpers.GetPointer(ngfAPIv1alpha1.IPv4), }, }, Valid: true, } nginxProxyIPv6 := &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{}, - IPFamily: helpers.GetPointer(ngfAPI.IPv6), + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{}, + IPFamily: helpers.GetPointer(ngfAPIv1alpha1.IPv6), }, }, Valid: true, @@ -2090,12 +2091,12 @@ func TestBuildConfiguration(t *testing.T) { }) g.NginxProxy = &graph.NginxProxy{ Valid: false, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ DisableHTTP2: true, - IPFamily: helpers.GetPointer(ngfAPI.Dual), - Telemetry: &ngfAPI.Telemetry{ - Exporter: &ngfAPI.TelemetryExporter{ + IPFamily: helpers.GetPointer(ngfAPIv1alpha1.Dual), + Telemetry: &ngfAPIv1alpha1.Telemetry{ + Exporter: &ngfAPIv1alpha1.TelemetryExporter{ Endpoint: "some-endpoint", }, }, @@ -2266,17 +2267,17 @@ func TestBuildConfiguration(t *testing.T) { }) g.NginxProxy = &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - RewriteClientIP: &ngfAPI.RewriteClientIP{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + RewriteClientIP: &ngfAPIv1alpha1.RewriteClientIP{ SetIPRecursively: helpers.GetPointer(true), - TrustedAddresses: []ngfAPI.Address{ + TrustedAddresses: []ngfAPIv1alpha1.Address{ { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "1.1.1.1/32", }, }, - Mode: helpers.GetPointer(ngfAPI.RewriteClientIPModeProxyProtocol), + Mode: helpers.GetPointer(ngfAPIv1alpha1.RewriteClientIPModeProxyProtocol), }, }, }, @@ -2313,9 +2314,9 @@ func TestBuildConfiguration(t *testing.T) { }) g.NginxProxy = &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelDebug)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelDebug)}, }, }, } @@ -2342,7 +2343,7 @@ func TestBuildConfiguration(t *testing.T) { conf.MainSnippets = []Snippet{ { Name: createSnippetName( - ngfAPI.NginxContextMain, + ngfAPIv1alpha1.NginxContextMain, client.ObjectKeyFromObject(sf1.Source), ), Contents: "main snippet", @@ -2351,7 +2352,7 @@ func TestBuildConfiguration(t *testing.T) { conf.BaseHTTPConfig.Snippets = []Snippet{ { Name: createSnippetName( - ngfAPI.NginxContextHTTP, + ngfAPIv1alpha1.NginxContextHTTP, client.ObjectKeyFromObject(sf1.Source), ), Contents: "http snippet", @@ -2534,14 +2535,14 @@ func TestCreateFilters(t *testing.T) { snippetsFilter1 := graph.Filter{ FilterType: graph.FilterExtensionRef, ExtensionRef: &v1.LocalObjectReference{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.SnippetsFilter, Name: "sf1", }, ResolvedExtensionRef: &graph.ExtensionRefFilter{ Valid: true, SnippetsFilter: &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "sf1", Namespace: "default", @@ -2549,11 +2550,11 @@ func TestCreateFilters(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "location snippet 1", - ngfAPI.NginxContextMain: "main snippet 1", - ngfAPI.NginxContextHTTPServer: "server snippet 1", - ngfAPI.NginxContextHTTP: "http snippet 1", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "location snippet 1", + ngfAPIv1alpha1.NginxContextMain: "main snippet 1", + ngfAPIv1alpha1.NginxContextHTTPServer: "server snippet 1", + ngfAPIv1alpha1.NginxContextHTTP: "http snippet 1", }, }, }, @@ -2562,14 +2563,14 @@ func TestCreateFilters(t *testing.T) { snippetsFilter2 := graph.Filter{ FilterType: graph.FilterExtensionRef, ExtensionRef: &v1.LocalObjectReference{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: kinds.SnippetsFilter, Name: "sf2", }, ResolvedExtensionRef: &graph.ExtensionRefFilter{ Valid: true, SnippetsFilter: &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "sf2", Namespace: "default", @@ -2577,11 +2578,11 @@ func TestCreateFilters(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "location snippet 2", - ngfAPI.NginxContextMain: "main snippet 2", - ngfAPI.NginxContextHTTPServer: "server snippet 2", - ngfAPI.NginxContextHTTP: "http snippet 2", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "location snippet 2", + ngfAPIv1alpha1.NginxContextMain: "main snippet 2", + ngfAPIv1alpha1.NginxContextHTTPServer: "server snippet 2", + ngfAPIv1alpha1.NginxContextHTTP: "http snippet 2", }, }, }, @@ -2628,14 +2629,14 @@ func TestCreateFilters(t *testing.T) { { LocationSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServerLocation, + ngfAPIv1alpha1.NginxContextHTTPServerLocation, types.NamespacedName{Namespace: "default", Name: "sf1"}, ), Contents: "location snippet 1", }, ServerSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServer, + ngfAPIv1alpha1.NginxContextHTTPServer, types.NamespacedName{Namespace: "default", Name: "sf1"}, ), Contents: "server snippet 1", @@ -2644,14 +2645,14 @@ func TestCreateFilters(t *testing.T) { { LocationSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServerLocation, + ngfAPIv1alpha1.NginxContextHTTPServerLocation, types.NamespacedName{Namespace: "default", Name: "sf2"}, ), Contents: "location snippet 2", }, ServerSnippet: &Snippet{ Name: createSnippetName( - ngfAPI.NginxContextHTTPServer, + ngfAPIv1alpha1.NginxContextHTTPServer, types.NamespacedName{Namespace: "default", Name: "sf2"}, ), Contents: "server snippet 2", @@ -3278,17 +3279,17 @@ func TestConvertBackendTLS(t *testing.T) { func TestBuildTelemetry(t *testing.T) { t.Parallel() telemetryConfigured := &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{ - Exporter: &ngfAPI.TelemetryExporter{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{ + Exporter: &ngfAPIv1alpha1.TelemetryExporter{ Endpoint: "my-otel.svc:4563", BatchSize: helpers.GetPointer(int32(512)), BatchCount: helpers.GetPointer(int32(4)), - Interval: helpers.GetPointer(ngfAPI.Duration("5s")), + Interval: helpers.GetPointer(ngfAPIv1alpha1.Duration("5s")), }, ServiceName: helpers.GetPointer("my-svc"), - SpanAttributes: []ngfAPI.SpanAttribute{ + SpanAttributes: []ngfAPIv1alpha1.SpanAttribute{ {Key: "key", Value: "value"}, }, }, @@ -3323,7 +3324,7 @@ func TestBuildTelemetry(t *testing.T) { { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{}, + Source: &ngfAPIv1alpha1.NginxProxy{}, }, }, expTelemetry: Telemetry{}, @@ -3332,10 +3333,10 @@ func TestBuildTelemetry(t *testing.T) { { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Telemetry: &ngfAPI.Telemetry{ - Exporter: &ngfAPI.TelemetryExporter{}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Telemetry: &ngfAPIv1alpha1.Telemetry{ + Exporter: &ngfAPIv1alpha1.TelemetryExporter{}, }, }, }, @@ -3373,13 +3374,13 @@ func TestBuildTelemetry(t *testing.T) { NginxProxy: telemetryConfigured, NGFPolicies: map[graph.PolicyKey]*graph.Policy{ {NsName: types.NamespacedName{Name: "obsPolicy"}}: { - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obsPolicy", Namespace: "custom-ns", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Ratio: helpers.GetPointer[int32](25), }, }, @@ -3408,46 +3409,46 @@ func TestBuildTelemetry(t *testing.T) { NginxProxy: telemetryConfigured, NGFPolicies: map[graph.PolicyKey]*graph.Policy{ {NsName: types.NamespacedName{Name: "obsPolicy"}}: { - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obsPolicy", Namespace: "custom-ns", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Ratio: helpers.GetPointer[int32](25), }, }, }, }, {NsName: types.NamespacedName{Name: "obsPolicy2"}}: { - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obsPolicy2", Namespace: "custom-ns", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Ratio: helpers.GetPointer[int32](50), }, }, }, }, {NsName: types.NamespacedName{Name: "obsPolicy3"}}: { - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obsPolicy3", Namespace: "custom-ns", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Ratio: helpers.GetPointer[int32](25), }, }, }, }, {NsName: types.NamespacedName{Name: "csPolicy"}}: { - Source: &ngfAPI.ClientSettingsPolicy{ + Source: &ngfAPIv1alpha1.ClientSettingsPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "csPolicy", Namespace: "custom-ns", @@ -3478,13 +3479,13 @@ func TestBuildTelemetry(t *testing.T) { NginxProxy: telemetryConfigured, NGFPolicies: map[graph.PolicyKey]*graph.Policy{ {NsName: types.NamespacedName{Name: "obsPolicy"}}: { - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ ObjectMeta: metav1.ObjectMeta{ Name: "obsPolicy", Namespace: "custom-ns", }, - Spec: ngfAPI.ObservabilityPolicySpec{ - Tracing: &ngfAPI.Tracing{ + Spec: ngfAPIv1alpha2.ObservabilityPolicySpec{ + Tracing: &ngfAPIv1alpha2.Tracing{ Ratio: helpers.GetPointer[int32](0), }, }, @@ -3913,7 +3914,7 @@ func TestBuildRewriteIPSettings(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{}, + Source: &ngfAPIv1alpha1.NginxProxy{}, }, }, expRewriteIPSettings: RewriteClientIPSettings{}, @@ -3923,13 +3924,13 @@ func TestBuildRewriteIPSettings(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - RewriteClientIP: &ngfAPI.RewriteClientIP{ - Mode: helpers.GetPointer(ngfAPI.RewriteClientIPModeProxyProtocol), - TrustedAddresses: []ngfAPI.Address{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + RewriteClientIP: &ngfAPIv1alpha1.RewriteClientIP{ + Mode: helpers.GetPointer(ngfAPIv1alpha1.RewriteClientIPModeProxyProtocol), + TrustedAddresses: []ngfAPIv1alpha1.Address{ { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "10.9.9.4/32", }, }, @@ -3950,13 +3951,13 @@ func TestBuildRewriteIPSettings(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - RewriteClientIP: &ngfAPI.RewriteClientIP{ - Mode: helpers.GetPointer(ngfAPI.RewriteClientIPModeXForwardedFor), - TrustedAddresses: []ngfAPI.Address{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + RewriteClientIP: &ngfAPIv1alpha1.RewriteClientIP{ + Mode: helpers.GetPointer(ngfAPIv1alpha1.RewriteClientIPModeXForwardedFor), + TrustedAddresses: []ngfAPIv1alpha1.Address{ { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "76.89.90.11/24", }, }, @@ -3977,25 +3978,25 @@ func TestBuildRewriteIPSettings(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - RewriteClientIP: &ngfAPI.RewriteClientIP{ - Mode: helpers.GetPointer(ngfAPI.RewriteClientIPModeXForwardedFor), - TrustedAddresses: []ngfAPI.Address{ + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + RewriteClientIP: &ngfAPIv1alpha1.RewriteClientIP{ + Mode: helpers.GetPointer(ngfAPIv1alpha1.RewriteClientIPModeXForwardedFor), + TrustedAddresses: []ngfAPIv1alpha1.Address{ { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "5.5.5.5/12", }, { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "1.1.1.1/26", }, { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "2.2.2.2/32", }, { - Type: ngfAPI.CIDRAddressType, + Type: ngfAPIv1alpha1.CIDRAddressType, Value: "3.3.3.3/24", }, }, @@ -4042,8 +4043,8 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{}, }, }, }, @@ -4054,9 +4055,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelDebug)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelDebug)}, }, }, }, @@ -4068,9 +4069,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelInfo)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelInfo)}, }, }, }, @@ -4082,9 +4083,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelNotice)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelNotice)}, }, }, }, @@ -4096,9 +4097,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelWarn)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelWarn)}, }, }, }, @@ -4110,9 +4111,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelError)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelError)}, }, }, }, @@ -4124,9 +4125,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelCrit)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelCrit)}, }, }, }, @@ -4138,9 +4139,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelAlert)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelAlert)}, }, }, }, @@ -4152,9 +4153,9 @@ func TestBuildLogging(t *testing.T) { g: &graph.Graph{ NginxProxy: &graph.NginxProxy{ Valid: true, - Source: &ngfAPI.NginxProxy{ - Spec: ngfAPI.NginxProxySpec{ - Logging: &ngfAPI.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPI.NginxLogLevelEmerg)}, + Source: &ngfAPIv1alpha1.NginxProxy{ + Spec: ngfAPIv1alpha1.NginxProxySpec{ + Logging: &ngfAPIv1alpha1.NginxLogging{ErrorLevel: helpers.GetPointer(ngfAPIv1alpha1.NginxLogLevelEmerg)}, }, }, }, @@ -4179,7 +4180,7 @@ func TestCreateSnippetName(t *testing.T) { g := NewWithT(t) name := createSnippetName( - ngfAPI.NginxContextHTTPServerLocation, + ngfAPIv1alpha1.NginxContextHTTPServerLocation, types.NamespacedName{Namespace: "some-ns", Name: "some-name"}, ) g.Expect(name).To(Equal("SnippetsFilter_http.server.location_some-ns_some-name")) @@ -4189,7 +4190,7 @@ func TestBuildSnippetForContext(t *testing.T) { t.Parallel() validUnreferenced := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-unreferenced", Namespace: "default", @@ -4197,13 +4198,13 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: true, Referenced: false, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "valid unreferenced", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "valid unreferenced", }, } invalidUnreferenced := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "invalid-unreferenced", Namespace: "default", @@ -4211,13 +4212,13 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: false, Referenced: false, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "invalid unreferenced", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "invalid unreferenced", }, } invalidReferenced := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "invalid-referenced", Namespace: "default", @@ -4225,13 +4226,13 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: false, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "invalid referenced", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "invalid referenced", }, } validReferenced1 := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-referenced1", Namespace: "default", @@ -4239,14 +4240,14 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTP: "http valid referenced 1", - ngfAPI.NginxContextMain: "main valid referenced 1", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTP: "http valid referenced 1", + ngfAPIv1alpha1.NginxContextMain: "main valid referenced 1", }, } validReferenced2 := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-referenced2", Namespace: "other-ns", @@ -4254,14 +4255,14 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextMain: "main valid referenced 2", - ngfAPI.NginxContextHTTP: "http valid referenced 2", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextMain: "main valid referenced 2", + ngfAPIv1alpha1.NginxContextHTTP: "http valid referenced 2", }, } validReferenced3 := &graph.SnippetsFilter{ - Source: &ngfAPI.SnippetsFilter{ + Source: &ngfAPIv1alpha1.SnippetsFilter{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-referenced3", Namespace: "other-ns", @@ -4269,29 +4270,29 @@ func TestBuildSnippetForContext(t *testing.T) { }, Valid: true, Referenced: true, - Snippets: map[ngfAPI.NginxContext]string{ - ngfAPI.NginxContextHTTPServerLocation: "location valid referenced 2", + Snippets: map[ngfAPIv1alpha1.NginxContext]string{ + ngfAPIv1alpha1.NginxContextHTTPServerLocation: "location valid referenced 2", }, } expMainSnippets := []Snippet{ { - Name: createSnippetName(ngfAPI.NginxContextMain, client.ObjectKeyFromObject(validReferenced1.Source)), + Name: createSnippetName(ngfAPIv1alpha1.NginxContextMain, client.ObjectKeyFromObject(validReferenced1.Source)), Contents: "main valid referenced 1", }, { - Name: createSnippetName(ngfAPI.NginxContextMain, client.ObjectKeyFromObject(validReferenced2.Source)), + Name: createSnippetName(ngfAPIv1alpha1.NginxContextMain, client.ObjectKeyFromObject(validReferenced2.Source)), Contents: "main valid referenced 2", }, } expHTTPSnippets := []Snippet{ { - Name: createSnippetName(ngfAPI.NginxContextHTTP, client.ObjectKeyFromObject(validReferenced1.Source)), + Name: createSnippetName(ngfAPIv1alpha1.NginxContextHTTP, client.ObjectKeyFromObject(validReferenced1.Source)), Contents: "http valid referenced 1", }, { - Name: createSnippetName(ngfAPI.NginxContextHTTP, client.ObjectKeyFromObject(validReferenced2.Source)), + Name: createSnippetName(ngfAPIv1alpha1.NginxContextHTTP, client.ObjectKeyFromObject(validReferenced2.Source)), Contents: "http valid referenced 2", }, } @@ -4310,25 +4311,25 @@ func TestBuildSnippetForContext(t *testing.T) { tests := []struct { name string snippetsFilters map[types.NamespacedName]*graph.SnippetsFilter - ctx ngfAPI.NginxContext + ctx ngfAPIv1alpha1.NginxContext expSnippets []Snippet }{ { name: "no snippets filters", snippetsFilters: nil, - ctx: ngfAPI.NginxContextMain, + ctx: ngfAPIv1alpha1.NginxContextMain, expSnippets: nil, }, { name: "main context: mix of invalid, unreferenced, and valid, referenced snippets filters", snippetsFilters: getSnippetsFilters(), - ctx: ngfAPI.NginxContextMain, + ctx: ngfAPIv1alpha1.NginxContextMain, expSnippets: expMainSnippets, }, { name: "http context: mix of invalid, unreferenced, and valid, referenced snippets filters", snippetsFilters: getSnippetsFilters(), - ctx: ngfAPI.NginxContextHTTP, + ctx: ngfAPIv1alpha1.NginxContextHTTP, expSnippets: expHTTPSnippets, }, } diff --git a/internal/mode/static/state/graph/policy_ancestor_test.go b/internal/mode/static/state/graph/policy_ancestor_test.go index 0b34f8e1e..dcf492121 100644 --- a/internal/mode/static/state/graph/policy_ancestor_test.go +++ b/internal/mode/static/state/graph/policy_ancestor_test.go @@ -8,7 +8,7 @@ import ( v1 "sigs.k8s.io/gateway-api/apis/v1" "sigs.k8s.io/gateway-api/apis/v1alpha2" - ngfAPI "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/kinds" ) @@ -90,7 +90,7 @@ func TestNGFPolicyAncestorsFull(t *testing.T) { } return &Policy{ - Source: &ngfAPI.ObservabilityPolicy{ + Source: &ngfAPIv1alpha2.ObservabilityPolicy{ Status: v1alpha2.PolicyStatus{ Ancestors: currAncestors, }, diff --git a/tests/suite/system_suite_test.go b/tests/suite/system_suite_test.go index cb8640abf..ba9f8b168 100644 --- a/tests/suite/system_suite_test.go +++ b/tests/suite/system_suite_test.go @@ -31,7 +31,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log" v1 "sigs.k8s.io/gateway-api/apis/v1" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + ngfAPIv1alpha1 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + ngfAPIv1alpha2 "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha2" "github.com/nginxinc/nginx-gateway-fabric/tests/framework" ) @@ -117,7 +118,8 @@ func setup(cfg setupConfig, extraInstallArgs ...string) { Expect(coordination.AddToScheme(scheme)).To(Succeed()) Expect(v1.Install(scheme)).To(Succeed()) Expect(batchv1.AddToScheme(scheme)).To(Succeed()) - Expect(ngfAPI.AddToScheme(scheme)).To(Succeed()) + Expect(ngfAPIv1alpha1.AddToScheme(scheme)).To(Succeed()) + Expect(ngfAPIv1alpha2.AddToScheme(scheme)).To(Succeed()) options := client.Options{ Scheme: scheme, diff --git a/tests/suite/tracing_test.go b/tests/suite/tracing_test.go index 354c1137d..13a6ee334 100644 --- a/tests/suite/tracing_test.go +++ b/tests/suite/tracing_test.go @@ -17,7 +17,8 @@ import ( gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - ngfAPI "github.com/nginxinc/nginx-gateway-fabric/apis/v1alpha1" + 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/mode/static/state/conditions" "github.com/nginxinc/nginx-gateway-fabric/tests/framework" ) @@ -101,7 +102,7 @@ var _ = Describe("Tracing", FlakeAttempts(2), Label("functional", "tracing"), fu } gwClass.Spec.ParametersRef = &gatewayv1.ParametersReference{ - Group: ngfAPI.GroupName, + Group: ngfAPIv1alpha1.GroupName, Kind: gatewayv1.Kind("NginxProxy"), Name: "nginx-proxy", } @@ -235,7 +236,7 @@ func verifyPolicyStatus() error { ctx, cancel := context.WithTimeout(context.Background(), timeoutConfig.GetTimeout) defer cancel() - var pol ngfAPI.ObservabilityPolicy + var pol ngfAPIv1alpha2.ObservabilityPolicy key := types.NamespacedName{Name: "test-observability-policy", Namespace: "helloworld"} if err := k8sClient.Get(ctx, key, &pol); err != nil { return err