Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
84094633
Commit
84094633
authored
Aug 29, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] add asset load policy config
parent
657fbc18
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
11 deletions
+16
-11
README.md
README.md
+1
-1
config_example.yml
cmd/config_example.yml
+4
-0
config.go
pkg/config/config.go
+3
-2
session.go
pkg/handler/session.go
+8
-8
No files found.
README.md
View file @
84094633
...
...
@@ -42,7 +42,7 @@ make linux
tar
xzf koko-[branch name]-[commit]-linux-amd64.tar.gz
```
3.
创建配置文件config.yml,配置参数请参考
[
c
oco
](
https://github.com/jumpserver/coco/blob/master/config_example.yml
)
3.
创建配置文件config.yml,配置参数请参考
[
c
md
](
url:https://github.com/jumpserver/koko/tree/master/cmd
)
目录下的config_example.yml文件
```
shell
touch
config.yml
```
...
...
cmd/config_example.yml
View file @
84094633
...
...
@@ -48,3 +48,6 @@ BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>
# 是否复用和用户后端资产已建立的连接(用户不会复用其他用户的连接)
# REUSE_CONNECTION: true
# 资产加载策略, 可根据资产规模自行调整. 默认异步加载资产, 异步搜索分页; 如果为all, 则资产全部加载, 本地搜索分页.
# ASSET_LOAD_POLICY:
\ No newline at end of file
pkg/config/config.go
View file @
84094633
...
...
@@ -45,7 +45,7 @@ type Config struct {
Language
string
`yaml:"LANG"`
LanguageCode
string
`yaml:"LANGUAGE_CODE"`
// Abandon
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
()
{
...
...
@@ -101,7 +101,7 @@ func (c *Config) LoadFromEnv() error {
}
func
(
c
*
Config
)
Load
(
filepath
string
)
error
{
if
err
:=
c
.
LoadFromYAMLPath
(
filepath
);
err
==
nil
{
if
err
:=
c
.
LoadFromYAMLPath
(
filepath
);
err
==
nil
{
return
err
}
log
.
Print
(
"Load from env"
)
...
...
@@ -134,6 +134,7 @@ var Conf = &Config{
SftpRoot
:
"/tmp"
,
ShowHiddenFile
:
false
,
ReuseConnection
:
true
,
AssetLoadPolicy
:
""
,
}
func
SetConf
(
conf
*
Config
)
{
...
...
pkg/handler/session.go
View file @
84094633
...
...
@@ -63,12 +63,12 @@ type interactiveHandler struct {
offset
int
limit
int
loadDataDone
chan
struct
{}
loadPolicy
string
loadDataDone
chan
struct
{}
assetLoadPolicy
string
}
func
(
h
*
interactiveHandler
)
Initial
()
{
h
.
loadPolicy
=
config
.
GetConf
()
.
LoadPolicy
h
.
assetLoadPolicy
=
strings
.
ToLower
(
config
.
GetConf
()
.
AssetLoadPolicy
)
h
.
displayBanner
()
h
.
winWatchChan
=
make
(
chan
bool
)
h
.
loadDataDone
=
make
(
chan
struct
{})
...
...
@@ -77,7 +77,7 @@ func (h *interactiveHandler) Initial() {
func
(
h
*
interactiveHandler
)
firstLoadData
()
{
h
.
loadUserNodes
(
"1"
)
switch
h
.
l
oadPolicy
{
switch
h
.
assetL
oadPolicy
{
case
"all"
:
h
.
loadAllAssets
()
}
...
...
@@ -184,7 +184,7 @@ func (h *interactiveHandler) Dispatch(ctx cctx.Context) {
}
func
(
h
*
interactiveHandler
)
displayAllAssets
()
{
switch
h
.
l
oadPolicy
{
switch
h
.
assetL
oadPolicy
{
case
"all"
:
<-
h
.
loadDataDone
h
.
displayAssets
(
h
.
allAssets
)
...
...
@@ -270,7 +270,7 @@ func (h *interactiveHandler) displayNodes(nodes []model.Node) {
}
func
(
h
*
interactiveHandler
)
refreshAssetsAndNodesData
()
{
switch
h
.
l
oadPolicy
{
switch
h
.
assetL
oadPolicy
{
case
"all"
:
h
.
loadAllAssets
()
}
...
...
@@ -290,7 +290,7 @@ func (h *interactiveHandler) loadAllAssets() {
}
func
(
h
*
interactiveHandler
)
searchAsset
(
key
string
)
{
switch
h
.
l
oadPolicy
{
switch
h
.
assetL
oadPolicy
{
case
"all"
:
<-
h
.
loadDataDone
var
searchData
[]
model
.
Asset
...
...
@@ -321,7 +321,7 @@ func (h *interactiveHandler) searchAssetOrProxy(key string) {
}
}
var
assets
[]
model
.
Asset
switch
h
.
l
oadPolicy
{
switch
h
.
assetL
oadPolicy
{
case
"all"
:
<-
h
.
loadDataDone
var
searchData
[]
model
.
Asset
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment