Skip to content

Commit 7ee876d

Browse files
committed
feat(flagd): add support for azure blob
- fix for ToEnvVars function to not add prefix for Azure blob related env vars Signed-off-by: vmai <[email protected]>
1 parent c45f44a commit 7ee876d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

api/core/v1beta1/featureflagsource_types.go

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

1919
import (
2020
"fmt"
21+
"strings"
2122

2223
"github.com/open-feature/open-feature-operator/apis/core/v1beta1/common"
2324
corev1 "k8s.io/api/core/v1"
@@ -209,12 +210,19 @@ func (fc *FeatureFlagSourceSpec) Merge(new *FeatureFlagSourceSpec) {
209210
}
210211
}
211212

213+
func (fc *FeatureFlagSourceSpec) decorateEnvVarName(original string) string {
214+
if strings.HasPrefix(original, "AZURE_STORAGE") {
215+
return original
216+
}
217+
return common.EnvVarKey(fc.EnvVarPrefix, original)
218+
}
219+
212220
func (fc *FeatureFlagSourceSpec) ToEnvVars() []corev1.EnvVar {
213221
envs := []corev1.EnvVar{}
214222

215223
for _, envVar := range fc.EnvVars {
216224
envs = append(envs, corev1.EnvVar{
217-
Name: common.EnvVarKey(fc.EnvVarPrefix, envVar.Name),
225+
Name: fc.decorateEnvVarName(envVar.Name),
218226
Value: envVar.Value,
219227
})
220228
}

api/core/v1beta1/featureflagsource_types_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ func Test_FLagSourceConfiguration_ToEnvVars(t *testing.T) {
180180
Name: "env2",
181181
Value: "val2",
182182
},
183+
{
184+
Name: "AZURE_STORAGE_ACCOUNT",
185+
Value: "account123",
186+
},
187+
{
188+
Name: "AZURE_STORAGE_KEY",
189+
Value: "key456",
190+
},
183191
},
184192
EnvVarPrefix: "PRE",
185193
ManagementPort: 22,
@@ -198,6 +206,14 @@ func Test_FLagSourceConfiguration_ToEnvVars(t *testing.T) {
198206
Name: "PRE_env2",
199207
Value: "val2",
200208
},
209+
{
210+
Name: "AZURE_STORAGE_ACCOUNT",
211+
Value: "account123",
212+
},
213+
{
214+
Name: "AZURE_STORAGE_KEY",
215+
Value: "key456",
216+
},
201217
{
202218
Name: "PRE_MANAGEMENT_PORT",
203219
Value: "22",

docs/feature_flag_source.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ sources:
8383
selector: 'source=database,app=weatherapp' # flag filtering options
8484
```
8585

86+
### Azure Blob Storage
87+
88+
Given below is an example configuration with provider type `azblob` and supported options,
89+
90+
```yaml
91+
sources:
92+
- source: azblob://my-bucket/test.json # my-bucket - container name
93+
provider: azblob
94+
envVars:
95+
- name: AZURE_STORAGE_ACCOUNT
96+
value: <account_name>
97+
- name: AZURE_STORAGE_SAS_TOKEN
98+
value: <SAS token>
99+
```
100+
Other type of credentials for Azure Blob Storage are supported, for details (see [AZ credentials config](https://pkg.go.dev/gocloud.dev/blob/azureblob#hdr-URLs))
101+
86102
## Sidecar configurations
87103

88104
`FeatureFlagSource` provides configurations to the injected flagd sidecar.

0 commit comments

Comments
 (0)