Unverified Commit 73da96ac authored by 老广's avatar 老广 Committed by GitHub

Modbranch (#32)

* [update] change dep to mod

* add mod file

* [Update] 修改使用cache

* [Update] 修改路径
parent 2a473350
......@@ -12,7 +12,6 @@
*.out
data/
log/
go.sum
.idea/
vendor/
config.yml
......
FROM golang:1.12-alpine as stage-build
LABEL stage=stage-build
WORKDIR /go/src/github.com/jumpserver/koko
RUN apk update && apk add git
ARG https_proxy
ARG http_proxy
ENV https_proxy=$https_proxy
ENV http_proxy=$http_proxy
RUN go get -u github.com/golang/dep/cmd/dep
WORKDIR /opt/coco
ARG GOPROXY
ENV GOPROXY=$GOPROXY
ENV GO111MODULE=on
COPY . .
RUN dep ensure -vendor-only && cd cmd && go build koko.go
RUN cd cmd && go build koko.go
FROM alpine
WORKDIR /opt/koko/
COPY --from=stage-build /go/src/github.com/jumpserver/koko/cmd/koko .
COPY --from=stage-build /go/src/github.com/jumpserver/koko/cmd/locale/ locale
COPY --from=stage-build /go/src/github.com/jumpserver/koko/cmd/static/ static
COPY --from=stage-build /go/src/github.com/jumpserver/koko/cmd/templates/ templates
WORKDIR /opt/coco/
COPY --from=stage-build /opt/coco/cmd/koko .
COPY --from=stage-build /opt/coco/cmd/locale/ locale
COPY --from=stage-build /opt/coco/cmd/static/ static
COPY --from=stage-build /opt/coco/cmd/templates/ templates
COPY cmd/config_example.yml .
COPY entrypoint.sh .
RUN chmod 755 ./entrypoint.sh \
......
This diff is collapsed.
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
required = ["github.com/googollee/go-engine.io"]
[[constraint]]
name = "github.com/gliderlabs/ssh"
source = "github.com/ibuler/ssh"
branch = "dev"
[[constraint]]
name = "github.com/googollee/go-engine.io"
source = "github.com/ibuler/go-engine.io"
branch = "master"
[[constraint]]
name = "github.com/googollee/go-socket.io"
source = "github.com/LeeEirc/go-socket.io"
branch = "master"
[[constraint]]
name = "github.com/gorilla/mux"
version = "v1.7.2"
[[constraint]]
name = "github.com/jarcoal/httpmock"
version = "1.0.3"
[[constraint]]
name = "github.com/kr/pty"
version = "1.1.4"
[[constraint]]
name = "github.com/olekukonko/tablewriter"
version = "0.0.1"
[[constraint]]
name = "github.com/pkg/sftp"
version = "1.10.0"
[[constraint]]
name = "github.com/satori/go.uuid"
version = "1.2.0"
[[constraint]]
name = "github.com/sirupsen/logrus"
version = "1.4.1"
[[constraint]]
branch = "master"
name = "github.com/xlab/treeprint"
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
source = "github.com/ibuler/crypto"
[[constraint]]
name = "gopkg.in/yaml.v2"
version = "2.2.2"
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "gopkg.in/natefinch/lumberjack.v2"
version = "2.1.0"
[[constraint]]
name = "github.com/aliyun/aliyun-oss-go-sdk"
version = "1.9.6"
[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.19.33"
[[constraint]]
name = "github.com/Azure/azure-storage-blob-go"
version = "0.6.0"
[[constraint]]
name = "github.com/elastic/go-elasticsearch"
version = "0.0.0"
......@@ -21,17 +21,7 @@ koko是golang版本的的coco;重构了coco的SSH/SFTP服务和web terminal服
go get github.com/jumpserver/koko
```
2.下载依赖包
koko的项目使用[dep](https://github.com/golang/dep)管理依赖包, 需要预先安装dep;
```shell
dep ensure
```
> 由于网络问题,部分依赖包需要走代理. 需要自行设置http_proxy和https_proxy代理便于下载
3.编译应用
2.编译应用
先进入cmd文件夹, 并构建应用.
```shell
......@@ -41,7 +31,7 @@ cd cmd
make linux
```
> 如果构建成功,会在项目下自动生成build文件夹,里面包含当前分支的linux 64位版本压缩包.
因为使用go mod进行依赖管理,可以设置GOPROXY=https://goproxy.io代理下载部分依赖包。
## 使用
......@@ -74,4 +64,3 @@ cd cmd
make docker
```
构建成功后,生成koko镜像
> 由于网络问题,部分依赖包需要走代理. 需要自行设置http_proxy和https_proxy代理便于下载
......@@ -37,7 +37,7 @@ $(PLATFORMS): Asset
.PHONY: docker
docker:
@echo "build docker images"
docker build -t koko --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) $(BASEPATH)/../
docker build -t koko --build-arg GOPROXY=$(GOPROXY) $(BASEPATH)/../
.PHONY: clean
clean:
......
#!/bin/sh
#
if [ ! -f "/opt/koko/config.yml" ]; then
cp /opt/koko/config_example.yml /opt/koko/config.yml
sed -i '5d' /opt/koko/config.yml
sed -i "5i CORE_HOST: $CORE_HOST" /opt/koko/config.yml
sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/koko/config.yml
sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/koko/config.yml
if [ ! -f "/opt/coco/config.yml" ]; then
cp /opt/coco/config_example.yml /opt/coco/config.yml
sed -i '5d' /opt/coco/config.yml
sed -i "5i CORE_HOST: $CORE_HOST" /opt/coco/config.yml
sed -i "s/BOOTSTRAP_TOKEN: <PleasgeChangeSameWithJumpserver>/BOOTSTRAP_TOKEN: $BOOTSTRAP_TOKEN/g" /opt/coco/config.yml
sed -i "s/# LOG_LEVEL: INFO/LOG_LEVEL: ERROR/g" /opt/coco/config.yml
fi
cd /opt/koko
cd /opt/coco
./koko
module github.com/jumpserver/koko
go 1.12
require (
github.com/Azure/azure-pipeline-go v0.1.9
github.com/Azure/azure-storage-blob-go v0.6.0
github.com/LeeEirc/elfinder v0.0.0-20190604073433-f4f8357e9220
github.com/aliyun/aliyun-oss-go-sdk v1.9.8
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239
github.com/aws/aws-sdk-go v1.19.46
github.com/elastic/go-elasticsearch v0.0.0
github.com/gliderlabs/ssh v0.2.3-0.20190711180243-866d0ddf7991
github.com/go-playground/form v3.1.4+incompatible
github.com/googollee/go-socket.io v1.4.2-0.20190317095603-ed07a7212e28
github.com/gorilla/mux v1.7.2
github.com/gorilla/websocket v1.4.0
github.com/jarcoal/httpmock v1.0.4
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
github.com/konsorten/go-windows-terminal-sequences v1.0.2
github.com/kr/fs v0.1.0
github.com/kr/pty v1.1.4
github.com/leonelquinteros/gotext v1.4.0
github.com/mattn/go-runewidth v0.0.4
github.com/olekukonko/tablewriter v0.0.1
github.com/pkg/errors v0.8.1
github.com/pkg/sftp v1.10.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3
gopkg.in/yaml.v2 v2.2.2
)
replace (
github.com/gliderlabs/ssh v0.2.3-0.20190711180243-866d0ddf7991 => github.com/ibuler/ssh v0.1.6-0.20190509065047-1c00c8e8b607
github.com/googollee/go-engine.io v1.4.1 => github.com/ibuler/go-engine.io v1.4.2-0.20190529094538-7786d3a289b9
github.com/googollee/go-socket.io v1.4.2-0.20190317095603-ed07a7212e28 => github.com/LeeEirc/go-socket.io v1.4.2-0.20190610105739-e344e8b5a55a
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 => github.com/ibuler/crypto v0.0.0-20190509101200-a7099eef26a7
)
This diff is collapsed.
......@@ -170,7 +170,7 @@ func (c *Client) Do(method, url string, data, res interface{}, params ...map[str
if res != nil {
err = json.Unmarshal(body, res)
if err != nil {
msg := fmt.Sprintf("%s %s failed, unmarshal '%s' response failed: %s", req.Method, req.URL, body, err)
msg := fmt.Sprintf("%s %s failed, unmarshal '%s' response failed: %s", req.Method, req.URL, body[:12], err)
err = errors.New(msg)
return
}
......
......@@ -9,26 +9,26 @@ import (
func GetUserAssets(userID, cachePolicy string) (assets model.AssetList) {
if cachePolicy == "" {
cachePolicy = "0"
cachePolicy = "1"
}
payload := map[string]string{"cache_policy": cachePolicy}
Url := fmt.Sprintf(UserAssetsURL, userID)
err := authClient.Get(Url, &assets, payload)
if err != nil {
logger.Error("GetUserAssets---err")
logger.Error("Get user assets error: ", err)
}
return
}
func GetUserNodes(userID, cachePolicy string) (nodes model.NodeList) {
if cachePolicy == "" {
cachePolicy = "0"
cachePolicy = "1"
}
payload := map[string]string{"cache_policy": cachePolicy}
Url := fmt.Sprintf(UserNodesAssetsURL, userID)
err := authClient.Get(Url, &nodes, payload)
if err != nil {
logger.Error("GetUserNodes err")
logger.Error("Get user nodes error: ", err)
}
return
}
......@@ -39,6 +39,7 @@ func ValidateUserAssetPermission(userID, assetID, systemUserID, action string) b
"asset_id": assetID,
"system_user_id": systemUserID,
"action_name": action,
"cache_policy": "1",
}
Url := ValidateUserAssetPermissionURL
var res struct {
......
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