-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: odubajDT <[email protected]>
- Loading branch information
Showing
22 changed files
with
249 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ testbin/* | |
*.swo | ||
*~ | ||
|
||
go.work | ||
go.work.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.