mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-11 05:12:26 +00:00
Added setting ui mode - enterprise or normal (#575)
This commit is contained in:
parent
f535719ddd
commit
482036182b
@ -24,6 +24,8 @@ import (
|
|||||||
"plugin"
|
"plugin"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ const (
|
|||||||
socketConnectionRetries = 30
|
socketConnectionRetries = 30
|
||||||
socketConnectionRetryDelay = time.Second * 2
|
socketConnectionRetryDelay = time.Second * 2
|
||||||
socketHandshakeTimeout = time.Second * 2
|
socketHandshakeTimeout = time.Second * 2
|
||||||
|
uiIndexPath = "./site/index.html"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -251,7 +254,12 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.Use(DisableRootStaticCache())
|
app.Use(DisableRootStaticCache())
|
||||||
|
|
||||||
|
if err := setUIMode(); err != nil {
|
||||||
|
logger.Log.Panicf("Error setting ui mode, err: %v", err)
|
||||||
|
}
|
||||||
app.Use(static.ServeRoot("/", "./site"))
|
app.Use(static.ServeRoot("/", "./site"))
|
||||||
|
|
||||||
app.Use(CORSMiddleware()) // This has to be called after the static middleware, does not work if its called before
|
app.Use(CORSMiddleware()) // This has to be called after the static middleware, does not work if its called before
|
||||||
|
|
||||||
api.WebSocketRoutes(app, &eventHandlers, startTime)
|
api.WebSocketRoutes(app, &eventHandlers, startTime)
|
||||||
@ -291,6 +299,22 @@ func CORSMiddleware() gin.HandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setUIMode() error {
|
||||||
|
read, err := ioutil.ReadFile(uiIndexPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
replacedContent := strings.Replace(string(read), "__IS_STANDALONE__", strconv.FormatBool(config.Config.StandaloneMode), 1)
|
||||||
|
|
||||||
|
err = ioutil.WriteFile(uiIndexPath, []byte(replacedContent), 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func parseEnvVar(env string) map[string][]v1.Pod {
|
func parseEnvVar(env string) map[string][]v1.Pod {
|
||||||
var mapOfList map[string][]v1.Pod
|
var mapOfList map[string][]v1.Pod
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ func getInstallMizuAgentConfig(maxDBSizeBytes int64, tapperResources shared.Reso
|
|||||||
TapperResources: tapperResources,
|
TapperResources: tapperResources,
|
||||||
MizuResourcesNamespace: config.Config.MizuResourcesNamespace,
|
MizuResourcesNamespace: config.Config.MizuResourcesNamespace,
|
||||||
AgentDatabasePath: shared.DataDirPath,
|
AgentDatabasePath: shared.DataDirPath,
|
||||||
|
StandaloneMode: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &mizuAgentConfig
|
return &mizuAgentConfig
|
||||||
|
@ -40,6 +40,7 @@ type MizuAgentConfig struct {
|
|||||||
TapperResources Resources `json:"tapperResources"`
|
TapperResources Resources `json:"tapperResources"`
|
||||||
MizuResourcesNamespace string `json:"mizuResourceNamespace"`
|
MizuResourcesNamespace string `json:"mizuResourceNamespace"`
|
||||||
AgentDatabasePath string `json:"agentDatabasePath"`
|
AgentDatabasePath string `json:"agentDatabasePath"`
|
||||||
|
StandaloneMode bool `json:"standaloneMode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebSocketMessageMetadata struct {
|
type WebSocketMessageMetadata struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user