Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Nov 16, 2023
1 parent e17e66b commit be5eda6
Show file tree
Hide file tree
Showing 22 changed files with 249 additions and 248 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ testbin/*
*.swo
*~

go.work
go.work.sum
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ CRDOC ?= $(LOCALBIN)/crdoc
KUSTOMIZE_VERSION ?= v4.5.7
# renovate: datasource=github-releases depName=kubernetes-sigs/controller-tools
CONTROLLER_TOOLS_VERSION ?= v0.10.0
CRDOC_VERSION ?= v0.6.2
CRDOC_VERSION ?= v0.7.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
4 changes: 0 additions & 4 deletions apis/core/v1alpha1/featureflagconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,7 @@ func (ff *FeatureFlagConfiguration) GenerateConfigMap(name string, namespace str
OwnerReferences: references,
},
Data: map[string]string{
<<<<<<< HEAD
common.FeatureFlagConfigurationConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
=======
utils.FeatureFlagConfigMapKey(namespace, name): ff.Spec.FeatureFlagSpec,
>>>>>>> feat: use v1beta1 in operator logic
},
}
}
Expand Down
3 changes: 1 addition & 2 deletions apis/core/v1alpha1/featureflagconfiguration_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package v1alpha1

import (
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"testing"

"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"testing"
)

func Test_FeatureFlagConfiguration(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions apis/core/v1alpha1/flagsourceconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package v1alpha1

import (
"fmt"
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"os"
"strconv"
"strings"

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand All @@ -49,7 +49,7 @@ const (
defaultEvaluator string = "json"
defaultImage string = "ghcr.io/open-feature/flagd"
// renovate: datasource=github-tags depName=open-feature/flagd/flagd
defaultTag string = "v0.6.3"
defaultTag string = "v0.7.0"
defaultLogFormat string = "json"
defaultProbesEnabled bool = true
SyncProviderKubernetes SyncProviderType = "kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion apis/core/v1alpha1/flagsourceconfiguration_types_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package v1alpha1

import (
"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"testing"

"github.com/open-feature/open-feature-operator/apis/core/v1alpha1/common"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
)
Expand Down
11 changes: 0 additions & 11 deletions apis/core/v1beta1/common.go

This file was deleted.

57 changes: 57 additions & 0 deletions apis/core/v1beta1/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package common

import "fmt"

type SyncProviderType string

const (
SyncProviderKubernetes SyncProviderType = "kubernetes"
SyncProviderFilepath SyncProviderType = "file"
SyncProviderHttp SyncProviderType = "http"
SyncProviderGrpc SyncProviderType = "grpc"
SyncProviderFlagdProxy SyncProviderType = "flagd-proxy"
)

func (s SyncProviderType) IsKubernetes() bool {
return s == SyncProviderKubernetes
}

func (s SyncProviderType) IsHttp() bool {
return s == SyncProviderHttp
}

func (s SyncProviderType) IsFilepath() bool {
return s == SyncProviderFilepath
}

func (s SyncProviderType) IsGrpc() bool {
return s == SyncProviderGrpc
}

func (s SyncProviderType) IsFlagdProxy() bool {
return s == SyncProviderFlagdProxy
}

func TrueVal() *bool {
b := true
return &b
}

func FalseVal() *bool {
b := false
return &b
}

func EnvVarKey(prefix string, suffix string) string {
return fmt.Sprintf("%s_%s", prefix, suffix)
}

// unique string used to create unique volume mount and file name
func FeatureFlagConfigurationId(namespace, name string) string {
return fmt.Sprintf("%s_%s", namespace, name)
}

// unique key (and filename) for configMap data
func FeatureFlagConfigMapKey(namespace, name string) string {
return fmt.Sprintf("%s.flagd.json", FeatureFlagConfigurationId(namespace, name))
}
28 changes: 28 additions & 0 deletions apis/core/v1beta1/common/common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package common

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test_FeatureFlagSource_SyncProvider(t *testing.T) {
k := SyncProviderKubernetes
f := SyncProviderFilepath
h := SyncProviderHttp
g := SyncProviderGrpc

require.True(t, k.IsKubernetes())
require.True(t, f.IsFilepath())
require.True(t, h.IsHttp())
require.True(t, g.IsGrpc())

require.False(t, f.IsKubernetes())
require.False(t, h.IsFilepath())
require.False(t, k.IsGrpc())
require.False(t, g.IsHttp())
}

func Test_FLagSourceConfiguration_envVarKey(t *testing.T) {
require.Equal(t, "pre_suf", EnvVarKey("pre", "suf"))
}
6 changes: 3 additions & 3 deletions apis/core/v1beta1/featureflag_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1beta1
import (
"encoding/json"

"github.com/open-feature/open-feature-operator/common/utils"
"github.com/open-feature/open-feature-operator/apis/core/v1beta1/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -93,7 +93,7 @@ func (ff *FeatureFlag) GetReference() metav1.OwnerReference {
Kind: ff.Kind,
Name: ff.Name,
UID: ff.UID,
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
}
}

Expand All @@ -112,7 +112,7 @@ func (ff *FeatureFlag) GenerateConfigMap(name string, namespace string, referenc
OwnerReferences: references,
},
Data: map[string]string{
utils.FeatureFlagConfigMapKey(namespace, name): string(b),
common.FeatureFlagConfigMapKey(namespace, name): string(b),
},
}, nil
}
8 changes: 4 additions & 4 deletions apis/core/v1beta1/featureflag_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1beta1
import (
"testing"

"github.com/open-feature/open-feature-operator/common/utils"
"github.com/open-feature/open-feature-operator/apis/core/v1beta1/common"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -21,7 +21,7 @@ func Test_FeatureFlag(t *testing.T) {
Kind: "kind",
Name: "ffconf1",
UID: types.UID("5"),
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
},
},
},
Expand All @@ -37,7 +37,7 @@ func Test_FeatureFlag(t *testing.T) {
Kind: ff.Kind,
Name: ff.Name,
UID: ff.UID,
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
}, ff.GetReference())

name := "cmname"
Expand All @@ -48,7 +48,7 @@ func Test_FeatureFlag(t *testing.T) {
Kind: "kind",
Name: "ffconf1",
UID: types.UID("5"),
Controller: utils.TrueVal(),
Controller: common.TrueVal(),
},
}

Expand Down
Loading

0 comments on commit be5eda6

Please sign in to comment.