Commit c32db87d authored by ibuler's avatar ibuler

Merge branch 'dev' of github.com:jumpserver/koko into dev

parents ebd7b1c2 4b037ec5
...@@ -42,7 +42,7 @@ make linux ...@@ -42,7 +42,7 @@ make linux
tar xzf koko-[branch name]-[commit]-linux-amd64.tar.gz tar xzf koko-[branch name]-[commit]-linux-amd64.tar.gz
``` ```
3.创建配置文件config.yml,配置参数请参考[coco](https://github.com/jumpserver/coco/blob/master/config_example.yml) 3.创建配置文件config.yml,配置参数请参考[cmd](https://github.com/jumpserver/koko/tree/master/cmd)目录下的config_example.yml文件
```shell ```shell
touch config.yml touch config.yml
``` ```
......
...@@ -48,3 +48,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver> ...@@ -48,3 +48,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
# 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接) # 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接)
# REUSE_CONNECTION: true # REUSE_CONNECTION: true
# 资产加载策略, 可根据资产规模自行调整. 默认异步加载资产, 异步搜索分页; 如果为all, 则资产全部加载, 本地搜索分页.
# ASSET_LOAD_POLICY:
\ No newline at end of file
...@@ -45,7 +45,7 @@ type Config struct { ...@@ -45,7 +45,7 @@ type Config struct {
Language string `yaml:"LANG"` Language string `yaml:"LANG"`
LanguageCode string `yaml:"LANGUAGE_CODE"` // Abandon LanguageCode string `yaml:"LANGUAGE_CODE"` // Abandon
UploadFailedReplay bool `yaml:"UPLOAD_FAILED_REPLAY_ON_START"` UploadFailedReplay bool `yaml:"UPLOAD_FAILED_REPLAY_ON_START"`
LoadPolicy string `yaml:"LOAD_POLICY"` // all, pagination AssetLoadPolicy string `yaml:"ASSET_LOAD_POLICY"` // all
} }
func (c *Config) EnsureConfigValid() { func (c *Config) EnsureConfigValid() {
...@@ -101,7 +101,7 @@ func (c *Config) LoadFromEnv() error { ...@@ -101,7 +101,7 @@ func (c *Config) LoadFromEnv() error {
} }
func (c *Config) Load(filepath string) error { func (c *Config) Load(filepath string) error {
if err := c.LoadFromYAMLPath(filepath); err == nil{ if err := c.LoadFromYAMLPath(filepath); err == nil {
return err return err
} }
log.Print("Load from env") log.Print("Load from env")
...@@ -134,6 +134,7 @@ var Conf = &Config{ ...@@ -134,6 +134,7 @@ var Conf = &Config{
SftpRoot: "/tmp", SftpRoot: "/tmp",
ShowHiddenFile: false, ShowHiddenFile: false,
ReuseConnection: true, ReuseConnection: true,
AssetLoadPolicy: "",
} }
func SetConf(conf *Config) { func SetConf(conf *Config) {
......
...@@ -63,12 +63,12 @@ type interactiveHandler struct { ...@@ -63,12 +63,12 @@ type interactiveHandler struct {
offset int offset int
limit int limit int
loadDataDone chan struct{} loadDataDone chan struct{}
loadPolicy string assetLoadPolicy string
} }
func (h *interactiveHandler) Initial() { func (h *interactiveHandler) Initial() {
h.loadPolicy = config.GetConf().LoadPolicy h.assetLoadPolicy = strings.ToLower(config.GetConf().AssetLoadPolicy)
h.displayBanner() h.displayBanner()
h.winWatchChan = make(chan bool) h.winWatchChan = make(chan bool)
h.loadDataDone = make(chan struct{}) h.loadDataDone = make(chan struct{})
...@@ -77,7 +77,7 @@ func (h *interactiveHandler) Initial() { ...@@ -77,7 +77,7 @@ func (h *interactiveHandler) Initial() {
func (h *interactiveHandler) firstLoadData() { func (h *interactiveHandler) firstLoadData() {
h.loadUserNodes("1") h.loadUserNodes("1")
switch h.loadPolicy { switch h.assetLoadPolicy {
case "all": case "all":
h.loadAllAssets() h.loadAllAssets()
} }
...@@ -184,7 +184,7 @@ func (h *interactiveHandler) Dispatch(ctx cctx.Context) { ...@@ -184,7 +184,7 @@ func (h *interactiveHandler) Dispatch(ctx cctx.Context) {
} }
func (h *interactiveHandler) displayAllAssets() { func (h *interactiveHandler) displayAllAssets() {
switch h.loadPolicy { switch h.assetLoadPolicy {
case "all": case "all":
<-h.loadDataDone <-h.loadDataDone
h.displayAssets(h.allAssets) h.displayAssets(h.allAssets)
...@@ -270,7 +270,7 @@ func (h *interactiveHandler) displayNodes(nodes []model.Node) { ...@@ -270,7 +270,7 @@ func (h *interactiveHandler) displayNodes(nodes []model.Node) {
} }
func (h *interactiveHandler) refreshAssetsAndNodesData() { func (h *interactiveHandler) refreshAssetsAndNodesData() {
switch h.loadPolicy { switch h.assetLoadPolicy {
case "all": case "all":
h.loadAllAssets() h.loadAllAssets()
} }
...@@ -290,7 +290,7 @@ func (h *interactiveHandler) loadAllAssets() { ...@@ -290,7 +290,7 @@ func (h *interactiveHandler) loadAllAssets() {
} }
func (h *interactiveHandler) searchAsset(key string) { func (h *interactiveHandler) searchAsset(key string) {
switch h.loadPolicy { switch h.assetLoadPolicy {
case "all": case "all":
<-h.loadDataDone <-h.loadDataDone
var searchData []model.Asset var searchData []model.Asset
...@@ -321,7 +321,7 @@ func (h *interactiveHandler) searchAssetOrProxy(key string) { ...@@ -321,7 +321,7 @@ func (h *interactiveHandler) searchAssetOrProxy(key string) {
} }
} }
var assets []model.Asset var assets []model.Asset
switch h.loadPolicy { switch h.assetLoadPolicy {
case "all": case "all":
<-h.loadDataDone <-h.loadDataDone
var searchData []model.Asset var searchData []model.Asset
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment