diff --git a/pkg/local_workflows/config_utils/feature_flag.go b/pkg/local_workflows/config_utils/feature_flag.go index 8248d46dd..7554e5155 100644 --- a/pkg/local_workflows/config_utils/feature_flag.go +++ b/pkg/local_workflows/config_utils/feature_flag.go @@ -1,6 +1,8 @@ package config_utils import ( + "net/http" + "github.com/snyk/go-application-framework/internal/api" "github.com/snyk/go-application-framework/pkg/configuration" "github.com/snyk/go-application-framework/pkg/workflow" @@ -12,15 +14,7 @@ func AddFeatureFlagToConfig(engine workflow.Engine, configKey string, featureFla callback := func(existingValue interface{}) (interface{}, error) { if existingValue == nil { httpClient := engine.GetNetworkAccess().GetHttpClient() - logger := engine.GetLogger() - url := config.GetString(configuration.API_URL) - org := config.GetString(configuration.ORGANIZATION) - apiClient := api.NewApi(url, httpClient) - result, err := apiClient.GetFeatureFlag(featureFlagName, org) - if err != nil { - logger.Printf("Failed to determine feature flag \"%s\" for org \"%s\": %s", featureFlagName, org, err) - } - return result, nil + return GetFeatureFlagValue(featureFlagName, config, httpClient) } else { return existingValue, nil } @@ -28,3 +22,11 @@ func AddFeatureFlagToConfig(engine workflow.Engine, configKey string, featureFla config.AddDefaultValue(configKey, callback) } + +func GetFeatureFlagValue(featureFlagName string, config configuration.Configuration, httpClient *http.Client) (bool, error) { + url := config.GetString(configuration.API_URL) + org := config.GetString(configuration.ORGANIZATION) + apiClient := api.NewApi(url, httpClient) + result, err := apiClient.GetFeatureFlag(featureFlagName, org) + return result, err +}