1
1
package config_utils
2
2
3
3
import (
4
+ "net/http"
5
+
4
6
"github.com/snyk/go-application-framework/internal/api"
5
7
"github.com/snyk/go-application-framework/pkg/configuration"
6
8
"github.com/snyk/go-application-framework/pkg/workflow"
@@ -12,19 +14,19 @@ func AddFeatureFlagToConfig(engine workflow.Engine, configKey string, featureFla
12
14
callback := func (existingValue interface {}) (interface {}, error ) {
13
15
if existingValue == nil {
14
16
httpClient := engine .GetNetworkAccess ().GetHttpClient ()
15
- logger := engine .GetLogger ()
16
- url := config .GetString (configuration .API_URL )
17
- org := config .GetString (configuration .ORGANIZATION )
18
- apiClient := api .NewApi (url , httpClient )
19
- result , err := apiClient .GetFeatureFlag (featureFlagName , org )
20
- if err != nil {
21
- logger .Printf ("Failed to determine feature flag \" %s\" for org \" %s\" : %s" , featureFlagName , org , err )
22
- }
23
- return result , nil
17
+ return GetFeatureFlagValue (featureFlagName , config , httpClient )
24
18
} else {
25
19
return existingValue , nil
26
20
}
27
21
}
28
22
29
23
config .AddDefaultValue (configKey , callback )
30
24
}
25
+
26
+ func GetFeatureFlagValue (featureFlagName string , config configuration.Configuration , httpClient * http.Client ) (bool , error ) {
27
+ url := config .GetString (configuration .API_URL )
28
+ org := config .GetString (configuration .ORGANIZATION )
29
+ apiClient := api .NewApi (url , httpClient )
30
+ result , err := apiClient .GetFeatureFlag (featureFlagName , org )
31
+ return result , err
32
+ }
0 commit comments