From 0e5611b7e97de84618374f4a531bb1685514ece2 Mon Sep 17 00:00:00 2001 From: Igor Gov Date: Wed, 12 Jan 2022 18:05:12 +0200 Subject: [PATCH] FE setting experimental feature flags (#633) --- agent/main.go | 5 +++-- cli/config/configStruct.go | 4 ++-- ui/public/index.html | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/agent/main.go b/agent/main.go index a21ce3fe0..a9d8e3a93 100644 --- a/agent/main.go +++ b/agent/main.go @@ -233,7 +233,7 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) { app.Use(DisableRootStaticCache()) - if err := setUIMode(); err != nil { + if err := setUIFlags(); err != nil { logger.Log.Errorf("Error setting ui mode, err: %v", err) } app.Use(static.ServeRoot("/", "./site")) @@ -268,13 +268,14 @@ func DisableRootStaticCache() gin.HandlerFunc { } } -func setUIMode() error { +func setUIFlags() error { read, err := ioutil.ReadFile(uiIndexPath) if err != nil { return err } replacedContent := strings.Replace(string(read), "__IS_STANDALONE__", strconv.FormatBool(config.Config.StandaloneMode), 1) + replacedContent = strings.Replace(replacedContent, "__IS_OAS_ENABLED__", strconv.FormatBool(config.Config.OAS), 1) err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0) if err != nil { diff --git a/cli/config/configStruct.go b/cli/config/configStruct.go index f18142eea..6fad6180d 100644 --- a/cli/config/configStruct.go +++ b/cli/config/configStruct.go @@ -34,8 +34,8 @@ type ConfigStruct struct { ConfigFilePath string `yaml:"config-path,omitempty" readonly:""` HeadlessMode bool `yaml:"headless" default:"false"` LogLevelStr string `yaml:"log-level,omitempty" default:"INFO" readonly:""` - ServiceMap bool `yaml:"service-map" default:"false" readonly:""` - OAS bool `yaml:"oas" default:"false" readonly:""` + ServiceMap bool `yaml:"service-map,omitempty" default:"false" readonly:""` + OAS bool `yaml:"oas,omitempty" default:"false" readonly:""` } func (config *ConfigStruct) validate() error { diff --git a/ui/public/index.html b/ui/public/index.html index a8268a85a..f8f972ceb 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -29,6 +29,7 @@ try { // Injected from server window.isEnt = __IS_STANDALONE__ + window.isOasEnabled = __IS_OAS_ENABLED__ } catch (e) { }