Added setup files and removed unused files
This commit is contained in:
parent
466d69eae0
commit
46c021bded
68
Makefile
68
Makefile
@ -1,68 +0,0 @@
|
||||
export PATH := $(GOPATH)/bin:$(PATH)
|
||||
export GO111MODULE=on
|
||||
LDFLAGS := -s -w
|
||||
|
||||
all: fmt build
|
||||
|
||||
build: frps frpc
|
||||
|
||||
# compile assets into binary file
|
||||
file:
|
||||
rm -rf ./assets/frps/static/*
|
||||
rm -rf ./assets/frpc/static/*
|
||||
cp -rf ./web/frps/dist/* ./assets/frps/static
|
||||
cp -rf ./web/frpc/dist/* ./assets/frpc/static
|
||||
|
||||
fmt:
|
||||
go fmt ./...
|
||||
|
||||
fmt-more:
|
||||
gofumpt -l -w .
|
||||
|
||||
gci:
|
||||
gci write -s standard -s default -s "prefix(github.com/fatedier/frp/)" ./
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
frps:
|
||||
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frps ./cmd/frps
|
||||
|
||||
frpc:
|
||||
env CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/frpc ./cmd/frpc
|
||||
|
||||
test: gotest
|
||||
|
||||
gotest:
|
||||
go test -v --cover ./assets/...
|
||||
go test -v --cover ./cmd/...
|
||||
go test -v --cover ./client/...
|
||||
go test -v --cover ./server/...
|
||||
go test -v --cover ./pkg/...
|
||||
|
||||
e2e:
|
||||
./hack/run-e2e.sh
|
||||
|
||||
e2e-trace:
|
||||
DEBUG=true LOG_LEVEL=trace ./hack/run-e2e.sh
|
||||
|
||||
e2e-compatibility-last-frpc:
|
||||
if [ ! -d "./lastversion" ]; then \
|
||||
TARGET_DIRNAME=lastversion ./hack/download.sh; \
|
||||
fi
|
||||
FRPC_PATH="`pwd`/lastversion/frpc" ./hack/run-e2e.sh
|
||||
rm -r ./lastversion
|
||||
|
||||
e2e-compatibility-last-frps:
|
||||
if [ ! -d "./lastversion" ]; then \
|
||||
TARGET_DIRNAME=lastversion ./hack/download.sh; \
|
||||
fi
|
||||
FRPS_PATH="`pwd`/lastversion/frps" ./hack/run-e2e.sh
|
||||
rm -r ./lastversion
|
||||
|
||||
alltest: vet gotest e2e
|
||||
|
||||
clean:
|
||||
rm -f ./bin/frpc
|
||||
rm -f ./bin/frps
|
||||
rm -rf ./lastversion
|
@ -1,27 +0,0 @@
|
||||
export PATH := $(GOPATH)/bin:$(PATH)
|
||||
export GO111MODULE=on
|
||||
LDFLAGS := -s -w
|
||||
|
||||
os-archs=darwin:amd64 darwin:arm64 freebsd:386 freebsd:amd64 linux:386 linux:amd64 linux:arm linux:arm64 windows:386 windows:amd64 windows:arm64 linux:mips64 linux:mips64le linux:mips:softfloat linux:mipsle:softfloat linux:riscv64
|
||||
|
||||
all: build
|
||||
|
||||
build: app
|
||||
|
||||
app:
|
||||
@$(foreach n, $(os-archs),\
|
||||
os=$(shell echo "$(n)" | cut -d : -f 1);\
|
||||
arch=$(shell echo "$(n)" | cut -d : -f 2);\
|
||||
gomips=$(shell echo "$(n)" | cut -d : -f 3);\
|
||||
target_suffix=$${os}_$${arch};\
|
||||
echo "Build $${os}-$${arch}...";\
|
||||
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frpc_$${target_suffix} ./cmd/frpc;\
|
||||
env CGO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} GOMIPS=$${gomips} go build -trimpath -ldflags "$(LDFLAGS)" -o ./release/frps_$${target_suffix} ./cmd/frps;\
|
||||
echo "Build $${os}-$${arch} done";\
|
||||
)
|
||||
@mv ./release/frpc_windows_386 ./release/frpc_windows_386.exe
|
||||
@mv ./release/frps_windows_386 ./release/frps_windows_386.exe
|
||||
@mv ./release/frpc_windows_amd64 ./release/frpc_windows_amd64.exe
|
||||
@mv ./release/frps_windows_amd64 ./release/frps_windows_amd64.exe
|
||||
@mv ./release/frpc_windows_arm64 ./release/frpc_windows_arm64.exe
|
||||
@mv ./release/frps_windows_arm64 ./release/frps_windows_arm64.exe
|
99
README_zh.md
99
README_zh.md
@ -1,99 +0,0 @@
|
||||
# frp
|
||||
|
||||
[](https://circleci.com/gh/fatedier/frp)
|
||||
[](https://github.com/fatedier/frp/releases)
|
||||
|
||||
[README](README.md) | [中文文档](README_zh.md)
|
||||
|
||||
frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议,且支持 P2P 通信。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。
|
||||
|
||||
<h3 align="center">Gold Sponsors</h3>
|
||||
<!--gold sponsors start-->
|
||||
<p align="center">
|
||||
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=frp&utm_source=github" target="_blank">
|
||||
<img width="350px" src="https://raw.githubusercontent.com/fatedier/frp/dev/doc/pic/sponsor_workos.png">
|
||||
</a>
|
||||
</p>
|
||||
<!--gold sponsors end-->
|
||||
|
||||
## 为什么使用 frp ?
|
||||
|
||||
通过在具有公网 IP 的节点上部署 frp 服务端,可以轻松地将内网服务穿透到公网,同时提供诸多专业的功能特性,这包括:
|
||||
|
||||
* 客户端服务端通信支持 TCP、QUIC、KCP 以及 Websocket 等多种协议。
|
||||
* 采用 TCP 连接流式复用,在单个连接间承载更多请求,节省连接建立时间,降低请求延迟。
|
||||
* 代理组间的负载均衡。
|
||||
* 端口复用,多个服务通过同一个服务端端口暴露。
|
||||
* 支持 P2P 通信,流量不经过服务器中转,充分利用带宽资源。
|
||||
* 多个原生支持的客户端插件(静态文件查看,HTTPS/HTTP 协议转换,HTTP、SOCK5 代理等),便于独立使用 frp 客户端完成某些工作。
|
||||
* 高度扩展性的服务端插件系统,易于结合自身需求进行功能扩展。
|
||||
* 服务端和客户端 UI 页面。
|
||||
|
||||
## 开发状态
|
||||
|
||||
frp 目前已被很多公司广泛用于测试、生产环境。
|
||||
|
||||
master 分支用于发布稳定版本,dev 分支用于开发,您可以尝试下载最新的 release 版本进行测试。
|
||||
|
||||
我们正在进行 v2 大版本的开发,将会尝试在各个方面进行重构和升级,且不会与 v1 版本进行兼容,预计会持续较长的一段时间。
|
||||
|
||||
现在的 v0 版本将会在合适的时间切换为 v1 版本并且保证兼容性,后续只做 bug 修复和优化,不再进行大的功能性更新。
|
||||
|
||||
### 关于 v2 的一些说明
|
||||
|
||||
当前整体形势不佳,面临的生活工作压力很大。
|
||||
|
||||
v2 版本的复杂度和难度比我们预期的要高得多。我只能利用零散的时间进行开发,而且由于上下文经常被打断,效率极低。由于这种情况可能会持续一段时间,我们仍然会在当前版本上进行一些优化和迭代,直到我们有更多空闲时间来推进大版本的重构。
|
||||
|
||||
v2 的构想是基于我多年在云原生领域,特别是在 K8s 和 ServiceMesh 方面的工作经验和思考。它的核心是一个现代化的四层和七层代理,类似于 envoy。这个代理本身高度可扩展,不仅可以用于实现内网穿透的功能,还可以应用于更多领域。在这个高度可扩展的内核基础上,我们将实现 frp v1 中的所有功能,并且能够以一种更加优雅的方式实现原先架构中无法实现或不易实现的功能。同时,我们将保持高效的开发和迭代能力。
|
||||
|
||||
除此之外,我希望 frp 本身也成为一个高度可扩展的系统和平台,就像我们可以基于 K8s 提供一系列扩展能力一样。在 K8s 上,我们可以根据企业需求进行定制化开发,例如使用 CRD、controller 模式、webhook、CSI 和 CNI 等。在 frp v1 中,我们引入了服务端插件的概念,实现了一些简单的扩展性。但是,它实际上依赖于简单的 HTTP 协议,并且需要用户自己启动独立的进程和管理。这种方式远远不够灵活和方便,而且现实世界的需求千差万别,我们不能期望一个由少数人维护的非营利性开源项目能够满足所有人的需求。
|
||||
|
||||
最后,我们意识到像配置管理、权限验证、证书管理和管理 API 等模块的当前设计并不够现代化。尽管我们可能在 v1 版本中进行一些优化,但确保兼容性是一个令人头疼的问题,需要投入大量精力来解决。
|
||||
|
||||
非常感谢您对 frp 的支持。
|
||||
|
||||
## 文档
|
||||
|
||||
完整文档已经迁移至 [https://gofrp.org](https://gofrp.org/docs)。
|
||||
|
||||
## 为 frp 做贡献
|
||||
|
||||
frp 是一个免费且开源的项目,我们欢迎任何人为其开发和进步贡献力量。
|
||||
|
||||
* 在使用过程中出现任何问题,可以通过 [issues](https://github.com/fatedier/frp/issues) 来反馈。
|
||||
* Bug 的修复可以直接提交 Pull Request 到 dev 分支。
|
||||
* 如果是增加新的功能特性,请先创建一个 issue 并做简单描述以及大致的实现方法,提议被采纳后,就可以创建一个实现新特性的 Pull Request。
|
||||
* 欢迎对说明文档做出改善,帮助更多的人使用 frp,特别是英文文档。
|
||||
* 贡献代码请提交 PR 至 dev 分支,master 分支仅用于发布稳定可用版本。
|
||||
* 如果你有任何其他方面的问题或合作,欢迎发送邮件至 fatedier@gmail.com 。
|
||||
|
||||
**提醒:和项目相关的问题最好在 [issues](https://github.com/fatedier/frp/issues) 中反馈,这样方便其他有类似问题的人可以快速查找解决方法,并且也避免了我们重复回答一些问题。**
|
||||
|
||||
## 赞助
|
||||
|
||||
如果您觉得 frp 对你有帮助,欢迎给予我们一定的捐助来维持项目的长期发展。
|
||||
|
||||
### Sponsors
|
||||
|
||||
长期赞助可以帮助我们保持项目的持续发展。
|
||||
|
||||
您可以通过 [GitHub Sponsors](https://github.com/sponsors/fatedier) 赞助我们。
|
||||
|
||||
国内用户可以通过 [爱发电](https://afdian.net/a/fatedier) 赞助我们。
|
||||
|
||||
企业赞助者可以将贵公司的 Logo 以及链接放置在项目 README 文件中。
|
||||
|
||||
### 知识星球
|
||||
|
||||
如果您想了解更多 frp 相关技术以及更新详解,或者寻求任何帮助及咨询,都可以通过微信扫描下方的二维码付费加入知识星球的官方社群:
|
||||
|
||||

|
||||
|
||||
### 支付宝扫码捐赠
|
||||
|
||||

|
||||
|
||||
### 微信支付捐赠
|
||||
|
||||

|
@ -1,3 +0,0 @@
|
||||
### Features
|
||||
|
||||
* Support Go 1.21.
|
373
setup
Executable file
373
setup
Executable file
@ -0,0 +1,373 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
[[ $@ =~ (^| )-d( |$) ]] && set -x || :
|
||||
|
||||
for i in GITHUB_USER GITHUB_TOKEN GOPATH; do
|
||||
[[ -n ${!i:-} ]] || {
|
||||
[[ ${i} == GITHUB_USER && -n ${GITHUB_USERNAME} ]] && GITHUB_USER=${GITHUB_USERNAME} && continue
|
||||
[[ ${i} == GITHUB_TOKEN && -n ${GITHUB_PASSWORD} ]] && GITHUB_TOKEN=${GITHUB_PASSWORD} && continue
|
||||
echo "${i} is not defined."; exit 1;
|
||||
}
|
||||
done
|
||||
|
||||
setup_yaml=`cat setup.yaml | yq '... comments=""'`
|
||||
|
||||
function get_config() {
|
||||
if [[ -n "${1:-}" ]]; then
|
||||
if [[ -z "${2:-}" ]]; then
|
||||
yq "${1}" <<<${setup_yaml} 2>/dev/null || return 1
|
||||
else
|
||||
yq "${1} // \"${2}\"" <<<${setup_yaml} 2>/dev/null
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Define global variables or load them from yaml config
|
||||
build_dir=$(get_config .build-dir "./build")
|
||||
tools=${build_dir}/tools
|
||||
specs_dir=${build_dir}/api-specs
|
||||
clients_dir=${build_dir}/clients
|
||||
|
||||
do_not_download=false
|
||||
generate_server=false
|
||||
generate_client=false
|
||||
clients_to_generate=()
|
||||
client_api_spec_urls=""
|
||||
build_binary=false
|
||||
build_image=false
|
||||
push_image=false
|
||||
|
||||
service_name=$(get_config .service-name)
|
||||
|
||||
# Docker image
|
||||
dockerhub_org=${DOCKERHUB_ORG:-tesselldev}
|
||||
docker_image_tag_versioned=${service_name}:$(get_config .docker-image-tag "v0.0.1")
|
||||
docker_image_tag_latest=${service_name}:latest
|
||||
|
||||
# Flyway docker image
|
||||
if [[ -d ${script_dir}/flyway && $(get_config .flyway-docker-image) != null && $(get_config .flyway-docker-image.name) != null ]]; then
|
||||
build_flyway_image=true
|
||||
flyway_image=${dockerhub_org}/$(get_config .flyway-docker-image.name):$(get_config .flyway-docker-image.tag "latest")
|
||||
flyway_dir=$(get_config .flyway-docker-image.dir "${script_dir}/flyway")
|
||||
fi
|
||||
|
||||
# Github url
|
||||
github_url=https://${GITHUB_TOKEN}@raw.githubusercontent.com/TessellDevelopment/tessell-api-specifications
|
||||
service_api_spec_url=${github_url}/$(get_config .service-api-spec.branch "main")/$(get_config .service-api-spec.filepath)
|
||||
common_api_spec_url=""
|
||||
if [[ -n $(get_config '. | has("common-api-spec")') ]]; then
|
||||
common_api_spec_url=${github_url}/$(get_config .common-api-spec.branch "main")/$(get_config .common-api-spec.filepath)
|
||||
fi
|
||||
|
||||
|
||||
function item_in_array () {
|
||||
local i match="${1}"
|
||||
shift
|
||||
for i; do [[ "${i}" == "${match}" ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
function download() {
|
||||
[[ $# -ge 2 ]] || { echo "Atleast two args need for function download, the 1st arg being the dest dir"; return 1; }
|
||||
mkdir -p ${1}
|
||||
pushd ${1} > /dev/null
|
||||
while [[ $# -gt 1 ]]; do shift; curl ${1} -O; done
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
function download_generator_jars() {
|
||||
for url in ${oag_cli_jar_url_client} ${oag_cli_jar_url_server} `[[ ${1:-} == client_only ]] || echo ${oag_gofiber_jar_url}` `[[ ${1:-} == server_only ]] || echo ${oag_client_jar_url}`; do
|
||||
[[ -s ${tools}/$(basename ${url}) ]] || download ${tools} ${url}
|
||||
done
|
||||
}
|
||||
|
||||
function download_common_api_spec() {
|
||||
echo "[*] Downloading common API spec."
|
||||
download ${specs_dir} ${common_api_spec_url}
|
||||
echo "[*] Completed download of common API spec."
|
||||
}
|
||||
|
||||
function generate_gofiber_boilerplate() {
|
||||
download_generator_jars server_only
|
||||
|
||||
if ! ${do_not_download}; then
|
||||
echo "[*] Downloading service API spec for generating GoFiber server boilerplate."
|
||||
download ${specs_dir} ${service_api_spec_url}
|
||||
echo "[*] Completed download of service API spec."
|
||||
download_common_api_spec
|
||||
fi
|
||||
|
||||
echo "[*] Generating GoFiber server boilerplate from OpenAPI spec."
|
||||
rm -rf ${build_dir}/server ./server
|
||||
java -cp "${tools}/${oag_gofiber_jar}:${tools}/${oag_cli_jar_for_server}" ${oag_gen_server} \
|
||||
-e pebble \
|
||||
--enable-post-process-file \
|
||||
--package-name server \
|
||||
-o ${build_dir} \
|
||||
-i ${specs_dir}/$(basename ${service_api_spec_url})
|
||||
|
||||
echo "[*] Completed GoFiber server boilerplate generation."
|
||||
|
||||
if $(get_config .create-symlinks "false"); then
|
||||
ln -sfn ${build_dir}/server ${script_dir}/server
|
||||
fi
|
||||
}
|
||||
|
||||
function add_all_clients_to_generate() {
|
||||
local filepath branch
|
||||
while read filepath branch; do
|
||||
client_api_spec_urls+="${github_url}/${branch}/${filepath/:} "
|
||||
done < <(get_config '.clients-specs | to_entries | .[].value | {.filepath: .branch // "main"}')
|
||||
while read filepath branch; do
|
||||
client_api_spec_urls+="${github_url}/${branch}/${filepath/:} "
|
||||
done < <(get_config '.clients-specs | to_entries | .[].value.deps[] | {.filepath: .branch // "main"}' | sort | uniq)
|
||||
echo ${client_api_spec_urls[@]}
|
||||
}
|
||||
|
||||
function add_client_to_generate() {
|
||||
local k=${1}
|
||||
local v=$(get_config ".client-key-map.${k} // \"\"")
|
||||
if [[ -z ${v} ]]; then
|
||||
if $(get_config ".clients-specs | has(\"${k}\")"); then
|
||||
v=${k}
|
||||
else
|
||||
echo "Unrecognized client (${k}) provided for specifying client to generate"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
clients_to_generate+=(${v})
|
||||
filepath=$(get_config ".clients-specs.${v}.filepath")
|
||||
branch=$(get_config ".clients-specs.${v}.branch // \"main\"")
|
||||
client_api_spec_urls+="${github_url}/${branch}/${filepath} "
|
||||
|
||||
while read filepath branch; do
|
||||
client_api_spec_urls+="${github_url}/${branch}/${filepath/:} "
|
||||
done < <(get_config ".clients-specs.${v}.deps[] | {.filepath: .branch // \"main\"}")
|
||||
}
|
||||
|
||||
function generate_required_api_clients() {
|
||||
download_generator_jars client_only
|
||||
|
||||
if ! ${do_not_download}; then
|
||||
if [[ ${#clients_to_generate[@]} -gt 0 ]]; then
|
||||
echo "[*] Starting download of API specs for only the following specified clients: ${clients_to_generate[@]}"
|
||||
else
|
||||
echo "[*] Starting download of API specs for all required clients."
|
||||
fi
|
||||
download ${specs_dir} ${client_api_spec_urls}
|
||||
download_common_api_spec
|
||||
echo "[*] Completed download of API specs for all required clients."
|
||||
fi
|
||||
|
||||
if [[ ${#clients_to_generate[@]} -gt 0 ]]; then
|
||||
echo "[*] Generating only the following specified clients: ${clients_to_generate[@]}"
|
||||
else
|
||||
echo "[*] Generating all required clients."
|
||||
fi
|
||||
|
||||
mkdir -p ${clients_dir}
|
||||
|
||||
local client filepath output_dir
|
||||
while read client filepath; do
|
||||
client=${client/:}
|
||||
[[ ${#clients_to_generate[@]} -gt 0 ]] && ! item_in_array "${client}" "${clients_to_generate[@]}" && continue || :
|
||||
output_dir=${clients_dir}/${client/:}
|
||||
rm -rf ${output_dir}
|
||||
|
||||
java -cp "${tools}/${oag_client_jar}:${tools}/${oag_cli_jar_for_client}" ${oag_gen_client} \
|
||||
-g go \
|
||||
--additional-properties isGoSubmodule=true \
|
||||
--additional-properties structPrefix=true \
|
||||
-i ${specs_dir}/$(basename ${filepath}) -o ${output_dir} --package-name ${client/:}
|
||||
|
||||
if $(get_config .create-symlinks "false"); then
|
||||
ln -sfn ${output_dir} ${script_dir}/${client/:}
|
||||
fi
|
||||
|
||||
rm -f ${output_dir}/go.*
|
||||
done < <(get_config '.clients-specs | to_entries | .[].value |= .filepath | from_entries')
|
||||
echo "[*] Completed generating all required clients."
|
||||
}
|
||||
|
||||
function go_fmt() {
|
||||
go fmt ./...
|
||||
goimports -w .
|
||||
}
|
||||
|
||||
function build_bin() {
|
||||
echo "[*] Building ${service_name} binary"
|
||||
go mod tidy
|
||||
go_fmt
|
||||
go build -o ${service_name}
|
||||
echo "[*] Binary for ${service_name} ready at ./${service_name}"
|
||||
}
|
||||
|
||||
function build_docker_image() {
|
||||
echo "[*] Building docker image"
|
||||
go mod tidy
|
||||
go_fmt
|
||||
docker build -t ${docker_image_tag_versioned} --build-arg GITHUB_USER=${GITHUB_USER} --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} ${no_cache:-} .
|
||||
docker tag ${docker_image_tag_versioned} ${docker_image_tag_latest}
|
||||
echo "[*] Built docker image with tag ${docker_image_tag_versioned}"
|
||||
echo "[*] Tagged docker image ${docker_image_tag_versioned} as ${docker_image_tag_latest}"
|
||||
if [[ ${dockerhub_org} == tesselldev ]]; then
|
||||
docker tag ${docker_image_tag_versioned} ${dockerhub_org}/${docker_image_tag_versioned}
|
||||
echo "[*] Tagged docker image ${docker_image_tag_versioned} as ${dockerhub_org}/${docker_image_tag_versioned}"
|
||||
fi
|
||||
if ${build_flyway_image:-false}; then
|
||||
cd ${flyway_dir}
|
||||
docker build --tag ${flyway_image} .
|
||||
cd - &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
function push_docker_image() {
|
||||
echo "[*] Pushing docker image with tag ${dockerhub_org}/${docker_image_tag_versioned}"
|
||||
docker push ${dockerhub_org}/${docker_image_tag_versioned} && \
|
||||
echo "[*] Successfully pushed docker image" || \
|
||||
echo "[*] Failed to push docker image"
|
||||
if ${build_flyway_image:-false}; then
|
||||
docker push ${flyway_image}
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
echo "[*] Cleaning up all generated code and downloaded artifacts."
|
||||
cd ${clients_dir}
|
||||
for d in `ls`; do rm -rf ${script_dir}/${d}; done
|
||||
cd - &>/dev/null
|
||||
rm -rf ${build_dir} vendor server
|
||||
}
|
||||
|
||||
# Main execution
|
||||
if [[ $@ =~ (^| )--(cln|clean|cleanup)( |$) ]]; then
|
||||
cleanup
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "${1}" in
|
||||
--dnd)
|
||||
do_not_download=true
|
||||
echo "[*] Received flag --dnd for 'Do not download'. Will not download any artifact."
|
||||
echo "[*] Note: Generator Jars will still be downloaded, if not present locally."
|
||||
;;
|
||||
-g|--gen|--generate)
|
||||
gen_or_build=true
|
||||
generate_server=true
|
||||
generate_client=true
|
||||
add_all_clients_to_generate
|
||||
;;
|
||||
-s|--server)
|
||||
gen_or_build=true
|
||||
generate_server=true
|
||||
;;
|
||||
-c|--client)
|
||||
gen_or_build=true
|
||||
generate_client=true
|
||||
if [[ -n ${2:-} && ${2} != -* ]]; then
|
||||
while [[ -n ${2:-} && ${2} != -* ]]; do
|
||||
shift
|
||||
add_client_to_generate ${1}
|
||||
done
|
||||
else
|
||||
add_all_clients_to_generate
|
||||
fi
|
||||
;;
|
||||
-b|--binary)
|
||||
gen_or_build=true
|
||||
build_binary=true
|
||||
;;
|
||||
-i|--di|--docker-image)
|
||||
build_image=true
|
||||
;;
|
||||
-p|--push|--push-image)
|
||||
push_image=true
|
||||
;;
|
||||
--nc|--no-cache)
|
||||
no_cache=--no-cache
|
||||
;;
|
||||
--cln|--clean|--cleanup)
|
||||
:
|
||||
;;
|
||||
-d)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
echo "Encountered unexpected parameter"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
|
||||
if ! ${gen_or_build:-false}; then
|
||||
if ${build_image}; then
|
||||
build_docker_image
|
||||
fi
|
||||
if ${push_image}; then
|
||||
push_docker_image
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# OpenAPI Generator GoFiber
|
||||
oag_gofiber_ver=$(get_config .openapi-generator-gofiber-version "0.1.3")
|
||||
oag_gofiber_jar=openapi-generator-gofiber-generator-${oag_gofiber_ver}.jar
|
||||
oag_gofiber_jar_url=https://${GITHUB_USER}:${GITHUB_TOKEN}@nexus.tessell.cloud/repository/tessell-repos-m2-component/
|
||||
oag_gofiber_jar_url+=org/openapi/openapi-generator-gofiber-generator/${oag_gofiber_ver}/${oag_gofiber_jar}
|
||||
|
||||
# GoCLient OpenAPI Generator
|
||||
oag_client_ver=$(get_config .openapi-generator-goclient-version "1.0.4")
|
||||
oag_client_jar=go-client-openapi-generator-${oag_client_ver}.jar
|
||||
oag_client_jar_url=https://${GITHUB_USER}:${GITHUB_TOKEN}@nexus.tessell.cloud/repository/tessell-repos-m2-development/
|
||||
oag_client_jar_url+=org/openapi/go-client-openapi-generator/${oag_client_ver}/${oag_client_jar}
|
||||
|
||||
# OpenAPI CLI Jar for Client
|
||||
oag_cli_ver_for_client=$(get_config .openapi-generator-cli-version.for-client "6.1.0")
|
||||
oag_cli_jar_for_client=openapi-generator-cli-${oag_cli_ver_for_client}.jar
|
||||
oag_cli_jar_url_client=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${oag_cli_ver_for_client}/${oag_cli_jar_for_client}
|
||||
|
||||
# OpenAPI CLI Jar for Server
|
||||
oag_cli_ver_for_server=$(get_config .openapi-generator-cli-version.for-server "5.4.0")
|
||||
oag_cli_jar_for_server=openapi-generator-cli-${oag_cli_ver_for_server}.jar
|
||||
oag_cli_jar_url_server=https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${oag_cli_ver_for_server}/${oag_cli_jar_for_server}
|
||||
|
||||
# OpenAPI generate cmd base
|
||||
oag_gen_server="org.openapitools.codegen.OpenAPIGenerator generate -ggo-fiber --global-property skipFormModel=false --additional-properties enumClassPrefix=true"
|
||||
oag_gen_client="org.openapitools.codegen.OpenAPIGenerator generate --global-property skipFormModel=false --additional-properties enumClassPrefix=true"
|
||||
|
||||
if ${build_binary}; then
|
||||
build_bin
|
||||
fi
|
||||
|
||||
if ${generate_server}; then
|
||||
generate_gofiber_boilerplate
|
||||
fi
|
||||
|
||||
if ${generate_client} && [[ $(get_config .clients-specs) != null ]]; then
|
||||
generate_required_api_clients
|
||||
fi
|
||||
|
||||
if ${gen_or_build:-false}; then
|
||||
patch_files=$(get_config .build-patch[])
|
||||
for patch_file in ${patch_files:-}; do
|
||||
cp build-patch/${patch_file}-patch build/${patch_file}
|
||||
done
|
||||
|
||||
go_fmt
|
||||
fi
|
||||
|
||||
if ${build_image}; then
|
||||
build_docker_image
|
||||
fi
|
||||
|
||||
if ${push_image}; then
|
||||
push_docker_image
|
||||
fi
|
41
setup.yaml
Normal file
41
setup.yaml
Normal file
@ -0,0 +1,41 @@
|
||||
openapi-generator-gofiber-version: 0.1.5
|
||||
openapi-generator-goclient-version: 1.0.5
|
||||
openapi-generator-cli-version:
|
||||
for-server: 5.4.0
|
||||
for-clients: 6.1.0
|
||||
|
||||
build-dir: ./build
|
||||
create-symlinks: false
|
||||
docker-image-tag: v0.0.1
|
||||
|
||||
flyway-docker-image:
|
||||
name: genie-flyway-migration
|
||||
tag: latest
|
||||
|
||||
service-name: genie
|
||||
service-api-spec:
|
||||
filepath: genie/genie-api.yaml
|
||||
branch: 0.102.12
|
||||
|
||||
common-api-spec:
|
||||
filepath: common/common-specification.yaml
|
||||
branch: 0.102.12
|
||||
|
||||
clients-specs:
|
||||
dbsystem:
|
||||
filepath: database/database-system-api.yaml
|
||||
branch: 0.102.12
|
||||
deps:
|
||||
- filepath: dmm/dmm-api.yaml
|
||||
iam:
|
||||
filepath: iam/otp.yaml
|
||||
branch: 0.102.12
|
||||
notification:
|
||||
filepath: notification/notifications-api.yaml
|
||||
branch: 0.102.12
|
||||
tgs:
|
||||
filepath: gateway/tgs-api.yaml
|
||||
branch: 0.102.12
|
||||
slackbot:
|
||||
filepath: genie/slack-bot-api.yaml
|
||||
branch: 0.102.12
|
Loading…
Reference in New Issue
Block a user