Skip to content

Commit

Permalink
Gate (#249)
Browse files Browse the repository at this point in the history
* gate
  • Loading branch information
e154 authored Dec 11, 2023
1 parent a087f5b commit 30cebf4
Show file tree
Hide file tree
Showing 96 changed files with 3,993 additions and 364 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,17 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: upload cli linux amd64 artifact
- name: upload gate linux arm-7 artifact
uses: softprops/action-gh-release@v1
with:
files: /home/runner/work/smart-home/smart-home/cli-linux-amd64
files: /home/runner/work/smart-home/smart-home/gate-linux-arm-7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: upload gate linux amd64 artifact
uses: softprops/action-gh-release@v1
with:
files: /home/runner/work/smart-home/smart-home/gate-linux-amd64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ jobs:

- name: trying to build
id: build-all
run: make build_server build_cli build_structure build_common_structure build_archive docker_image
run: make build_server build_cli build_gate build_structure build_common_structure build_archive server_docker_image gate_docker_image
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ server-*
build/public/*
build/admin/*
smart-home-common.tar.gz
/cmd/gate/gate
/cmd/gate/conf
/gate-darwin-10.6-arm64
/gate-linux-amd64
/gate-linux-arm-5
/gate-linux-arm-6
/gate-linux-arm-7
/gate-darwin-10.6-amd64
85 changes: 66 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.PHONY: get_deps fmt
.DEFAULT_GOAL := build
build: build_public build_server build_cli
build: build_public build_server build_cli build_gate
tests: lint test
all: build build_structure build_common_structure build_archive docker_image
deploy: docker_image_upload
all: build build_structure build_common_structure build_archive server_docker_image gate_docker_image
deploy: server_docker_image_upload gate_docker_image_upload

EXEC=server
CLI=cli
GATE=gate
ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SERVER_DIR = ${ROOT}/tmp/${EXEC}
GATE_DIR = ${ROOT}/tmp/${GATE}
COMMON_DIR = ${ROOT}/tmp/common
ARCHIVE=smart-home-common.tar.gz

Expand All @@ -22,10 +24,13 @@ GENERATED_VALUE=$(shell date -u +'%Y-%m-%dT%H:%M:%S%z')
DEVELOPERS_VALUE=delta54<[email protected]>
BUILD_NUMBER_VALUE=$(shell echo ${TRAVIS_BUILD_NUMBER})

IMAGE=smart-home-${EXEC}
SERVER_IMAGE=smart-home-${EXEC}
GATE_IMAGE=smart-home-${GATE}
DOCKER_ACCOUNT=e154
DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${IMAGE}:${RELEASE_VERSION}
DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${IMAGE}:latest
SERVER_DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${SERVER_IMAGE}:${RELEASE_VERSION}
SERVER_DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${SERVER_IMAGE}:latest
GATE_DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${GATE_IMAGE}:${RELEASE_VERSION}
GATE_DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${GATE_IMAGE}:latest

VERSION_VAR=${PROJECT}/version.VersionString
REV_VAR=${PROJECT}/version.RevisionString
Expand All @@ -34,7 +39,7 @@ GENERATED_VAR=${PROJECT}/version.GeneratedString
DEVELOPERS_VAR=${PROJECT}/version.DevelopersString
BUILD_NUMBER_VAR=${PROJECT}/version.BuildNumString
DOCKER_IMAGE_VAR=${PROJECT}/version.DockerImageString
GO_BUILD_LDFLAGS= -s -w -X ${VERSION_VAR}=${RELEASE_VERSION} -X ${REV_VAR}=${REV_VALUE} -X ${REV_URL_VAR}=${REV_URL_VALUE} -X ${GENERATED_VAR}=${GENERATED_VALUE} -X ${DEVELOPERS_VAR}=${DEVELOPERS_VALUE} -X ${BUILD_NUMBER_VAR}=${BUILD_NUMBER_VALUE} -X ${DOCKER_IMAGE_VAR}=${DOCKER_IMAGE_VER}
GO_BUILD_LDFLAGS= -s -w -X ${VERSION_VAR}=${RELEASE_VERSION} -X ${REV_VAR}=${REV_VALUE} -X ${REV_URL_VAR}=${REV_URL_VALUE} -X ${GENERATED_VAR}=${GENERATED_VALUE} -X ${DEVELOPERS_VAR}=${DEVELOPERS_VALUE} -X ${BUILD_NUMBER_VAR}=${BUILD_NUMBER_VALUE} -X ${DOCKER_IMAGE_VAR}=${SERVER_DOCKER_IMAGE_VER}
GO_BUILD_FLAGS= -a -installsuffix cgo -v --ldflags '${GO_BUILD_LDFLAGS}'
GO_BUILD_ENV= CGO_ENABLED=0
GO_BUILD_TAGS= -tags 'production'
Expand Down Expand Up @@ -113,6 +118,15 @@ build_cli:
cd ${ROOT}/cmd/cli && ${GO_BUILD_ENV} GOOS=darwin GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${CLI}-darwin-10.6-amd64
cd ${ROOT}/cmd/cli && ${GO_BUILD_ENV} GOOS=darwin GOARCH=arm64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${CLI}-darwin-10.6-arm64

build_gate:
@echo MARK: build gate
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-amd64
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=7 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-7
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=6 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-6
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=5 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-5
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=darwin GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-darwin-10.6-amd64
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=darwin GOARCH=arm64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-darwin-10.6-arm64

build_public:
@echo MARK: build public
echo -e "node version.\n" && \
Expand All @@ -136,7 +150,9 @@ server:
oapi-codegen -generate types -package stub ${ROOT}/api/api.swagger3.yaml > ${ROOT}/api/stub/types.go

build_structure:
@echo MARK: create app structure
@echo MARK: create server structure
cd ${ROOT}
ls -ll
mkdir -p ${SERVER_DIR}
mkdir -p ${SERVER_DIR}/snapshots
cd ${SERVER_DIR}
Expand All @@ -145,7 +161,6 @@ build_structure:
cp ${ROOT}/LICENSE ${SERVER_DIR}
cp ${ROOT}/README* ${SERVER_DIR}
cp ${ROOT}/CONTRIBUTING.md ${SERVER_DIR}
cp ${ROOT}/bin/docker/Dockerfile ${SERVER_DIR}
cp ${ROOT}/bin/server-installer.sh ${SERVER_DIR}
chmod +x ${SERVER_DIR}/data/scripts/ping.sh
cp ${ROOT}/${EXEC}-linux-amd64 ${SERVER_DIR}
Expand All @@ -158,6 +173,21 @@ build_structure:
cp ${ROOT}/${CLI}-darwin-10.6-arm64 ${SERVER_DIR}
cp ${ROOT}/${CLI}-linux-amd64 ${SERVER_DIR}
cp ${ROOT}/bin/server ${SERVER_DIR}
@echo MARK: create gate structure
mkdir -p ${GATE_DIR}
mkdir -p ${GATE_DIR}/conf
cd ${GATE_DIR}
cp ${ROOT}/conf/config.gate.json ${GATE_DIR}/conf
cp ${ROOT}/LICENSE ${GATE_DIR}
cp ${ROOT}/README* ${GATE_DIR}
cp ${ROOT}/CONTRIBUTING.md ${GATE_DIR}
cp ${ROOT}/${GATE}-linux-amd64 ${GATE_DIR}
cp ${ROOT}/${GATE}-linux-arm-7 ${GATE_DIR}
cp ${ROOT}/${GATE}-linux-arm-6 ${GATE_DIR}
cp ${ROOT}/${GATE}-linux-arm-5 ${GATE_DIR}
cp ${ROOT}/${GATE}-darwin-10.6-amd64 ${GATE_DIR}
cp ${ROOT}/${GATE}-darwin-10.6-arm64 ${GATE_DIR}
cp ${ROOT}/bin/gate ${GATE_DIR}

build_common_structure:
@echo MARK: create common structure
Expand All @@ -169,7 +199,6 @@ build_common_structure:
cp ${ROOT}/LICENSE ${COMMON_DIR}
cp ${ROOT}/README* ${COMMON_DIR}
cp ${ROOT}/CONTRIBUTING.md ${COMMON_DIR}
cp ${ROOT}/bin/docker/Dockerfile ${COMMON_DIR}
cp ${ROOT}/bin/server-installer.sh ${COMMON_DIR}
chmod +x ${COMMON_DIR}/data/scripts/ping.sh
cp ${ROOT}/bin/server ${COMMON_DIR}
Expand Down Expand Up @@ -214,26 +243,44 @@ docs_deploy:
git push -q upstream HEAD:gh-pages
echo -e "Done documentation deploy.\n"

docker_image:
cd ${SERVER_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile -t ${DOCKER_ACCOUNT}/${IMAGE} .
server_docker_image:
cd ${SERVER_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile.server -t ${DOCKER_ACCOUNT}/${SERVER_IMAGE} .

server_docker_image_upload:
#echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_LATEST}
docker push ${SERVER_DOCKER_IMAGE_VER}
docker push ${SERVER_DOCKER_IMAGE_LATEST}

gate_docker_image:
cd ${GATE_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile.gate -t ${DOCKER_ACCOUNT}/${GATE_IMAGE} .

docker_image_upload:
echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_LATEST}
docker push ${DOCKER_IMAGE_VER}
docker push ${DOCKER_IMAGE_LATEST}
gate_docker_image_upload:
#echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_LATEST}
docker push ${GATE_DOCKER_IMAGE_VER}
docker push ${GATE_DOCKER_IMAGE_LATEST}

clean:
@echo MARK: clean
rm -rf ${SERVER_DIR}
rm -rf ${GATE_DIR}
rm -f ${ROOT}/${EXEC}-linux-amd64
rm -f ${ROOT}/${EXEC}-linux-arm-7
rm -f ${ROOT}/${EXEC}-linux-arm-6
rm -f ${ROOT}/${EXEC}-linux-arm-5
rm -f ${ROOT}/${EXEC}-darwin-10.6-amd64
rm -f ${ROOT}/${EXEC}-darwin-10.6-arm64
rm -f ${ROOT}/${GATE}-linux-amd64
rm -f ${ROOT}/${GATE}-linux-arm-7
rm -f ${ROOT}/${GATE}-linux-arm-6
rm -f ${ROOT}/${GATE}-linux-arm-5
rm -f ${ROOT}/${GATE}-darwin-10.6-amd64
rm -f ${ROOT}/${GATE}-darwin-10.6-arm64
rm -f ${ROOT}/${CLI}-linux-amd64
rm -f ${ROOT}/${CLI}-darwin-10.6-amd64
rm -f ${ROOT}/${CLI}-darwin-10.6-arm64
Expand Down
71 changes: 53 additions & 18 deletions Makefile.local
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.PHONY: get_deps fmt
.DEFAULT_GOAL := build
build: build_public build_server build_cli
build: build_public build_server build_cli build_gate
tests: lint test
all: build build_structure build_common_structure build_archive docker_image
deploy: docker_image_upload
all: build build_structure build_common_structure build_archive server_docker_image gate_docker_image
deploy: server_docker_image_upload gate_docker_image_upload

EXEC=server
CLI=cli
GATE=gate
ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SERVER_DIR = ${ROOT}/tmp/${EXEC}
GATE_DIR = ${ROOT}/tmp/${GATE}
COMMON_DIR = ${ROOT}/tmp/common
ARCHIVE=smart-home-common.tar.gz

Expand All @@ -23,11 +25,14 @@ DEVELOPERS_VALUE=delta54<[email protected]>
BUILD_NUMBER_VALUE=$(shell echo ${TRAVIS_BUILD_NUMBER})
RELEASE_VERSION ?= v0.1.0

IMAGE=smart-home-${EXEC}
SERVER_IMAGE=smart-home-${EXEC}
GATE_IMAGE=smart-home-${GATE}
SERVER ?= 192.168.43.127
DOCKER_ACCOUNT ?= ${SERVER}:5000
DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${IMAGE}:${RELEASE_VERSION}
DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${IMAGE}:latest
SERVER_DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${SERVER_IMAGE}:${RELEASE_VERSION}
SERVER_DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${SERVER_IMAGE}:latest
GATE_DOCKER_IMAGE_VER=${DOCKER_ACCOUNT}/${GATE_IMAGE}:${RELEASE_VERSION}
GATE_DOCKER_IMAGE_LATEST=${DOCKER_ACCOUNT}/${GATE_IMAGE}:latest

VERSION_VAR=${PROJECT}/version.VersionString
REV_VAR=${PROJECT}/version.RevisionString
Expand All @@ -36,7 +41,7 @@ GENERATED_VAR=${PROJECT}/version.GeneratedString
DEVELOPERS_VAR=${PROJECT}/version.DevelopersString
BUILD_NUMBER_VAR=${PROJECT}/version.BuildNumString
DOCKER_IMAGE_VAR=${PROJECT}/version.DockerImageString
GO_BUILD_LDFLAGS= -s -w -X ${VERSION_VAR}=${RELEASE_VERSION} -X ${REV_VAR}=${REV_VALUE} -X ${REV_URL_VAR}=${REV_URL_VALUE} -X ${GENERATED_VAR}=${GENERATED_VALUE} -X ${DEVELOPERS_VAR}=${DEVELOPERS_VALUE} -X ${BUILD_NUMBER_VAR}=${BUILD_NUMBER_VALUE} -X ${DOCKER_IMAGE_VAR}=${DOCKER_IMAGE_VER}
GO_BUILD_LDFLAGS= -s -w -X ${VERSION_VAR}=${RELEASE_VERSION} -X ${REV_VAR}=${REV_VALUE} -X ${REV_URL_VAR}=${REV_URL_VALUE} -X ${GENERATED_VAR}=${GENERATED_VALUE} -X ${DEVELOPERS_VAR}=${DEVELOPERS_VALUE} -X ${BUILD_NUMBER_VAR}=${BUILD_NUMBER_VALUE} -X ${DOCKER_IMAGE_VAR}=${SERVER_DOCKER_IMAGE_VER}
GO_BUILD_FLAGS= -a -installsuffix cgo -v --ldflags '${GO_BUILD_LDFLAGS}'
GO_BUILD_ENV= CGO_ENABLED=0
GO_BUILD_TAGS= -tags 'production'
Expand Down Expand Up @@ -115,6 +120,15 @@ build_cli:
#cd ${ROOT}/cmd/cli && ${GO_BUILD_ENV} GOOS=darwin GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${CLI}-darwin-10.6-amd64
#cd ${ROOT}/cmd/cli && ${GO_BUILD_ENV} GOOS=darwin GOARCH=arm64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${CLI}-darwin-10.6-arm64

build_gate:
@echo MARK: build gate
#cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-amd64
cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=7 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-7
#cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=6 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-6
#cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=linux GOARCH=arm GOARM=5 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-linux-arm-5
#cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=darwin GOARCH=amd64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-darwin-10.6-amd64
#cd ${ROOT}/cmd/gate && ${GO_BUILD_ENV} GOOS=darwin GOARCH=arm64 go build ${GO_BUILD_FLAGS} ${GO_BUILD_TAGS} -o ${ROOT}/${GATE}-darwin-10.6-arm64

build_public:
@echo MARK: build public
echo -e "node version.\n" && \
Expand All @@ -136,7 +150,7 @@ server:
oapi-codegen -generate types -package stub ${ROOT}/api/api.swagger3.yaml > ${ROOT}/api/stub/types.go

build_structure:
@echo MARK: create app structure
@echo MARK: create server structure
mkdir -p ${SERVER_DIR}
mkdir -p ${SERVER_DIR}/snapshots
cd ${SERVER_DIR}
Expand All @@ -145,11 +159,20 @@ build_structure:
cp ${ROOT}/LICENSE ${SERVER_DIR}
cp ${ROOT}/README* ${SERVER_DIR}
cp ${ROOT}/CONTRIBUTING.md ${SERVER_DIR}
cp ${ROOT}/bin/docker/Dockerfile ${SERVER_DIR}
cp ${ROOT}/bin/server-installer.sh ${SERVER_DIR}
chmod +x ${SERVER_DIR}/data/scripts/ping.sh
cp ${ROOT}/${EXEC}-linux-arm-7 ${SERVER_DIR}
cp ${ROOT}/bin/server ${SERVER_DIR}
@echo MARK: create gate structure
mkdir -p ${GATE_DIR}
mkdir -p ${GATE_DIR}/conf
cd ${GATE_DIR}
cp ${ROOT}/conf/config.gate.json ${GATE_DIR}/conf
cp ${ROOT}/LICENSE ${GATE_DIR}
cp ${ROOT}/README* ${GATE_DIR}
cp ${ROOT}/CONTRIBUTING.md ${GATE_DIR}
cp ${ROOT}/${GATE}-linux-arm-7 ${GATE_DIR}
cp ${ROOT}/bin/gate ${GATE_DIR}

build_common_structure:
@echo MARK: create common structure
Expand All @@ -161,7 +184,6 @@ build_common_structure:
cp ${ROOT}/LICENSE ${COMMON_DIR}
cp ${ROOT}/README* ${COMMON_DIR}
cp ${ROOT}/CONTRIBUTING.md ${COMMON_DIR}
cp ${ROOT}/bin/docker/Dockerfile ${COMMON_DIR}
cp ${ROOT}/bin/server-installer.sh ${COMMON_DIR}
chmod +x ${COMMON_DIR}/data/scripts/ping.sh
cp ${ROOT}/bin/server ${COMMON_DIR}
Expand Down Expand Up @@ -206,21 +228,34 @@ docs_deploy:
git push -q upstream HEAD:gh-pages
echo -e "Done documentation deploy.\n"

docker_image:
cd ${SERVER_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile -t ${DOCKER_ACCOUNT}/${IMAGE} .
server_docker_image:
cd ${SERVER_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile.server -t ${DOCKER_ACCOUNT}/${SERVER_IMAGE} .

server_docker_image_upload:
#echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${SERVER_IMAGE} ${SERVER_DOCKER_IMAGE_LATEST}
docker push ${SERVER_DOCKER_IMAGE_VER}
docker push ${SERVER_DOCKER_IMAGE_LATEST}

gate_docker_image:
cd ${GATE_DIR} && ls -ll && docker build -f ${ROOT}/bin/docker/Dockerfile.gate -t ${DOCKER_ACCOUNT}/${GATE_IMAGE} .

docker_image_upload:
gate_docker_image_upload:
#echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${IMAGE} ${DOCKER_IMAGE_LATEST}
docker push ${DOCKER_IMAGE_VER}
docker push ${DOCKER_IMAGE_LATEST}
docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_VER}
echo -e "docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_LATEST}"
docker tag ${DOCKER_ACCOUNT}/${GATE_IMAGE} ${GATE_DOCKER_IMAGE_LATEST}
docker push ${GATE_DOCKER_IMAGE_VER}
docker push ${GATE_DOCKER_IMAGE_LATEST}

clean:
@echo MARK: clean
rm -rf ${SERVER_DIR}
rm -rf ${GATE_DIR}
rm -f ${ROOT}/${EXEC}-linux-arm-7
rm -f ${ROOT}/${GATE}-linux-arm-7

front_client:
@echo MARK: generate front client lib
Expand Down
12 changes: 6 additions & 6 deletions adaptors/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type IVariable interface {
GetByName(ctx context.Context, name string) (ver m.Variable, err error)
Update(ctx context.Context, variable m.Variable) (err error)
Delete(ctx context.Context, name string) (err error)
List(ctx context.Context, limit, offset int64, orderBy, sort string, system bool) (list []m.Variable, total int64, err error)
List(ctx context.Context, limit, offset int64, orderBy, sort string, system bool, name string) (list []m.Variable, total int64, err error)
Search(ctx context.Context, query string, limit, offset int) (list []m.Variable, total int64, err error)
fromDb(dbVer db.Variable) (ver m.Variable)
toDb(ver m.Variable) (dbVer db.Variable)
Expand Down Expand Up @@ -97,9 +97,9 @@ func (n *Variable) Delete(ctx context.Context, name string) (err error) {
}

// List ...
func (n *Variable) List(ctx context.Context, limit, offset int64, orderBy, sort string, system bool) (list []m.Variable, total int64, err error) {
func (n *Variable) List(ctx context.Context, limit, offset int64, orderBy, sort string, system bool, name string) (list []m.Variable, total int64, err error) {
var dbList []db.Variable
if dbList, total, err = n.table.List(ctx, int(limit), int(offset), orderBy, sort, system); err != nil {
if dbList, total, err = n.table.List(ctx, int(limit), int(offset), orderBy, sort, system, name); err != nil {
return
}

Expand All @@ -113,15 +113,15 @@ func (n *Variable) List(ctx context.Context, limit, offset int64, orderBy, sort
}

// Search ...
func (s *Variable) Search(ctx context.Context, query string, limit, offset int) (list []m.Variable, total int64, err error) {
func (n *Variable) Search(ctx context.Context, query string, limit, offset int) (list []m.Variable, total int64, err error) {
var dbList []db.Variable
if dbList, total, err = s.table.Search(ctx, query, limit, offset); err != nil {
if dbList, total, err = n.table.Search(ctx, query, limit, offset); err != nil {
return
}

list = make([]m.Variable, 0)
for _, dbVer := range dbList {
list = append(list, s.fromDb(dbVer))
list = append(list, n.fromDb(dbVer))
}

return
Expand Down
Loading

0 comments on commit 30cebf4

Please sign in to comment.