From aef1010dff162e8d232942e642c68e3e9ba3f35f Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 3 Jun 2024 17:32:33 -0400 Subject: [PATCH] fix: flagd path defaults (#658) Signed-off-by: Todd Baert --- apis/core/v1beta1/flagd_types.go | 7 +++++-- config/crd/bases/core.openfeature.dev_flagds.yaml | 15 +++++++++------ controllers/core/flagd/resources/ingress.go | 6 +++--- controllers/core/flagd/resources/ingress_test.go | 8 ++++---- docs/crds.md | 9 ++++++--- .../00-assert.yaml | 4 ++-- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/apis/core/v1beta1/flagd_types.go b/apis/core/v1beta1/flagd_types.go index bbe7de4fb..4b99a58e8 100644 --- a/apis/core/v1beta1/flagd_types.go +++ b/apis/core/v1beta1/flagd_types.go @@ -76,16 +76,19 @@ type IngressSpec struct { PathType networkingv1.PathType `json:"pathType,omitempty"` // FlagdPath is the path to be used for accessing the flagd flag evaluation API + // Default: /flagd.evaluation.v1.Service // +optional FlagdPath string `json:"flagdPath,omitempty"` // OFREPPath is the path to be used for accessing the OFREP API + // Default: /ofrep // +optional - OFREPPath string `json:"ofrepPath"` + OFREPPath string `json:"ofrepPath,omitempty"` // SyncPath is the path to be used for accessing the sync API + // Default: /flagd.sync.v1.Service // +optional - SyncPath string `json:"syncPath"` + SyncPath string `json:"syncPath,omitempty"` } // FlagdStatus defines the observed state of Flagd diff --git a/config/crd/bases/core.openfeature.dev_flagds.yaml b/config/crd/bases/core.openfeature.dev_flagds.yaml index 601cf94ed..b736c4f5f 100644 --- a/config/crd/bases/core.openfeature.dev_flagds.yaml +++ b/config/crd/bases/core.openfeature.dev_flagds.yaml @@ -56,8 +56,9 @@ spec: description: Enabled enables/disables the ingress for flagd type: boolean flagdPath: - description: FlagdPath is the path to be used for accessing the - flagd flag evaluation API + description: |- + FlagdPath is the path to be used for accessing the flagd flag evaluation API + Default: /flagd.evaluation.v1.Service type: string hosts: description: Hosts list of hosts to be added to the ingress @@ -69,16 +70,18 @@ spec: class to be used for flagd type: string ofrepPath: - description: OFREPPath is the path to be used for accessing the - OFREP API + description: |- + OFREPPath is the path to be used for accessing the OFREP API + Default: /ofrep type: string pathType: description: PathType is the path type to be used for the ingress rules type: string syncPath: - description: SyncPath is the path to be used for accessing the - sync API + description: |- + SyncPath is the path to be used for accessing the sync API + Default: /flagd.sync.v1.Service type: string tls: description: TLS configuration for the ingress diff --git a/controllers/core/flagd/resources/ingress.go b/controllers/core/flagd/resources/ingress.go index 06984411f..4bb4e7a62 100644 --- a/controllers/core/flagd/resources/ingress.go +++ b/controllers/core/flagd/resources/ingress.go @@ -6,16 +6,16 @@ import ( api "github.com/open-feature/open-feature-operator/apis/core/v1beta1" "github.com/open-feature/open-feature-operator/common" - "github.com/open-feature/open-feature-operator/controllers/core/flagd/common" + resources "github.com/open-feature/open-feature-operator/controllers/core/flagd/common" networkingv1 "k8s.io/api/networking/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) const ( - defaultFlagdPath = "/flagd" + defaultFlagdPath = "/flagd.evaluation.v1.Service" defaultOFREPPath = "/ofrep" - defaultSyncPath = "/sync" + defaultSyncPath = "/flagd.sync.v1.Service" ) type FlagdIngress struct { diff --git a/controllers/core/flagd/resources/ingress_test.go b/controllers/core/flagd/resources/ingress_test.go index c15e56e99..107693f99 100644 --- a/controllers/core/flagd/resources/ingress_test.go +++ b/controllers/core/flagd/resources/ingress_test.go @@ -71,7 +71,7 @@ func TestFlagdIngress_getIngress(t *testing.T) { HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: []networkingv1.HTTPIngressPath{ { - Path: "/flagd", + Path: "/flagd.evaluation.v1.Service", PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ @@ -97,7 +97,7 @@ func TestFlagdIngress_getIngress(t *testing.T) { }, }, { - Path: "/sync", + Path: "/flagd.sync.v1.Service", PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ @@ -119,7 +119,7 @@ func TestFlagdIngress_getIngress(t *testing.T) { HTTP: &networkingv1.HTTPIngressRuleValue{ Paths: []networkingv1.HTTPIngressPath{ { - Path: "/flagd", + Path: "/flagd.evaluation.v1.Service", PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ @@ -145,7 +145,7 @@ func TestFlagdIngress_getIngress(t *testing.T) { }, }, { - Path: "/sync", + Path: "/flagd.sync.v1.Service", PathType: &pathType, Backend: networkingv1.IngressBackend{ Service: &networkingv1.IngressServiceBackend{ diff --git a/docs/crds.md b/docs/crds.md index 6e444c458..3ab15217a 100644 --- a/docs/crds.md +++ b/docs/crds.md @@ -942,7 +942,8 @@ Ingress flagdPath string - FlagdPath is the path to be used for accessing the flagd flag evaluation API
+ FlagdPath is the path to be used for accessing the flagd flag evaluation API +Default: /flagd.evaluation.v1.Service
false @@ -963,7 +964,8 @@ Ingress ofrepPath string - OFREPPath is the path to be used for accessing the OFREP API
+ OFREPPath is the path to be used for accessing the OFREP API +Default: /ofrep
false @@ -977,7 +979,8 @@ Ingress syncPath string - SyncPath is the path to be used for accessing the sync API
+ SyncPath is the path to be used for accessing the sync API +Default: /flagd.sync.v1.Service
false diff --git a/test/e2e/chainsaw/flagd-with-ingress-default-paths/00-assert.yaml b/test/e2e/chainsaw/flagd-with-ingress-default-paths/00-assert.yaml index ccad7c28a..9dc23f7e3 100644 --- a/test/e2e/chainsaw/flagd-with-ingress-default-paths/00-assert.yaml +++ b/test/e2e/chainsaw/flagd-with-ingress-default-paths/00-assert.yaml @@ -104,7 +104,7 @@ spec: name: flagd-sample port: number: 8013 - path: /flagd + path: /flagd.evaluation.v1.Service pathType: ImplementationSpecific - backend: service: @@ -118,5 +118,5 @@ spec: name: flagd-sample port: number: 8015 - path: /sync + path: /flagd.sync.v1.Service pathType: ImplementationSpecific