Skip to content

Commit 46eecbe

Browse files
merge
Signed-off-by: James Milligan <[email protected]>
2 parents 86d2312 + 3ee6075 commit 46eecbe

File tree

10 files changed

+192
-79
lines changed

10 files changed

+192
-79
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ IMG ?= controller:latest
44
# customize overlay to be used in the build, DEFAULT or HELM
55
KUSTOMIZE_OVERLAY ?= DEFAULT
66
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
7-
FLAGD_VERSION=v0.2.5
7+
FLAGD_VERSION=v0.2.7
88
CHART_VERSION=v0.2.20# x-release-please-version
99
ENVTEST_K8S_VERSION = 1.25
1010

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ spec:
129129
```
130130

131131
1. Reference the CR within the pod spec annotations
132+
The `openfeature.dev/featureflagconfiguration` annotation is a comma separated list of CR references, listed as `{namespace}/{name}`. e.g. `"default/featureflagconfiguration-sample, test/featureflagconfiguration-sample-2"`. If no namespace is defined, it is assumed that the flag configuration is in the same namespace as the deployed pod.
132133

133134
```
134135
apiVersion: v1
@@ -137,7 +138,7 @@ metadata:
137138
name: nginx
138139
annotations:
139140
openfeature.dev/enabled: "true"
140-
openfeature.dev/featureflagconfiguration: "featureflagconfiguration-sample"
141+
openfeature.dev/featureflagconfiguration: "default/featureflagconfiguration-sample"
141142
spec:
142143
containers:
143144
- name: nginx

apis/core/v1alpha1/featureflagconfiguration_types.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
"fmt"
21+
2022
"github.com/open-feature/open-feature-operator/pkg/utils"
2123
corev1 "k8s.io/api/core/v1"
2224
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -51,12 +53,31 @@ type FlagDSpec struct {
5153

5254
type FeatureFlagSyncProvider struct {
5355
Name string `json:"name"`
56+
// +optional
57+
// +nullable
58+
HttpSyncConfiguration *HttpSyncConfiguration `json:"httpSyncConfiguration"`
59+
}
60+
61+
// HttpSyncConfiguration defines the desired configuration for a http sync
62+
type HttpSyncConfiguration struct {
63+
// Target is the target url for flagd to poll
64+
Target string `json:"target"`
65+
// +optional
66+
BearerToken string `json:"bearerToken,omitempty"`
5467
}
5568

5669
func (ffsp FeatureFlagSyncProvider) IsKubernetes() bool {
5770
return ffsp.Name == "kubernetes"
5871
}
5972

73+
func (ffsp FeatureFlagSyncProvider) IsHttp() bool {
74+
return ffsp.Name == "http"
75+
}
76+
77+
func (ffsp FeatureFlagSyncProvider) IsFilepath() bool {
78+
return ffsp.Name == "filepath"
79+
}
80+
6081
type FeatureFlagServiceProvider struct {
6182
// +kubebuilder:validation:Enum=flagd
6283
Name string `json:"name"`
@@ -118,7 +139,7 @@ func GenerateFfConfigMap(name string, namespace string, references []metav1.Owne
118139
OwnerReferences: references,
119140
},
120141
Data: map[string]string{
121-
"config.json": spec.FeatureFlagSpec,
142+
fmt.Sprintf("%s.json", name): spec.FeatureFlagSpec,
122143
},
123144
}
124145
}

apis/core/v1alpha2/featureflagconfiguration_conversion.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1alpha2
1919
import (
2020
"encoding/json"
2121
"fmt"
22+
2223
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
2324
ctrl "sigs.k8s.io/controller-runtime"
2425
"sigs.k8s.io/controller-runtime/pkg/conversion"
@@ -43,6 +44,12 @@ func (src *FeatureFlagConfiguration) ConvertTo(dstRaw conversion.Hub) error {
4344

4445
if src.Spec.SyncProvider != nil {
4546
dst.Spec.SyncProvider = &v1alpha1.FeatureFlagSyncProvider{Name: src.Spec.SyncProvider.Name}
47+
if src.Spec.SyncProvider.HttpSyncConfiguration != nil {
48+
dst.Spec.SyncProvider.HttpSyncConfiguration = &v1alpha1.HttpSyncConfiguration{
49+
Target: src.Spec.SyncProvider.HttpSyncConfiguration.Target,
50+
BearerToken: src.Spec.SyncProvider.HttpSyncConfiguration.BearerToken,
51+
}
52+
}
4653
}
4754

4855
if src.Spec.FlagDSpec != nil {
@@ -71,7 +78,15 @@ func (dst *FeatureFlagConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
7178
}
7279

7380
if src.Spec.SyncProvider != nil {
74-
dst.Spec.SyncProvider = &FeatureFlagSyncProvider{Name: src.Spec.SyncProvider.Name}
81+
dst.Spec.SyncProvider = &FeatureFlagSyncProvider{
82+
Name: src.Spec.SyncProvider.Name,
83+
}
84+
if src.Spec.SyncProvider.HttpSyncConfiguration != nil {
85+
dst.Spec.SyncProvider.HttpSyncConfiguration = &HttpSyncConfiguration{
86+
Target: src.Spec.SyncProvider.HttpSyncConfiguration.Target,
87+
BearerToken: src.Spec.SyncProvider.HttpSyncConfiguration.BearerToken,
88+
}
89+
}
7590
}
7691

7792
if src.Spec.FlagDSpec != nil {

apis/core/v1alpha2/featureflagconfiguration_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1alpha2
1818

1919
import (
2020
"encoding/json"
21+
2122
"github.com/open-feature/open-feature-operator/pkg/utils"
2223
corev1 "k8s.io/api/core/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -75,6 +76,17 @@ type FlagSpec struct {
7576

7677
type FeatureFlagSyncProvider struct {
7778
Name string `json:"name"`
79+
// +optional
80+
// +nullable
81+
HttpSyncConfiguration *HttpSyncConfiguration `json:"httpSyncConfiguration"`
82+
}
83+
84+
// HttpSyncConfiguration defines the desired configuration for a http sync
85+
type HttpSyncConfiguration struct {
86+
// Target is the target url for flagd to poll
87+
Target string `json:"target"`
88+
// +optional
89+
BearerToken string `json:"bearerToken,omitempty"`
7890
}
7991

8092
func (ffsp FeatureFlagSyncProvider) IsKubernetes() bool {

config/crd/bases/core.openfeature.dev_featureflagconfigurations.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ spec:
238238
syncProvider:
239239
nullable: true
240240
properties:
241+
httpSyncConfiguration:
242+
description: HttpSyncConfiguration defines the desired configuration
243+
for a http sync
244+
nullable: true
245+
properties:
246+
bearerToken:
247+
type: string
248+
target:
249+
description: Target is the target url for flagd to poll
250+
type: string
251+
required:
252+
- target
253+
type: object
241254
name:
242255
type: string
243256
required:

controllers/featureflagconfiguration_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"time"
2223

2324
"github.com/go-logr/logr"
@@ -153,7 +154,7 @@ func (r *FeatureFlagConfigurationReconciler) Reconcile(ctx context.Context, req
153154
// Update ConfigMap Spec
154155
r.Log.Info("Updating ConfigMap Spec " + cm.Name)
155156
cm.Data = map[string]string{
156-
"config.json": ffconf.Spec.FeatureFlagSpec,
157+
fmt.Sprintf("%s.json", cm.Name): ffconf.Spec.FeatureFlagSpec,
157158
}
158159
err := r.Client.Update(ctx, &cm)
159160
if err != nil {

test/e2e/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ spec:
9292
- protocol: TCP
9393
port: 30000
9494
targetPort: 80
95-
nodePort: 30000
95+
nodePort: 30000

0 commit comments

Comments
 (0)