Merge branch 'master' into frontend-develop

This commit is contained in:
Twwy 2022-11-29 13:44:28 +08:00 committed by GitHub
commit b9a5a6220a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2364 changed files with 187886 additions and 12809 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ paas/action/test.sh
mvn_deploy.sh
mvn_install.sh
*.iml
*.swp

View File

@ -46,3 +46,4 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage], versi
[version]: https://contributor-covenant.org/version/1/4/

View File

@ -10,6 +10,8 @@
<p align="center">
<a href="https://www.yuque.com/sreworks-doc/docs" target="_blank">产品文档</a>
<a href="https://sreworks.opensource.alibaba.com/" target="_blank">开源官网</a>
<a href="https://gitee.com/sreworks/sreworks" target="_blank">国内代码库</a>
</p>
---
@ -37,12 +39,12 @@ SREWorks 作为阿里云大数据SRE团队对SRE理念的工程实践专注
回归到运维领域的需求无论上层产品和业务形态怎么变化运维本质上解决的还是“质量、成本、效率、安全”相关需求。SREWorks 用一个运维 SaaS 应用界面来支撑上述需求,同时以“数智”思想为内核驱动 SaaS 能力,具体包括交付、监测、管理、控制、运营、服务六部分。
![image.png](/paas/sw-frontend/docs/pictures/1650211475047-fdfccb84-61bd-4e1f-8451-9505847a48a7.png)
![image.png](paas/sw-frontend/docs/docs/pictures/1666944785433-f3417e59-35be-420c-9f11-fae88b4f7e30.jpeg.png)
## 入门指南
- [快速安装](/paas/sw-frontend/docs/documents/rr5g10.md)
- [源码安装](/paas/sw-frontend/docs/documents/mzz07m.md)
- [快速安装](/paas/sw-frontend/docs/docs/rr5g10.md)
- [源码安装](/paas/sw-frontend/docs/docs/mzz07m.md)
- [产品文档](https://www.yuque.com/sreworks-doc/docs/)
- [在线体验](https://wj.qq.com/s2/10565748/53da/)

View File

@ -10,6 +10,7 @@
<p align="center">
<a href="https://www.yuque.com/sreworks-doc/docs" target="_blank">Documentation</a>
<a href="https://sreworks.opensource.alibaba.com/" target="_blank">Website</a>
</p>
---
@ -31,12 +32,12 @@ Alibaba Cloud Big Data SRE team has been working hard to practice the "DataOps a
There are many excellent open-source O & M platforms that reflect cloud-native scenarios in the traditional IT O&M field. There are currently no systematic O & M solutions available. With the rise of the cloud-native era, the Alibaba Cloud Big Data SRE team will open-source its O & M platform, SREWorks, in the hopes of providing O & M engineers with an out-of-the-box experience.
![image.png](paas/sw-frontend/docs/pictures/1650534633770-0f784bd7-1996-473a-9b6f-91a54064a155.png)
![image.png](paas/sw-frontend/docs/docs/pictures/1663627633334-32214451-31cf-4e1a-b0a3-3cc3047ab842.jpeg.png)
## Getting Started
- [Quick Install](/paas/sw-frontend/docs/documents/rr5g10.md)
- [Installation from source code](/paas/sw-frontend/docs/documents/mzz07m.md)
- [Quick Install](/paas/sw-frontend/docs/docs/rr5g10.md)
- [Installation from source code](/paas/sw-frontend/docs/docs/mzz07m.md)
- [Document](https://www.yuque.com/sreworks-doc/docs/)
- [Online Demo](https://wj.qq.com/s2/10565748/53da/)

View File

@ -236,34 +236,34 @@ target_swcli(){
download_packages(){
PKG_URL="${SREWORKS_BUILTIN_PACKAGE_URL}/${tag}"
mkdir -p $SW_ROOT/saas/desktop/ui/ && wget "${PKG_URL}/saas/desktop/ui/desktop-auto.zip" -O $SW_ROOT/saas/desktop/ui/desktop-auto.zip
mkdir -p $SW_ROOT/saas/swadmin/ui/ && wget "${PKG_URL}/saas/swadmin/ui/swadmin-auto.zip" -O $SW_ROOT/saas/swadmin/ui/swadmin-auto.zip
mkdir -p $SW_ROOT/saas/system/ui/ && wget "${PKG_URL}/saas/system/ui/system-auto.zip" -O $SW_ROOT/saas/system/ui/system-auto.zip
mkdir -p $SW_ROOT/saas/upload/ui/ && wget "${PKG_URL}/saas/upload/ui/upload-auto.zip" -O $SW_ROOT/saas/upload/ui/upload-auto.zip
mkdir -p $SW_ROOT/saas/team/ui/ && wget "${PKG_URL}/saas/team/ui/team-auto.zip" -O $SW_ROOT/saas/team/ui/team-auto.zip
mkdir -p $SW_ROOT/saas/search/ui/ && wget "${PKG_URL}/saas/search/ui/search-auto.zip" -O $SW_ROOT/saas/search/ui/search-auto.zip
mkdir -p $SW_ROOT/saas/ocenter/ui/ && wget "${PKG_URL}/saas/ocenter/ui/ocenter-auto.zip" -O $SW_ROOT/saas/ocenter/ui/ocenter-auto.zip
mkdir -p $SW_ROOT/saas/aiops/ui/ && wget "${PKG_URL}/saas/aiops/ui/aiops-auto.zip" -O $SW_ROOT/saas/aiops/ui/aiops-auto.zip
mkdir -p $SW_ROOT/saas/app/ui/ && wget "${PKG_URL}/saas/app/ui/app-auto.zip" -O $SW_ROOT/saas/app/ui/app-auto.zip
mkdir -p $SW_ROOT/saas/cluster/ui/ && wget "${PKG_URL}/saas/cluster/ui/cluster-auto.zip" -O $SW_ROOT/saas/cluster/ui/cluster-auto.zip
mkdir -p $SW_ROOT/saas/dataops/ui/data/ && wget "${PKG_URL}/saas/dataops/ui/data/data-auto.zip" -O $SW_ROOT/saas/dataops/ui/data/data-auto.zip
mkdir -p $SW_ROOT/saas/healing/ui/ && wget "${PKG_URL}/saas/healing/ui/healing-auto.zip" -O $SW_ROOT/saas/healing/ui/healing-auto.zip
mkdir -p $SW_ROOT/saas/health/ui/ && wget "${PKG_URL}/saas/health/ui/health-auto.zip" -O $SW_ROOT/saas/health/ui/health-auto.zip
mkdir -p $SW_ROOT/saas/help/ui/ && wget "${PKG_URL}/saas/help/ui/help-auto.zip" -O $SW_ROOT/saas/help/ui/help-auto.zip
mkdir -p $SW_ROOT/saas/job/ui/ && wget "${PKG_URL}/saas/job/ui/job-auto.zip" -O $SW_ROOT/saas/job/ui/job-auto.zip
mkdir -p $SW_ROOT/saas/template/ui/ && wget "${PKG_URL}/saas/template/ui/template-auto.zip" -O $SW_ROOT/saas/template/ui/template-auto.zip
#mkdir -p $SW_ROOT/saas/desktop/ui/ && wget "${PKG_URL}/saas/desktop/ui/desktop-auto.zip" -O $SW_ROOT/saas/desktop/ui/desktop-auto.zip
#mkdir -p $SW_ROOT/saas/swadmin/ui/ && wget "${PKG_URL}/saas/swadmin/ui/swadmin-auto.zip" -O $SW_ROOT/saas/swadmin/ui/swadmin-auto.zip
#mkdir -p $SW_ROOT/saas/system/ui/ && wget "${PKG_URL}/saas/system/ui/system-auto.zip" -O $SW_ROOT/saas/system/ui/system-auto.zip
#mkdir -p $SW_ROOT/saas/upload/ui/ && wget "${PKG_URL}/saas/upload/ui/upload-auto.zip" -O $SW_ROOT/saas/upload/ui/upload-auto.zip
#mkdir -p $SW_ROOT/saas/team/ui/ && wget "${PKG_URL}/saas/team/ui/team-auto.zip" -O $SW_ROOT/saas/team/ui/team-auto.zip
#mkdir -p $SW_ROOT/saas/search/ui/ && wget "${PKG_URL}/saas/search/ui/search-auto.zip" -O $SW_ROOT/saas/search/ui/search-auto.zip
#mkdir -p $SW_ROOT/saas/ocenter/ui/ && wget "${PKG_URL}/saas/ocenter/ui/ocenter-auto.zip" -O $SW_ROOT/saas/ocenter/ui/ocenter-auto.zip
#mkdir -p $SW_ROOT/saas/aiops/ui/ && wget "${PKG_URL}/saas/aiops/ui/aiops-auto.zip" -O $SW_ROOT/saas/aiops/ui/aiops-auto.zip
#mkdir -p $SW_ROOT/saas/app/ui/ && wget "${PKG_URL}/saas/app/ui/app-auto.zip" -O $SW_ROOT/saas/app/ui/app-auto.zip
#mkdir -p $SW_ROOT/saas/cluster/ui/ && wget "${PKG_URL}/saas/cluster/ui/cluster-auto.zip" -O $SW_ROOT/saas/cluster/ui/cluster-auto.zip
#mkdir -p $SW_ROOT/saas/dataops/ui/data/ && wget "${PKG_URL}/saas/dataops/ui/data/data-auto.zip" -O $SW_ROOT/saas/dataops/ui/data/data-auto.zip
#mkdir -p $SW_ROOT/saas/healing/ui/ && wget "${PKG_URL}/saas/healing/ui/healing-auto.zip" -O $SW_ROOT/saas/healing/ui/healing-auto.zip
#mkdir -p $SW_ROOT/saas/health/ui/ && wget "${PKG_URL}/saas/health/ui/health-auto.zip" -O $SW_ROOT/saas/health/ui/health-auto.zip
#mkdir -p $SW_ROOT/saas/help/ui/ && wget "${PKG_URL}/saas/help/ui/help-auto.zip" -O $SW_ROOT/saas/help/ui/help-auto.zip
#mkdir -p $SW_ROOT/saas/job/ui/ && wget "${PKG_URL}/saas/job/ui/job-auto.zip" -O $SW_ROOT/saas/job/ui/job-auto.zip
#mkdir -p $SW_ROOT/saas/template/ui/ && wget "${PKG_URL}/saas/template/ui/template-auto.zip" -O $SW_ROOT/saas/template/ui/template-auto.zip
wget "${PKG_URL}/saas/aiops/aiops.zip" -O $SW_ROOT/saas/aiops/aiops.zip
wget "${PKG_URL}/saas/app/app.zip" -O $SW_ROOT/saas/app/app.zip
wget "${PKG_URL}/saas/cluster/cluster.zip" -O $SW_ROOT/saas/cluster/cluster.zip
wget "${PKG_URL}/saas/dataops/data.zip" -O $SW_ROOT/saas/dataops/data.zip
wget "${PKG_URL}/saas/health/health.zip" -O $SW_ROOT/saas/health/health.zip
wget "${PKG_URL}/saas/job/job.zip" -O $SW_ROOT/saas/job/job.zip
wget "${PKG_URL}/saas/search/search.zip" -O $SW_ROOT/saas/search/search.zip
#wget "${PKG_URL}/saas/aiops/aiops.zip" -O $SW_ROOT/saas/aiops/aiops.zip
#wget "${PKG_URL}/saas/app/app.zip" -O $SW_ROOT/saas/app/app.zip
#wget "${PKG_URL}/saas/cluster/cluster.zip" -O $SW_ROOT/saas/cluster/cluster.zip
#wget "${PKG_URL}/saas/dataops/data.zip" -O $SW_ROOT/saas/dataops/data.zip
#wget "${PKG_URL}/saas/health/health.zip" -O $SW_ROOT/saas/health/health.zip
#wget "${PKG_URL}/saas/job/job.zip" -O $SW_ROOT/saas/job/job.zip
#wget "${PKG_URL}/saas/search/search.zip" -O $SW_ROOT/saas/search/search.zip
wget "${PKG_URL}/saas/swcore/flycore.zip" -O $SW_ROOT/saas/swcore/flycore.zip
wget "${PKG_URL}/saas/system/system.zip" -O $SW_ROOT/saas/system/system.zip
wget "${PKG_URL}/saas/team/team.zip" -O $SW_ROOT/saas/team/team.zip
wget "${PKG_URL}/saas/upload/upload.zip" -O $SW_ROOT/saas/upload/upload.zip
#wget "${PKG_URL}/saas/system/system.zip" -O $SW_ROOT/saas/system/system.zip
#wget "${PKG_URL}/saas/team/team.zip" -O $SW_ROOT/saas/team/team.zip
#wget "${PKG_URL}/saas/upload/upload.zip" -O $SW_ROOT/saas/upload/upload.zip
}
@ -278,6 +278,7 @@ target_swcli_builtin_package(){
download_packages
cp -r $SW_ROOT/saas $SW_ROOT/paas/swcli/builtin_package/saas
cp -r $SW_ROOT/chart $SW_ROOT/paas/swcli/builtin_package/chart
cp -r $SW_ROOT/plugins $SW_ROOT/paas/swcli/builtin_package/plugins
TMP_DOCKERFILE="/tmp/${RANDOM}.dockerfile"
envsubst < $SW_ROOT/paas/swcli/Dockerfile_builtin_package.tpl > ${TMP_DOCKERFILE}
docker build -t swcli-builtin-package:$tag -f ${TMP_DOCKERFILE} $SW_ROOT/paas/swcli

View File

@ -3,11 +3,56 @@
"packagePath": "saas/template/build"
},{
"appId": "job",
"packagePath": "saas/job/build"
"packagePath": "saas/job/build",
"patch": "saas/job/api/patch.yaml"
},{
"appId": "app",
"packagePath": "saas/app/build"
"packagePath": "saas/app/build",
"patch": "saas/app/api/patch.yaml"
},{
"appId": "cluster",
"packagePath": "saas/cluster/build"
"packagePath": "saas/cluster/build",
"patch": "saas/cluster/api/patch.yaml"
},{
"appId": "swadmin",
"packagePath": "saas/swadmin/build"
},{
"appId": "team",
"packagePath": "saas/team/build",
"patch": "saas/team/api/patch.yaml"
},{
"appId": "help",
"packagePath": "saas/help/build"
},{
"appId": "health",
"packagePath": "saas/health/build",
"patch": "saas/health/api/patch.yaml"
},{
"appId": "search",
"packagePath": "saas/search/build",
"patch": "saas/search/api/patch.yaml"
},{
"appId": "upload",
"packagePath": "saas/upload/build",
"patch": "saas/upload/api/patch.yaml"
},{
"appId": "ocenter",
"packagePath": "saas/ocenter/build"
},{
"appId": "healing",
"packagePath": "saas/healing/build"
},{
"appId": "desktop",
"packagePath": "saas/desktop/build"
},{
"appId": "aiops",
"packagePath": "saas/aiops/build",
"patch": "saas/aiops/api/patch.yaml"
},{
"appId": "system",
"packagePath": "saas/system/build"
},{
"appId": "dataops",
"packagePath": "saas/dataops/build",
"patch": "saas/dataops/api/patch.yaml"
}]

View File

@ -34,8 +34,13 @@ spec:
ports:
- containerPort: 7001
envFrom:
{{- if .Values.server.sreworksEnvs }}
- configMapRef:
name: init-configmap
{{- end }}
- configMapRef:
name: {{ template "name.server-configmap" . }}
securityContext:
privileged: true
{{- end -}}

View File

@ -18,6 +18,7 @@ images:
rbacProxy: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/kube-rbac-proxy:v0.8.0
server:
sreworksEnvs: false
rbac: admin
database:
#host:

View File

@ -111,7 +111,7 @@ kruise:
enabled: true
kafka:
enabled: true
enabled: false
persistence:
size: 20Gi

View File

@ -1,4 +1,9 @@
Please execute following command in terminal to trace the install progress:
>
> kubectl logs job.batch/sreworks-progress-check -nsreworks -f
>
After install finished (5-10mins) open the following URL in your browser:

View File

@ -17,6 +17,7 @@ data:
JRE11_IMAGE: {{ .Values.global.artifacts.openjdk11Image }}
MAVEN_SETTINGS_XML: {{ .Values.global.artifacts.mavenSettingsXml }}
NODE_IMAGE: {{ .Values.global.artifacts.nodeImage }}
NODE_IMAGE2: {{ .Values.global.artifacts.nodeImage2 }}
ALPINE_IMAGE: {{ .Values.global.artifacts.alpineImage }}
MIGRATE_IMAGE: {{ template "migrate.image" . }}
POSTRUN_IMAGE: {{ template "postrun.image" . }}
@ -68,7 +69,7 @@ data:
ZOOKEEPER_ENDPOINT: {{ .Release.Name }}-zookeeper
ENDPOINT_PAAS_MINIO: {{ template "minio.endpoint" . }}
APPMANAGER_ENDPOINT: {{ .Release.Name }}-appmanager
KAFKA_ENDPOINT: {{ .Release.Name }}-kafka.{{ .Release.Namespace }}
KAFKA_ENDPOINT: prod-dataops-kafka.sreworks-dataops
AUTHPROXY_ENDPOINT: {{ .Values.core.stageId }}-{{ .Values.core.appId }}-paas-authproxy
REDIS_ENDPOINT: {{ .Release.Name }}-redis-master.{{ .Release.Namespace }}
REDIS_PASSWORD: {{ .Values.appmanagerbase.redis.password | quote }}
@ -103,14 +104,20 @@ data:
DATAOPS_DB_PASSWORD: {{ .Values.saas.dataops.dbPassword | quote }}
DATAOPS_DB_PORT: {{ .Values.saas.dataops.dbPort | quote }}
DATAOPS_DB_USER: {{ .Values.saas.dataops.dbUser | quote }}
DATA_DB_HOST: {{ .Values.saas.dataops.dbHost | quote }}
DATA_DB_PASSWORD: {{ .Values.saas.dataops.dbPassword | quote }}
DATA_DB_PORT: {{ .Values.saas.dataops.dbPort | quote }}
DATA_DB_USER: {{ .Values.saas.dataops.dbUser | quote }}
GRAFANA_ADMIN_PASSWORD: {{ .Values.saas.grafana.password | quote }}
DATA_ES_HOST: {{ .Values.saas.dataops.esHost | quote }}
DATA_ES_PORT: {{ .Values.saas.dataops.esPort | quote }}
DATA_ES_USER: {{ .Values.saas.dataops.esUser | quote }}
DATA_ES_PASSWORD: {{ .Values.saas.dataops.esPassword | quote }}
DATAOPS_FILEBEAT_ENABLE: {{ .Values.saas.dataops.filebeatEnable | quote}}
DATAOPS_METRICBEAT_ENABLE: {{ .Values.saas.dataops.metricbeatEnable | quote}}
DATA_PROM_HOST: "localhost"
DATA_PROM_PORT: "80"
DATA_PROM_HOST: {{ .Values.saas.dataops.prometheusHost | quote }}
DATA_PROM_PORT: {{ .Values.saas.dataops.prometheusPort | quote }}
ACCOUNT_SUPER_CLIENT_ID: {{ .Values.appmanager.gateway.account_super_client_id }}
ACCOUNT_SUPER_CLIENT_SECRET: {{ .Values.appmanager.gateway.account_super_client_secret }}

View File

@ -16,6 +16,8 @@ data:
#fi
#cd sreworks-flycore
sh /app/upload-plugins.sh
cd /root/saas/swcore/api/core/
@ -46,7 +48,7 @@ data:
fi
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id=${CORE_APP_ID} --filepath /root/saas/swcore/flycore.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id=${CORE_APP_ID} --stage=prod --namespace=${NAMESPACE_ID} --path /root/saas/swcore/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --wait-max-seconds 300 --app-id=${CORE_APP_ID} --stage=prod --namespace=${NAMESPACE_ID} --path /root/saas/swcore/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
@ -56,30 +58,30 @@ data:
sh /app/core-action-service-check.sh
# import&launch saas desktop
envsubst < /root/saas/desktop/launch-v2.yaml.tpl > /root/saas/desktop/launch.yaml
envsubst < /root/saas/desktop/launch-v2-dev.yaml.tpl > /root/saas/desktop/launch-dev.yaml
envsubst < /root/saas/desktop/build/launch-frontend.yaml.tpl > /root/saas/desktop/launch-frontend.yaml
envsubst < /root/saas/desktop/build/launch-frontend-dev.yaml.tpl > /root/saas/desktop/launch-frontend-dev.yaml
if [[ "$ONLY_BASE" == "true" ]] ; then
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id desktop --filepath /root/saas/desktop/ui/desktop-nosearch.zip --print-only-app-package-id=true --reset-version=true)
else
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id desktop --filepath /root/saas/desktop/ui/desktop-auto.zip --print-only-app-package-id=true --reset-version=true)
sed -i 's/searchConfig\\":true/searchConfig\\":false/g' /root/saas/desktop/build/INTERNAL_ADDON_productopsv2.zip.dir/content.json
fi
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id desktop --stage=prod --namespace=${NAMESPACE_ID} --path /root/saas/desktop/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id desktop --stage=dev --namespace=${NAMESPACE_ID} --path /root/saas/desktop/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
python /app/pack.py --src /root/saas/desktop/build --dest /root/saas/desktop/build.zip
sh /app/import.sh desktop /root/saas/desktop/build.zip /root/saas/desktop/launch-frontend.yaml /root/saas/desktop/launch-frontend-dev.yaml
# import&launch saas swadmin
envsubst < /root/saas/swadmin/launch-v2.yaml.tpl > /root/saas/swadmin/launch.yaml
envsubst < /root/saas/swadmin/launch-v2-dev.yaml.tpl > /root/saas/swadmin/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id swadmin --filepath /root/saas/swadmin/ui/swadmin-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id swadmin --path /root/saas/swadmin/launch.yaml --stage=prod --namespace=${NAMESPACE_ID} --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id swadmin --path /root/saas/swadmin/launch-dev.yaml --stage dev --namespace=${NAMESPACE_ID} --app-package-id $result --arch x86 --wait=true --cluster master
python /app/pack.py --src /root/saas/swadmin/build --dest /root/saas/swadmin/build.zip
envsubst < /root/saas/swadmin/build/launch-frontend.yaml.tpl > /root/saas/swadmin/launch-frontend.yaml
envsubst < /root/saas/swadmin/build/launch-frontend-dev.yaml.tpl > /root/saas/swadmin/launch-frontend-dev.yaml
sh /app/import.sh swadmin /root/saas/swadmin/build.zip /root/saas/swadmin/launch-frontend.yaml /root/saas/swadmin/launch-frontend-dev.yaml
# import&launch saas template
envsubst < /root/saas/template/launch-v2.yaml.tpl > /root/saas/template/launch.yaml
envsubst < /root/saas/template/launch-v2-dev.yaml.tpl > /root/saas/template/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id template --filepath /root/saas/template/ui/template-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id template --path /root/saas/template/launch.yaml --stage=prod --namespace=${NAMESPACE_ID} --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --app-id template --path /root/saas/template/launch-dev.yaml --stage dev --namespace=${NAMESPACE_ID} --app-package-id $result --arch x86 --wait=true --cluster master
python /app/pack.py --src /root/saas/template/build --dest /root/saas/template/build.zip
envsubst < /root/saas/template/build/launch-frontend.yaml.tpl > /root/saas/template/launch-frontend.yaml
envsubst < /root/saas/template/build/launch-frontend-dev.yaml.tpl > /root/saas/template/launch-frontend-dev.yaml
sh /app/import.sh template /root/saas/template/build.zip /root/saas/template/launch-frontend.yaml /root/saas/template/launch-frontend-dev.yaml
fi
@ -123,42 +125,28 @@ data:
# build&launch cluster api
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/cluster/api/build.yaml.tpl > /root/saas/cluster/api/build.yaml
envsubst < /root/saas/cluster/api/launch.yaml.tpl > /root/saas/cluster/api/launch.yaml
envsubst < /root/saas/cluster/ui/launch-v2.yaml.tpl > /root/saas/cluster/ui/launch.yaml
envsubst < /root/saas/cluster/ui/launch-v2-dev.yaml.tpl > /root/saas/cluster/ui/launch-dev.yaml
envsubst < /root/saas/cluster/build/launch.yaml.tpl > /root/saas/cluster/launch.yaml
envsubst < /root/saas/cluster/build/launch-backend.yaml.tpl > /root/saas/cluster/launch-backend.yaml
envsubst < /root/saas/cluster/build/launch-frontend.yaml.tpl > /root/saas/cluster/launch-frontend.yaml
envsubst < /root/saas/cluster/build/launch-frontend-dev.yaml.tpl > /root/saas/cluster/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/cluster/build --dest /root/saas/cluster/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/cluster/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=cluster --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=cluster --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
# wait flycore
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
# import&launch cluster ui
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id cluster --filepath /root/saas/cluster/ui/cluster-auto.zip --print-only-app-package-id=true --reset-version=true)
sh /app/import.sh cluster /root/saas/cluster/build.zip /root/saas/cluster/launch-frontend.yaml /root/saas/cluster/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id cluster --path /root/saas/cluster/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id cluster --path /root/saas/cluster/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/cluster/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/cluster/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/cluster/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id cluster --filepath /root/saas/cluster/cluster.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id cluster --path /root/saas/cluster/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id cluster --path /root/saas/cluster/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh cluster /root/saas/cluster/build.zip /root/saas/cluster/launch.yaml /root/saas/cluster/launch-frontend-dev.yaml
fi
@ -173,40 +161,27 @@ data:
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/app/api/build.yaml.tpl > /root/saas/app/api/build.yaml
envsubst < /root/saas/app/api/launch.yaml.tpl > /root/saas/app/api/launch.yaml
envsubst < /root/saas/app/ui/launch-v2.yaml.tpl > /root/saas/app/ui/launch.yaml
envsubst < /root/saas/app/ui/launch-v2-dev.yaml.tpl > /root/saas/app/ui/launch-dev.yaml
envsubst < /root/saas/app/build/launch.yaml.tpl > /root/saas/app/launch.yaml
envsubst < /root/saas/app/build/launch-backend.yaml.tpl > /root/saas/app/launch-backend.yaml
envsubst < /root/saas/app/build/launch-frontend.yaml.tpl > /root/saas/app/launch-frontend.yaml
envsubst < /root/saas/app/build/launch-frontend-dev.yaml.tpl > /root/saas/app/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/app/build --dest /root/saas/app/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/app/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=app --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=app --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id app --filepath /root/saas/app/ui/app-auto.zip --print-only-app-package-id=true --reset-version=true)
sh /app/import.sh app /root/saas/app/build.zip /root/saas/app/launch-frontend.yaml /root/saas/app/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id app --path /root/saas/app/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id app --path /root/saas/app/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/app/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/app/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/app/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id app --filepath /root/saas/app/app.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id app --path /root/saas/app/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id app --path /root/saas/app/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh app /root/saas/app/build.zip /root/saas/app/launch.yaml /root/saas/app/launch-frontend-dev.yaml
fi
@ -222,42 +197,26 @@ data:
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/system/api/build.yaml.tpl > /root/saas/system/api/build.yaml
envsubst < /root/saas/system/api/launch.yaml.tpl > /root/saas/system/api/launch.yaml
envsubst < /root/saas/system/ui/launch-v2.yaml.tpl > /root/saas/system/ui/launch.yaml
envsubst < /root/saas/system/ui/launch-v2-dev.yaml.tpl > /root/saas/system/ui/launch-dev.yaml
envsubst < /root/saas/system/build/launch.yaml.tpl > /root/saas/system/launch.yaml
envsubst < /root/saas/system/build/launch-backend.yaml.tpl > /root/saas/system/launch-backend.yaml
envsubst < /root/saas/system/build/launch-frontend.yaml.tpl > /root/saas/system/launch-frontend.yaml
envsubst < /root/saas/system/build/launch-frontend-dev.yaml.tpl > /root/saas/system/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/system/build --dest /root/saas/system/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/system/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=system --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=system --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id system --filepath /root/saas/system/ui/system-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id system --path /root/saas/system/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id system --path /root/saas/system/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh system /root/saas/system/build.zip /root/saas/system/launch-frontend.yaml /root/saas/system/launch-frontend-dev.yaml
fi
else
cd /root/saas/system/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/system/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/system/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id system --filepath /root/saas/system/system.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id system --path /root/saas/system/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id system --path /root/saas/system/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh system /root/saas/system/build.zip /root/saas/system/launch.yaml /root/saas/system/launch-frontend-dev.yaml
fi
@ -270,45 +229,43 @@ data:
sh /app/core-deploy-check.sh
cd /root
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/upload/api/build.yaml.tpl > /root/saas/upload/api/build.yaml
envsubst < /root/saas/upload/api/launch.yaml.tpl > /root/saas/upload/api/launch.yaml
envsubst < /root/saas/upload/ui/launch-v2.yaml.tpl > /root/saas/upload/ui/launch.yaml
envsubst < /root/saas/upload/ui/launch-v2-dev.yaml.tpl > /root/saas/upload/ui/launch-dev.yaml
envsubst < /root/saas/upload/build/launch.yaml.tpl > /root/saas/upload/launch.yaml
envsubst < /root/saas/upload/build/launch-backend.yaml.tpl > /root/saas/upload/launch-backend.yaml
envsubst < /root/saas/upload/build/launch-frontend.yaml.tpl > /root/saas/upload/launch-frontend.yaml
envsubst < /root/saas/upload/build/launch-frontend-dev.yaml.tpl > /root/saas/upload/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/upload/build --dest /root/saas/upload/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/upload/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=upload --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=upload --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
sh /app/import.sh upload /root/saas/upload/build.zip /root/saas/upload/launch-frontend.yaml /root/saas/upload/launch-frontend-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id upload --filepath /root/saas/upload/ui/upload-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id upload --path /root/saas/upload/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id upload --path /root/saas/upload/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/upload/
sh /app/import.sh upload /root/saas/upload/build.zip /root/saas/upload/launch.yaml /root/saas/upload/launch-frontend-dev.yaml
fi
import.sh: |
set -e
set -x
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/upload/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/upload/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id $1 --filepath $2 --print-only-app-package-id=true --reset-version=true)
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id upload --filepath /root/saas/upload/upload.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id upload --path /root/saas/upload/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id upload --path /root/saas/upload/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id $1 --path $3 --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id $1 --path $4 --app-package-id $result --arch x86 --wait=true --cluster master
reduce.py: |
@ -333,7 +290,117 @@ data:
res = reduce(merge, [yaml.safe_load(raw) for raw in sys.stdin.read().strip().split("---")])
print(yaml.dump(res))
pack.py: |
import shutil
import tempfile
import os
import argparse
parser = argparse.ArgumentParser(description='package tool')
parser.add_argument("-s",'--src', type=str, dest="src", required=True)
parser.add_argument("-d",'--dest', type=str, dest="dest", required=True)
args = parser.parse_args()
packagePath = tempfile.mkdtemp()
targetPath = packagePath + "/target"
shutil.copytree(args.src, targetPath)
for path in os.listdir(targetPath):
if path.endswith(".zip.dir"):
shutil.make_archive(targetPath + "/" + path.split(".zip")[0], 'zip', targetPath + "/" + path)
shutil.rmtree(targetPath + "/" + path)
shutil.make_archive(args.dest.split(".zip")[0], 'zip', targetPath + "/")
remove-components.py: |
import yaml
import argparse
parser = argparse.ArgumentParser(description='remove components tool')
parser.add_argument("-s",'--src', type=str, dest="src", required=True)
parser.add_argument("-c",'--components', type=str, nargs="+", dest="components", required=True)
args = parser.parse_args()
f = open(args.src, 'r')
srcData = yaml.safe_load(f.read())
f.close()
srcData["spec"]["components"] = list(filter(lambda c: c.get("revisionName") not in args.components, srcData["spec"]["components"]))
f = open(args.src, 'w')
f.write(yaml.safe_dump(srcData, width=float("inf")))
f.close()
saas-dataops.sh: |
set -e
set -x
cd /root
sh /app/core-deploy-check.sh
# build&launch dataops api
export NAMESPACE_ID=${NAMESPACE_DATAOPS}
export NODE_NAME='$''{''NODE_NAME''}'
export NODE_IP='$''{''NODE_IP''}'
envsubst < /root/saas/dataops/api/build.yaml.tpl > /root/saas/dataops/api/build.yaml
envsubst < /root/saas/dataops/build/launch.yaml.tpl > /root/saas/dataops/launch.yaml
envsubst < /root/saas/dataops/build/launch-backend.yaml.tpl > /root/saas/dataops/launch-backend.yaml
envsubst < /root/saas/dataops/build/launch-frontend.yaml.tpl > /root/saas/dataops/launch-frontend.yaml
envsubst < /root/saas/dataops/build/launch-frontend-dev.yaml.tpl > /root/saas/dataops/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/dataops/build --dest /root/saas/dataops/build.zip
# mysql地址如果从外部传入就不拉起mysql
if [[ "$DATAOPS_DB_HOST" != "prod-dataops-mysql.sreworks-dataops" ]]
then
python /app/remove-components.py -s /root/saas/dataops/launch.yaml -c "HELM|mysql|_"
python /app/remove-components.py -s /root/saas/dataops/launch-frontend.yaml -c "HELM|mysql|_"
fi
if [[ "$DATA_ES_HOST" != "prod-dataops-elasticsearch-master.sreworks-dataops" ]]
then
python /app/remove-components.py -s /root/saas/dataops/launch.yaml -c "HELM|elasticsearch|_"
python /app/remove-components.py -s /root/saas/dataops/launch-frontend.yaml -c "HELM|elasticsearch|_"
fi
if [[ "$DATAOPS_FILEBEAT_ENABLE" == "false" ]]
then
python /app/remove-components.py -s /root/saas/dataops/launch.yaml -c "HELM|filebeat|_"
python /app/remove-components.py -s /root/saas/dataops/launch-frontend.yaml -c "HELM|filebeat|_"
fi
if [[ "$DATAOPS_METRICBEAT_ENABLE" == "false" ]]
then
python /app/remove-components.py -s /root/saas/dataops/launch.yaml -c "HELM|metricbeat|_"
python /app/remove-components.py -s /root/saas/dataops/launch-frontend.yaml -c "HELM|metricbeat|_"
fi
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/dataops/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=dataops --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
# wait flycore
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
sh /app/import.sh dataops /root/saas/dataops/build.zip /root/saas/dataops/launch-frontend.yaml /root/saas/dataops/launch-frontend-dev.yaml
fi
else
sh /app/import.sh dataops /root/saas/dataops/build.zip /root/saas/dataops/launch.yaml /root/saas/dataops/launch-frontend-dev.yaml
fi
saas-dataops1.sh: |
set -e
set -x
@ -391,6 +458,10 @@ data:
envsubst < /root/saas/dataops/api/skywalking/launch.yaml.tpl > tmp-launch.yaml
split
envsubst < /root/saas/dataops/api/prometheus/build.yaml.tpl > tmp-build.yaml
envsubst < /root/saas/dataops/api/prometheus/launch.yaml.tpl > tmp-launch.yaml
split
#envsubst < /root/saas/dataops/api/mongodb/build.yaml.tpl > tmp-build.yaml
#envsubst < /root/saas/dataops/api/mongodb/launch.yaml.tpl > tmp-launch.yaml
#split
@ -454,44 +525,30 @@ data:
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/team/api/build.yaml.tpl > /root/saas/team/api/build.yaml
envsubst < /root/saas/team/api/launch.yaml.tpl > /root/saas/team/api/launch.yaml
envsubst < /root/saas/team/ui/launch-v2.yaml.tpl > /root/saas/team/ui/launch.yaml
envsubst < /root/saas/team/ui/launch-v2-dev.yaml.tpl > /root/saas/team/ui/launch-dev.yaml
envsubst < /root/saas/team/build/launch.yaml.tpl > /root/saas/team/launch.yaml
envsubst < /root/saas/team/build/launch-backend.yaml.tpl > /root/saas/team/launch-backend.yaml
envsubst < /root/saas/team/build/launch-frontend.yaml.tpl > /root/saas/team/launch-frontend.yaml
envsubst < /root/saas/team/build/launch-frontend-dev.yaml.tpl > /root/saas/team/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/team/build --dest /root/saas/team/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/team/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --stage=prod --namespace=${NAMESPACE_ID} --app-id=team --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --stage=prod --namespace=${NAMESPACE_ID} --app-id=team --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id team --filepath /root/saas/team/ui/team-auto.zip --print-only-app-package-id=true --reset-version=true)
sh /app/import.sh team /root/saas/team/build.zip /root/saas/team/launch-frontend.yaml /root/saas/team/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id team --path /root/saas/team/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id team --path /root/saas/team/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/team/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/team/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/team/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id team --filepath /root/saas/team/team.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id team --path /root/saas/team/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id team --path /root/saas/team/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh team /root/saas/team/build.zip /root/saas/team/launch.yaml /root/saas/team/launch-frontend-dev.yaml
fi
saas-aiops.sh: |
set -e
@ -508,43 +565,26 @@ data:
fi
envsubst < /root/saas/aiops/api/build.yaml.tpl > /root/saas/aiops/api/build.yaml
envsubst < /root/saas/aiops/api/launch.yaml.tpl > /root/saas/aiops/api/launch.yaml
envsubst < /root/saas/aiops/ui/launch-v2.yaml.tpl > /root/saas/aiops/ui/launch.yaml
envsubst < /root/saas/aiops/ui/launch-v2-dev.yaml.tpl > /root/saas/aiops/ui/launch-dev.yaml
envsubst < /root/saas/aiops/build/launch.yaml.tpl > /root/saas/aiops/launch.yaml
envsubst < /root/saas/aiops/build/launch-backend.yaml.tpl > /root/saas/aiops/launch-backend.yaml
envsubst < /root/saas/aiops/build/launch-frontend.yaml.tpl > /root/saas/aiops/launch-frontend.yaml
envsubst < /root/saas/aiops/build/launch-frontend-dev.yaml.tpl > /root/saas/aiops/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/aiops/build --dest /root/saas/aiops/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/aiops/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=aiops --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=aiops --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
sh /app/core-deploy-check.sh
sh /app/import.sh aiops /root/saas/aiops/build.zip /root/saas/aiops/launch-frontend.yaml /root/saas/aiops/launch-frontend-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id aiops --filepath /root/saas/aiops/ui/aiops-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id aiops --path /root/saas/aiops/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id aiops --path /root/saas/aiops/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/aiops/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/aiops/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/aiops/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id aiops --filepath /root/saas/aiops/aiops.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id aiops --path /root/saas/aiops/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id aiops --path /root/saas/aiops/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh aiops /root/saas/aiops/build.zip /root/saas/aiops/launch.yaml /root/saas/aiops/launch-frontend-dev.yaml
fi
@ -561,43 +601,26 @@ data:
# build&launch cluster api
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
envsubst < /root/saas/job/api/build.yaml.tpl > /root/saas/job/api/build.yaml
envsubst < /root/saas/job/api/launch.yaml.tpl > /root/saas/job/api/launch.yaml
envsubst < /root/saas/job/ui/launch-v2.yaml.tpl > /root/saas/job/ui/launch.yaml
envsubst < /root/saas/job/ui/launch-v2-dev.yaml.tpl > /root/saas/job/ui/launch-dev.yaml
envsubst < /root/saas/job/build/launch.yaml.tpl > /root/saas/job/launch.yaml
envsubst < /root/saas/job/build/launch-backend.yaml.tpl > /root/saas/job/launch-backend.yaml
envsubst < /root/saas/job/build/launch-frontend.yaml.tpl > /root/saas/job/launch-frontend.yaml
envsubst < /root/saas/job/build/launch-frontend-dev.yaml.tpl > /root/saas/job/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/job/build --dest /root/saas/job/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/job/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=job --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=job --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
sh /app/import.sh job /root/saas/job/build.zip /root/saas/job/launch-frontend.yaml /root/saas/job/launch-frontend-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id job --filepath /root/saas/job/ui/job-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id job --path /root/saas/job/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id job --path /root/saas/job/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/job/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/job/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/job/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id job --filepath /root/saas/job/job.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id job --path /root/saas/job/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id job --path /root/saas/job/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh job /root/saas/job/build.zip /root/saas/job/launch.yaml /root/saas/job/launch-frontend-dev.yaml
fi
@ -615,13 +638,12 @@ data:
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
envsubst < /root/saas/healing/build/launch-frontend.yaml.tpl > /root/saas/healing/launch-frontend.yaml
envsubst < /root/saas/healing/build/launch-frontend-dev.yaml.tpl > /root/saas/healing/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/healing/build --dest /root/saas/healing/build.zip
envsubst < /root/saas/healing/ui/launch-v2.yaml.tpl > /root/saas/healing/ui/launch.yaml
envsubst < /root/saas/healing/ui/launch-v2-dev.yaml.tpl > /root/saas/healing/ui/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id healing --filepath /root/saas/healing/ui/healing-auto.zip --print-only-app-package-id=true --reset-version=true)
sh /app/import.sh healing /root/saas/healing/build.zip /root/saas/healing/launch-frontend.yaml /root/saas/healing/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id healing --path /root/saas/healing/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id healing --path /root/saas/healing/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
saas-health.sh: |
@ -634,6 +656,7 @@ data:
cd /root
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
export VERSION_CHECK=$(python /app/version_check.py /root/saas/health/build)
if [[ "$DATAOPS_DB_HOST" == "default-mysql" ]]
then
@ -642,41 +665,27 @@ data:
fi
envsubst < /root/saas/health/api/build.yaml.tpl > /root/saas/health/api/build.yaml
envsubst < /root/saas/health/api/launch.yaml.tpl > /root/saas/health/api/launch.yaml
envsubst < /root/saas/health/ui/launch-v2.yaml.tpl > /root/saas/health/ui/launch.yaml
envsubst < /root/saas/health/ui/launch-v2-dev.yaml.tpl > /root/saas/health/ui/launch-dev.yaml
envsubst < /root/saas/health/build/launch.yaml.tpl > /root/saas/health/launch.yaml
envsubst < /root/saas/health/build/launch-backend.yaml.tpl > /root/saas/health/launch-backend.yaml
envsubst < /root/saas/health/build/launch-frontend.yaml.tpl > /root/saas/health/launch-frontend.yaml
envsubst < /root/saas/health/build/launch-frontend-dev.yaml.tpl > /root/saas/health/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/health/build --dest /root/saas/health/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/health/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=health --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=health --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
sh /app/import.sh health /root/saas/health/build.zip /root/saas/health/launch-frontend.yaml /root/saas/health/launch-frontend-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id health --filepath /root/saas/health/ui/health-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id health --path /root/saas/health/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id health --path /root/saas/health/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
elif [[ "$VERSION_CHECK" == "NEED UPDATE" ]] ; then
cd /root/saas/health/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/health/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/health/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id health --filepath /root/saas/health/health.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id health --path /root/saas/health/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id health --path /root/saas/health/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh health /root/saas/health/build.zip /root/saas/health/launch.yaml /root/saas/health/launch-frontend-dev.yaml
fi
@ -692,16 +701,16 @@ data:
cd /root
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
export VERSION_CHECK=$(python /app/version_check.py /root/saas/ocenter/build)
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
envsubst < /root/saas/ocenter/build/launch.yaml.tpl > /root/saas/ocenter/launch.yaml
envsubst < /root/saas/ocenter/build/launch-frontend-dev.yaml.tpl > /root/saas/ocenter/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/ocenter/build --dest /root/saas/ocenter/build.zip
if [[ "$IMPORT_FRONTEND" == "true" && "$VERSION_CHECK" == "NEED UPDATE" ]] ; then
envsubst < /root/saas/ocenter/ui/launch-v2.yaml.tpl > /root/saas/ocenter/ui/launch.yaml
envsubst < /root/saas/ocenter/ui/launch-v2-dev.yaml.tpl > /root/saas/ocenter/ui/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id ocenter --filepath /root/saas/ocenter/ui/ocenter-auto.zip --print-only-app-package-id=true --reset-version=true)
sh /app/import.sh ocenter /root/saas/ocenter/build.zip /root/saas/ocenter/launch.yaml /root/saas/ocenter/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id ocenter --path /root/saas/ocenter/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id ocenter --path /root/saas/ocenter/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
saas-help.sh: |
@ -714,16 +723,17 @@ data:
cd /root
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
export VERSION_CHECK=$(python /app/version_check.py /root/saas/help/build)
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
envsubst < /root/saas/help/build/launch.yaml.tpl > /root/saas/help/launch.yaml
envsubst < /root/saas/help/build/launch-frontend-dev.yaml.tpl > /root/saas/help/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/help/build --dest /root/saas/help/build.zip
envsubst < /root/saas/help/ui/launch-v2.yaml.tpl > /root/saas/help/ui/launch.yaml
envsubst < /root/saas/help/ui/launch-v2-dev.yaml.tpl > /root/saas/help/ui/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id help --filepath /root/saas/help/ui/help-auto.zip --print-only-app-package-id=true --reset-version=true)
if [[ "$IMPORT_FRONTEND" == "true" && "$VERSION_CHECK" == "NEED UPDATE" ]] ; then
sh /app/import.sh help /root/saas/help/build.zip /root/saas/help/launch.yaml /root/saas/help/launch-frontend-dev.yaml
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id help --path /root/saas/help/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id help --path /root/saas/help/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
@ -738,81 +748,30 @@ data:
# build&launch search api
export NAMESPACE_ID=$(cat /run/secrets/kubernetes.io/serviceaccount/namespace)
export VERSION_CHECK=$(python /app/version_check.py /root/saas/search/build)
envsubst < /root/saas/search/api/build.yaml.tpl > /root/saas/search/api/build.yaml
envsubst < /root/saas/search/api/launch.yaml.tpl > /root/saas/search/api/launch.yaml
envsubst < /root/saas/search/ui/launch-v2.yaml.tpl > /root/saas/search/ui/launch.yaml
envsubst < /root/saas/search/ui/launch-v2-dev.yaml.tpl > /root/saas/search/ui/launch-dev.yaml
envsubst < /root/saas/search/build/launch.yaml.tpl > /root/saas/search/launch.yaml
envsubst < /root/saas/search/build/launch-backend.yaml.tpl > /root/saas/search/launch-backend.yaml
envsubst < /root/saas/search/build/launch-frontend.yaml.tpl > /root/saas/search/launch-frontend.yaml
envsubst < /root/saas/search/build/launch-frontend-dev.yaml.tpl > /root/saas/search/launch-frontend-dev.yaml
python /app/pack.py --src /root/saas/search/build --dest /root/saas/search/build.zip
if [[ "$IMAGE_BUILD_ENABLE" == "true" ]] ; then
cd /root/saas/search/api/
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=search --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=./launch.yaml --disable-dir-check
/root/swcli --config /swcli/swcli.yaml app-package oneflow --app-id=search --stage=prod --namespace=${NAMESPACE_ID} --tags="release=sreworks/x86_64" --arch=x86 --cluster=master --path=../launch-backend.yaml --disable-dir-check
if [[ "$IMPORT_FRONTEND" == "true" ]] ; then
envsubst < /root/saas/search/ui/launch-v2.yaml.tpl > /root/saas/search/ui/launch.yaml
envsubst < /root/saas/search/ui/launch-v2-dev.yaml.tpl > /root/saas/search/ui/launch-dev.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id search --filepath /root/saas/search/ui/search-auto.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id search --path /root/saas/search/ui/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id search --path /root/saas/search/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
else
cd /root/saas/search/
sh /app/core-action-service-check.sh
echo "" > merge-launch.yaml
cat /root/saas/search/api/launch.yaml >> merge-launch.yaml
echo "---" >> merge-launch.yaml
cat /root/saas/search/ui/launch.yaml >> merge-launch.yaml
cat merge-launch.yaml | python /app/reduce.py > launch.yaml
result=$(/root/swcli --config /swcli/swcli.yaml app-package import --app-id search --filepath /root/saas/search/search.zip --print-only-app-package-id=true --reset-version=true)
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage prod --app-id search --path /root/saas/search/launch.yaml --app-package-id $result --arch x86 --wait=true --cluster master
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace ${NAMESPACE_ID} --stage dev --app-id search --path /root/saas/search/ui/launch-dev.yaml --app-package-id $result --arch x86 --wait=true --cluster master
sh /app/import.sh search /root/saas/search/build.zip /root/saas/search/launch-frontend.yaml /root/saas/search/launch-frontend-dev.yaml
fi
elif [[ "$VERSION_CHECK" == "NEED UPDATE" ]] ; then
sh /app/import.sh search /root/saas/search/build.zip /root/saas/search/launch.yaml /root/saas/search/launch-frontend-dev.yaml
saas-dataops-grafana-import.sh: |
set -e
set -x
cd /root
until $(curl --silent --fail --show-error --output /dev/null http://admin:${GRAFANA_ADMIN_PASSWORD}@${SAAS_STAGE_ID}-dataops-grafana.${NAMESPACE_DATAOPS}/api/datasources); do
printf '.' ; sleep 1 ;
done ;
for file in /root/saas/dataops/ui/grafana/datasource/*.json ; do
if [ -e "$file" ] ; then
echo "importing $file" &&
curl --silent --fail --show-error \
--request POST http://admin:${GRAFANA_ADMIN_PASSWORD}@${SAAS_STAGE_ID}-dataops-grafana.${NAMESPACE_DATAOPS}/api/datasources \
--header "Content-Type: application/json" \
--data-binary "@$file" ;
echo "" ;
fi
done ;
for file in /root/saas/dataops/ui/grafana/dashboard/*.json ; do
if [ -e "$file" ] ; then
echo "importing $file" &&
curl --silent --fail --show-error \
--request POST http://admin:${GRAFANA_ADMIN_PASSWORD}@${SAAS_STAGE_ID}-dataops-grafana.${NAMESPACE_DATAOPS}/api/dashboards/import \
--header "Content-Type: application/json" \
--data-binary "@$file" ;
echo "" ;
fi
done
saas-demoapp.sh: |
@ -830,6 +789,94 @@ data:
/root/swcli --config /swcli/swcli.yaml deployment launch --namespace sreworks --stage prod --app-id sreworks1 --path /root/saas/app/launch-demoApp.yaml --app-package-id $result --arch x86 --wait=true --cluster master
fi
version_check.py: |
import sys
import os
import yaml
from oauthlib.oauth2 import LegacyApplicationClient
from requests_oauthlib import OAuth2Session
from distutils.version import StrictVersion
ENDPOINT = 'http://sreworks-appmanager'
CLIENT_ID = os.getenv('APPMANAGER_CLIENT_ID')
CLIENT_SECRET = os.getenv('APPMANAGER_CLIENT_SECRET')
USERNAME = os.getenv('APPMANAGER_USERNAME')
PASSWORD = os.getenv('APPMANAGER_PASSWORD')
class AppManagerClient(object):
def __init__(self, endpoint, client_id, client_secret, username, password):
os.environ.setdefault('OAUTHLIB_INSECURE_TRANSPORT', '1')
self._endpoint = endpoint
self._client_id = client_id
self._client_secret = client_secret
self._username = username
self._password = password
self._token = self._fetch_token()
@property
def client(self):
return OAuth2Session(self._client_id, token=self._token)
def _fetch_token(self):
oauth = OAuth2Session(client=LegacyApplicationClient(client_id=CLIENT_ID))
return oauth.fetch_token(
token_url=os.path.join(ENDPOINT, 'oauth/token'),
username=self._username,
password=self._password,
client_id=self._client_id,
client_secret=self._client_secret
)
appBuildPath = sys.argv[1]
f = open(appBuildPath + "/meta.yaml", 'r')
metaData = yaml.safe_load(f.read())
f.close()
appId = metaData["appId"]
baselineVersion = metaData["packageVersion"].split("+")[0]
appmanagerClient = AppManagerClient(ENDPOINT, CLIENT_ID, CLIENT_SECRET, USERNAME, PASSWORD)
res = appmanagerClient.client.get(ENDPOINT + "/realtime/app-instances?appId=" + appId + "&stageId=prod")
items = res.json()["data"].get("items", [])
if len(items) == 0:
print("NEED UPDATE")
sys.exit(0)
for item in items:
if StrictVersion(baselineVersion) > StrictVersion(item["simpleVersion"]):
print("NEED UPDATE")
sys.exit(0)
if StrictVersion(baselineVersion) == StrictVersion(item["simpleVersion"]) and item["status"] not in ["RUNNING","PENDING"]:
print("NEED UPDATE")
sys.exit(0)
print("NO UPDATE")
sys.exit(0)
upload-plugins.sh: |
set -x
cat /root/plugins/auto-install.list | while read line
do
python3 /root/plugins/pack.py -f /root/plugins/$line -t /tmp/plugin
/root/swcli plugin upload --config /swcli/swcli.yaml --filepath="/tmp/plugin.zip" --overwrite=true
rm /tmp/plugin.zip
version=$(cat /root/plugins/${line}/definition.yaml |grep 'definition.oam.dev/version'|awk '{print $NF}'|awk -F '"' '{print $2}')
name=$(echo $line| awk -F '/' '{print $2"/"$3}')
echo $version
echo $name
/root/swcli plugin operate --config /swcli/swcli.yaml --name=$name --version=$version --operation=enable
done
echo "all the plugins upload to the appmanager"
saas-sleep.sh: |
sleep 999999999999

View File

@ -16,6 +16,9 @@ spec:
- image: {{ template "images.progressCheck" . }}
name: job
imagePullPolicy: Always
envFrom:
- configMapRef:
name: init-configmap
{{ end }}

View File

@ -7,7 +7,7 @@ global:
images:
registry: sreworks-registry.cn-beijing.cr.aliyuncs.com/sreworks
tag: v1.2
tag: v1.3
accessMode: ingress
@ -20,6 +20,7 @@ global:
mavenSettingsXml: https://sreworks.oss-cn-beijing.aliyuncs.com/resource/settings.xml
alpineImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/alpine:latest
nodeImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/node:14.20.0-alpine3.15
nodeImage2: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/node:16.17-alpine
npmRegistryUrl: https://registry.npmmirror.com
migrateImage: sw-migrate
postrunImage: sw-postrun
@ -32,8 +33,8 @@ global:
grafanaImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/grafana:7.5.3
kibanaImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/kibana:7.10.2
elasticsearchImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/elasticsearch:7.10.2-with-plugins
skywalkingOapImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-oap-server-utc-8:8.5.0-es7
skywalkingUiImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-ui:8.5.0
skywalkingOapImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-oap-server-utc-8:9.2.0
skywalkingUiImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/skywalking-ui:9.2.0
busyboxImage: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/busybox:1.30
vvpRegistry: sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror
@ -50,7 +51,7 @@ platformLogo: /static/publicMedia/sreworks.png
installMode: default
progressCheck: false
progressCheck: true
debug: false
adminInitPassword: "12345678"
@ -72,6 +73,7 @@ saas:
stageId: prod
onlyBase: false
list:
- demoapp
- cluster
- app
- team
@ -85,7 +87,6 @@ saas:
- ocenter
- help
- upload
- demoapp
baseList:
- cluster
- app
@ -103,6 +104,11 @@ saas:
esPort: 9200
esUser: "elastic"
esPassword: "sreworkses123."
prometheusHost: "prod-dataops-prometheus-server.sreworks-dataops"
prometheusPort: "80"
filebeatEnable: true
metricbeatEnable: true
grafana:
password: "sreworks123456"
@ -113,7 +119,7 @@ swcli:
clientSecret: stLCjCPKbWmki65DsAj2jPoeBLPimpJa
source:
branch: v1.2
branch: v1.3
repo: https://code.aliyun.com/sreworks_public/mirror.git
appmanagerbase:
@ -131,6 +137,7 @@ appmanager:
account_super_secret_key: test-super-secret-key
server:
sreworksEnvs: true
jvmXMX: "512m"
docker:
enableKaniko: true

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
server.address=0.0.0.0
server.servletPath=/
spring.application.name=action
server.port=7001
management.server.port=-1
# DB
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://appmanager-mysql.ca221ae8860d9421688e59c8ab45c8b21.cn-hangzhou.alicontainer.com:3306/sreworks?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.username=root
spring.datasource.password=bguwsawqm6k
# TKGONE
kg.search.endpoint=http://100.67.175.100:8001/data/elasticsearch/queryByKvPre
kg.insert.endpoint=http://100.67.175.100:8001/database/elasticsearch/document/upserts
# Index
tesla.abm.url=tesla.alibaba-inc.com/#
env.new.api.prefix=http://tesla.alibaba-inc.com/#
# MyBatis
mybatis.mapper-locations=classpath*:/mybatis/*Mapper.xml
mybatis.configuration.map-underscore-to-camel-case=true
# jpa
#spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.show-sql=false
spring.jpa.open-in-view=false
spring.jpa.hibernate.use-new-id-generator-mappings=false
# swagger
tesla.config.swagger.base-package=com.alibaba.tesla

View File

@ -7,7 +7,7 @@ COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct && go mod download
RUN go env -w GO111MODULE=on GOPROXY=https://goproxy.cn,direct && go mod download
# Copy the go source
COPY main.go main.go

View File

@ -7,7 +7,7 @@ COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN GOPROXY=https://goproxy.io,direct GOSUMDB='off' go mod download
RUN GOSUMDB='off' go mod download
# Copy the go source
COPY main.go main.go

View File

@ -1,7 +1,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd"
# Default Dockerfile path
DOCKERFILE ?= "./Dockerfile"
# Go Proxy URL
@ -64,11 +64,11 @@ generate: controller-gen
# Build the docker image
docker-build: test
docker build . -t ${IMG} -f ${DOCKERFILE}
docker build . -t ${IMG}
# Build the docker image
docker-build-arm: test
sudo docker build . -t ${IMG} -f ./Dockerfile.arm64v8
docker build . -t ${IMG} -f ./Dockerfile.arm64v8
# Build the docker image
docker-build-sw:

View File

@ -146,7 +146,7 @@ func (r *MicroserviceReconciler) ReconcileMicroserviceAdvancedStatefulSet(
return err
}
log.V(1).Info("deleted conflict advancedStatefulSet", "AdvancedStatefulSet", instance)
return nil
return err
}
log.V(1).Info(fmt.Sprintf("update AdvancedStatefulSet %s spec to %+v", microservice.Name, instance.Spec))
return nil

View File

@ -153,7 +153,7 @@ func (r *MicroserviceReconciler) ReconcileMicroserviceCloneSet(ctx context.Conte
return err
}
log.V(1).Info("deleted conflict cloneset", "CloneSet", instance)
return nil
return err
}
log.V(1).Info(fmt.Sprintf("update CloneSet %s spec to %+v", microservice.Name, instance.Spec))
return nil

View File

@ -76,7 +76,7 @@ func main() {
if globalListener {
options = ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
MetricsBindAddress: "0",
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: namespace + ".leader.abm.io",
@ -84,7 +84,7 @@ func main() {
} else {
options = ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
MetricsBindAddress: "0",
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: namespace + ".leader.abm.io",

View File

@ -0,0 +1,5 @@
alter table am_plugin_resource
modify plugin_name varchar(64) not null comment 'Plugin 唯一标识';
alter table am_plugin_resource
collate = utf8mb4_general_ci;

View File

@ -0,0 +1,15 @@
CREATE TABLE IF NOT EXISTS `am_app_component`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`gmt_modified` datetime DEFAULT NULL COMMENT '最后修改时间',
`app_id` varchar(64) NOT NULL COMMENT '应用 ID',
`component_type` varchar(32) NOT NULL COMMENT '组件类型',
`component_name` varchar(64) NOT NULL COMMENT '组件名称',
`config` longtext NOT NULL COMMENT '配置内容',
PRIMARY KEY (`id`),
UNIQUE INDEX `uk_app_id_component_type_name` (`app_id`, `component_type`, `component_name`) USING BTREE,
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='应用组件绑定表';

View File

@ -0,0 +1,20 @@
DROP TABLE IF EXISTS `am_app_component`;
CREATE TABLE IF NOT EXISTS `am_app_component`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`gmt_modified` datetime DEFAULT NULL COMMENT '最后修改时间',
`namespace_id` varchar(64) NULL COMMENT 'Namespace ID',
`stage_id` varchar(64) NULL COMMENT 'Stage ID',
`app_id` varchar(64) NOT NULL COMMENT '应用 ID',
`component_type` varchar(32) NOT NULL COMMENT '组件类型',
`component_name` varchar(64) NOT NULL COMMENT '组件名称',
`config` longtext NOT NULL COMMENT '配置内容',
PRIMARY KEY (`id`),
KEY `idx_namespace_id` (`namespace_id`),
KEY `idx_stage_id` (`stage_id`),
UNIQUE INDEX `uk_app_id_component_type_name` (`app_id`, `component_type`, `component_name`) USING BTREE,
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='应用组件绑定表';

View File

@ -0,0 +1,21 @@
DROP TABLE IF EXISTS `am_app_component`;
CREATE TABLE IF NOT EXISTS `am_app_component`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`gmt_modified` datetime DEFAULT NULL COMMENT '最后修改时间',
`namespace_id` varchar(64) NULL COMMENT 'Namespace ID',
`stage_id` varchar(64) NULL COMMENT 'Stage ID',
`app_id` varchar(64) NOT NULL COMMENT '应用 ID',
`category` varchar(32) NOT NULL COMMENT '分类',
`component_type` varchar(32) NOT NULL COMMENT '组件类型',
`component_name` varchar(64) NOT NULL COMMENT '组件名称',
`config` longtext NOT NULL COMMENT '配置内容',
PRIMARY KEY (`id`),
KEY `idx_namespace_id` (`namespace_id`),
KEY `idx_stage_id` (`stage_id`),
UNIQUE INDEX `uk_unique` (`app_id`, `category`, `component_type`, `component_name`) USING BTREE,
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='应用组件绑定表';

View File

@ -0,0 +1,8 @@
alter table am_workflow_instance
collate = utf8mb4_general_ci;
alter table am_workflow_instance
add category varchar(32) null comment 'Workflow 分类' after app_id;
create index idx_category
on am_workflow_instance (category);

View File

@ -0,0 +1,17 @@
alter table am_app_component
modify component_type varchar(96) not null comment '组件类型';
alter table am_component_package_task
modify component_type varchar(96) null comment '组件类型';
alter table am_component_package
modify component_type varchar(96) null comment '组件类型';
alter table am_helm_meta
modify component_type varchar(96) null comment '组件类型';
alter table am_k8s_micro_service_meta
modify component_type varchar(96) null comment '组件类型';
alter table am_rt_component_instance
modify component_type varchar(96) null comment '组件类型';

View File

@ -0,0 +1,5 @@
alter table am_deploy_config collate = utf8mb4_general_ci;
alter table am_deploy_config_history collate = utf8mb4_general_ci;
alter table am_deploy_config modify type_id varchar(191) not null comment '类型 ID';
alter table am_deploy_config_history modify type_id varchar(191) not null comment '类型 ID';

View File

@ -0,0 +1,20 @@
alter table am_workflow_task
modify deploy_app_id bigint default 0 null comment '发起的新 DeployApp ID';
alter table am_workflow_task
modify deploy_app_unit_id varchar(64) default '' null comment '发起的新 DeployApp ID 归属单元';
alter table am_workflow_task
modify deploy_app_namespace_id varchar(64) default '' null comment '发起的新 DeployApp ID 归属 Namespace';
alter table am_workflow_task
modify deploy_app_stage_id varchar(64) default '' null comment '发起的新 DeployApp ID 归属 Stage';
alter table am_workflow_task
collate = utf8mb4_general_ci;
alter table am_workflow_task
add deploy_workflow_instance_id bigint null comment '发起的新 WorkflowInstance ID';
create index idx_deploy_workflow_instance_id
on am_workflow_task (deploy_workflow_instance_id);

View File

@ -0,0 +1,5 @@
alter table am_workflow_task
add task_outputs longtext default null COMMENT 'Workflow 任务节点输出 (JSONArray 字符串)';
alter table am_workflow_task
add task_inputs longtext default null COMMENT 'Workflow 任务节点输入 (JSONArray 字符串)';

View File

@ -0,0 +1,5 @@
{
"name": "secret.schema.abm.io",
"jsonSchema": {
}
}

View File

@ -23,6 +23,20 @@ spec:
- STORAGE_CLASS
- ACCOUNT_SUPER_CLIENT_ID
- ACCOUNT_SUPER_CLIENT_SECRET
- DATA_ES_PASSWORD
- DATA_ES_USER
- DATA_ES_HOST
- DATA_ES_PORT
- DATA_PROM_HOST
- DATA_PROM_PORT
- DATA_DB_HOST
- DATA_DB_PORT
- DATA_DB_USER
- DATA_DB_PASSWORD
- KAFKA_ENDPOINT
- MINIO_ENDPOINT
- MINIO_ACCESS_KEY
- MINIO_SECRET_KEY
toFieldPaths:
- spec.keys
@ -59,4 +73,31 @@ spec:
fieldPath: '{{ spec.env.ACCOUNT_SUPER_CLIENT_ID }}'
- name: Global.ACCOUNT_SUPER_CLIENT_SECRET
fieldPath: '{{ spec.env.ACCOUNT_SUPER_CLIENT_SECRET }}'
- name: Global.DATA_ES_PASSWORD
fieldPath: '{{ spec.env.DATA_ES_PASSWORD }}'
- name: Global.DATA_ES_USER
fieldPath: '{{ spec.env.DATA_ES_USER }}'
- name: Global.DATA_ES_HOST
fieldPath: '{{ spec.env.DATA_ES_HOST }}'
- name: Global.DATA_ES_PORT
fieldPath: '{{ spec.env.DATA_ES_PORT }}'
- name: Global.DATA_PROM_HOST
fieldPath: '{{ spec.env.DATA_PROM_HOST }}'
- name: Global.DATA_PROM_PORT
fieldPath: '{{ spec.env.DATA_PROM_PORT }}'
- name: Global.DATA_DB_PORT
fieldPath: '{{ spec.env.DATA_DB_PORT }}'
- name: Global.DATA_DB_HOST
fieldPath: '{{ spec.env.DATA_DB_HOST }}'
- name: Global.DATA_DB_USER
fieldPath: '{{ spec.env.DATA_DB_USER }}'
- name: Global.DATA_DB_PASSWORD
fieldPath: '{{ spec.env.DATA_DB_PASSWORD }}'
- name: Global.KAFKA_ENDPOINT
fieldPath: '{{ spec.env.KAFKA_ENDPOINT }}'
- name: Global.MINIO_ENDPOINT
fieldPath: '{{ spec.env.MINIO_ENDPOINT }}'
- name: Global.MINIO_ACCESS_KEY
fieldPath: '{{ spec.env.MINIO_ACCESS_KEY }}'
- name: Global.MINIO_SECRET_KEY
fieldPath: '{{ spec.env.MINIO_SECRET_KEY }}'

View File

@ -0,0 +1,11 @@
apiVersion: core.oam.dev/v1alpha2
kind: TraitDefinition
metadata:
name: secret.trait.abm.io
spec:
runtime: pre
appliesToWorkloads:
- "*"
definitionRef:
name: secret.schema.abm.io
example: {}

View File

@ -14,8 +14,8 @@ ARG APP_NAME=tesla-appmanager
COPY --from=build /app/${APP_NAME}-start-standalone/target/${APP_NAME}.jar /app/${APP_NAME}-standalone.jar
COPY --from=build /app/${APP_NAME}-start-standalone/target/${APP_NAME}/BOOT-INF/classes/application-docker.properties /app/config/application.properties
# Copy Resources
COPY --from=build /app/${APP_NAME}-start-standalone/target/${APP_NAME}/BOOT-INF/classes/dynamicscripts /app/dynamicscripts
COPY --from=build /app/${APP_NAME}-start-standalone/target/${APP_NAME}/BOOT-INF/classes/jinja /app/jinja
COPY --from=build /app/${APP_NAME}-start-standalone/target/classes/dynamicscripts /app/dynamicscripts
COPY --from=build /app/${APP_NAME}-start-standalone/target/classes/jinja /app/jinja
RUN wget -O /app/helm "https://abm-storage.oss-cn-zhangjiakou.aliyuncs.com/lib/helm" \
&& chmod +x /app/helm \
&& wget -O /app/kustomize "https://abm-storage.oss-cn-zhangjiakou.aliyuncs.com/lib/kustomize" \

View File

@ -13,8 +13,8 @@ WORKDIR /root
COPY --from=build /app/tesla-appmanager-start-standalone/target/tesla-appmanager.jar /app/tesla-appmanager-standalone.jar
COPY --from=build /app/tesla-appmanager-start-standalone/target/tesla-appmanager/BOOT-INF/classes/application-docker.properties /app/config/application.properties
# Copy Resources
COPY --from=build /app/tesla-appmanager-start-standalone/target/tesla-appmanager/BOOT-INF/classes/dynamicscripts /app/dynamicscripts
COPY --from=build /app/tesla-appmanager-start-standalone/target/tesla-appmanager/BOOT-INF/classes/jinja /app/jinja
COPY --from=build /app/tesla-appmanager-start-standalone/target/classes/dynamicscripts /app/dynamicscripts
COPY --from=build /app/tesla-appmanager-start-standalone/target/classes/jinja /app/jinja
RUN curl -o /app/helm "${HELM_BIN_URL}" \
&& chmod +x /app/helm \
&& curl -o /app/kustomize "${KUSTOMIZE_BIN_URL}" \

View File

@ -7,7 +7,7 @@
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<packaging>pom</packaging>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<modules>
<module>tesla-appmanager-api</module>
<module>tesla-appmanager-common</module>
@ -63,6 +63,8 @@
<task-flow-service.version>1.1.0</task-flow-service.version>
<!-- other -->
<knife4j-springdoc-ui.version>3.0.3</knife4j-springdoc-ui.version>
<springdoc-openapi-ui.version>1.6.11</springdoc-openapi-ui.version>
<jackson-annotations.version>2.13.2</jackson-annotations.version>
<pagehelper.version>5.1.10</pagehelper.version>
<pagehelper-spring-boot-starter.version>1.4.1</pagehelper-spring-boot-starter.version>
@ -87,6 +89,9 @@
<!-- storage -->
<aliyun-sdk-oss.version>3.14.0</aliyun-sdk-oss.version>
<!-- SLS -->
<aliyun-sdk-sls.version>0.6.71</aliyun-sdk-sls.version>
<!-- plugin -->
<mybatis-generator.version>1.3.7</mybatis-generator.version>
<h2.version>2.1.210</h2.version>
@ -274,6 +279,18 @@
<version>${spring-cloud-stream-test-support.version}</version>
</dependency>
<!-- knife4j -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-springdoc-ui</artifactId>
<version>${knife4j-springdoc-ui.version}</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc-openapi-ui.version}</version>
</dependency>
<!-- groovy / shit mvnrepo alibaba -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
@ -588,6 +605,13 @@
<version>${aliyun-sdk-oss.version}</version>
</dependency>
<!-- SLS -->
<dependency>
<groupId>com.aliyun.openservices</groupId>
<artifactId>aliyun-log</artifactId>
<version>${aliyun-sdk-sls.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
@ -669,9 +693,45 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>**/test/**</exclude>
<exclude>**/repository/**</exclude>
<exclude>**/domain/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
</plugin>
</plugins>
</reporting>
<distributionManagement>
<repository>
<id>snapshots</id>

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -1,7 +1,10 @@
package com.alibaba.tesla.appmanager.api.provider;
import com.alibaba.tesla.appmanager.domain.dto.AppComponentDTO;
import com.alibaba.tesla.appmanager.domain.req.appcomponent.AppComponentCreateReq;
import com.alibaba.tesla.appmanager.domain.req.appcomponent.AppComponentDeleteReq;
import com.alibaba.tesla.appmanager.domain.req.appcomponent.AppComponentQueryReq;
import com.alibaba.tesla.appmanager.domain.req.appcomponent.AppComponentUpdateReq;
import java.util.List;
@ -12,6 +15,42 @@ import java.util.List;
*/
public interface AppComponentProvider {
/**
* 获取指定应用下的指定关联 Component 对象
*
* @param request 应用组件绑定查询请求
* @param operator 操作人
* @return AppComponentDTO
*/
AppComponentDTO get(AppComponentQueryReq request, String operator);
/**
* 创建应用下的关联 Component 绑定
*
* @param request 创建请求
* @param operator 操作人
* @return 绑定后的结果
*/
AppComponentDTO create(AppComponentCreateReq request, String operator);
/**
* 更新应用下的关联 Component 绑定
*
* @param request 更新请求
* @param operator 操作人
* @return 绑定后的结果
*/
AppComponentDTO update(AppComponentUpdateReq request, String operator);
/**
* 删除指定应用下的指定关联 Component 对象
*
* @param request 应用组件绑定查询请求
* @param operator 操作人
* @return AppComponentDTO
*/
void delete(AppComponentDeleteReq request, String operator);
/**
* 获取指定 appId 下的所有关联 Component 对象
*

View File

@ -1,9 +1,8 @@
package com.alibaba.tesla.appmanager.api.provider;
import com.alibaba.tesla.appmanager.common.pagination.Pagination;
import com.alibaba.tesla.appmanager.domain.dto.DeployConfigDTO;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigApplyTemplateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigDeleteReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigGenerateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.*;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigApplyTemplateRes;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigGenerateRes;
@ -30,6 +29,22 @@ public interface DeployConfigProvider {
*/
DeployConfigGenerateRes generate(DeployConfigGenerateReq req);
/**
* 根据指定查询条件获取列表不支持继承
*
* @param req 查询请求
* @return 部署配置列表
*/
Pagination<DeployConfigDTO> list(DeployConfigListReq req);
/**
* 更新指定 apiVersion + appId + typeId + envId 对应的 DeployConfig 记录
*
* @param req 更新请求
* @return 更新后的对象
*/
DeployConfigDTO upsert(DeployConfigUpsertReq req);
/**
* 删除指定 apiVersion + appId + typeId + envId 对应的 DeployConfig 记录
*

View File

@ -1,6 +1,10 @@
package com.alibaba.tesla.appmanager.api.provider;
import com.alibaba.tesla.appmanager.common.pagination.Pagination;
import com.alibaba.tesla.appmanager.domain.dto.PluginDefinitionDTO;
import com.alibaba.tesla.appmanager.domain.dto.PluginFrontendDTO;
import com.alibaba.tesla.appmanager.domain.req.PluginQueryReq;
import com.alibaba.tesla.appmanager.domain.req.plugin.*;
import org.springframework.web.multipart.MultipartFile;
/**
@ -10,12 +14,51 @@ import org.springframework.web.multipart.MultipartFile;
*/
public interface PluginProvider {
/**
* 获取插件列表
*
* @param request 查询插件列表请求
* @return 插件列表
*/
Pagination<PluginDefinitionDTO> list(PluginQueryReq request);
/**
* 查询单个插件
*
* @return 插件列表
*/
PluginDefinitionDTO get(PluginGetReq request);
/**
* 启用指定插件
*
* @param request 插件启用请求
* @return 开启后的 PluginDefinition 对象
*/
PluginDefinitionDTO enable(PluginEnableReq request);
/**
* 关闭指定插件
*
* @param request 插件关闭请求
* @return 关闭后的 PluginDefinition 对象
*/
PluginDefinitionDTO disable(PluginDisableReq request);
/**
* 上传插件 (默认不启用)
*
* @param file API 上传文件
* @param force 是否强制上传覆盖
* @param request 上传插件请求
* @return PluginDefinitionDTO
*/
PluginDefinitionDTO upload(MultipartFile file, boolean force);
PluginDefinitionDTO upload(MultipartFile file, PluginUploadReq request);
/**
* 获取 Plugin Frontend 资源
*
* @param request 获取请求
* @return PluginFrontend DTO 对象
*/
PluginFrontendDTO getFrontend(PluginFrontendGetReq request);
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.common.pagination.Pagination;
import com.alibaba.tesla.appmanager.domain.dto.TraitDTO;
import com.alibaba.tesla.appmanager.domain.req.trait.TraitQueryReq;
import com.alibaba.tesla.appmanager.domain.schema.TraitDefinition;
/**
* Trait 服务
@ -38,6 +39,14 @@ public interface TraitProvider {
*/
void apply(String request, String operator);
/**
* 向系统中新增或更新一个 Trait
*
* @param traitDefinition TraitDefinition
* @param operator 操作人
*/
void apply(TraitDefinition traitDefinition, String operator);
/**
* 删除指定条件的 Trait
*

View File

@ -1,5 +1,6 @@
package com.alibaba.tesla.appmanager.api.provider;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.common.pagination.Pagination;
import com.alibaba.tesla.appmanager.domain.dto.WorkflowInstanceDTO;
import com.alibaba.tesla.appmanager.domain.option.WorkflowInstanceOption;
@ -30,6 +31,23 @@ public interface WorkflowInstanceProvider {
*/
Pagination<WorkflowInstanceDTO> list(WorkflowInstanceListReq request);
/**
* 覆写 Context 到指定 Workflow 实例
*
* @param workflowInstanceId Workflow 实例 ID
* @param context Context JSONObject
*/
void putContext(Long workflowInstanceId, JSONObject context);
/**
* 获取指定应用指定 category 的最后一个 SUCCESS 状态的 Workflow 实例
*
* @param appId 应用 ID
* @param category 分类
* @return WorkflowInstanceDTO
*/
WorkflowInstanceDTO getLastSuccessInstance(String appId, String category);
/**
* 启动一个 Workflow 实例
*
@ -41,7 +59,7 @@ public interface WorkflowInstanceProvider {
WorkflowInstanceDTO launch(String appId, String configuration, WorkflowInstanceOption options);
/**
* 恢复处于 SUSPEND 状态的 Workflow 实例
* 唤醒处于 SUSPEND 状态的 Workflow 实例
*
* @param workflowInstanceId Workflow 实例 ID
* @return 执行结果

View File

@ -13,7 +13,7 @@
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager-auth-client</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>

View File

@ -156,8 +156,10 @@ public class AppManagerClient {
Request request;
if (!StringUtils.isEmpty(internalAuthToken)) {
request = requestBuilder.header("Authorization", "Bearer " + internalAuthToken).build();
log.info("action=appmanagerAccessToken|token={}|expiresAt={}", internalAuthToken, internalExpiresAt);
} else {
request = requestBuilder.header("X-EmpId", "SYSTEM").build();
log.info("action=appmanagerAccessToken|empId=SYSTEM");
}
return httpClient.newCall(request).execute();
}
@ -174,8 +176,10 @@ public class AppManagerClient {
Request request;
if (!StringUtils.isEmpty(internalAuthToken)) {
request = requestBuilder.header("Authorization", "Bearer " + internalAuthToken).build();
log.info("action=appmanagerAccessToken|token={}|expiresAt={}", internalAuthToken, internalExpiresAt);
} else {
request = requestBuilder.header("X-EmpId", "SYSTEM").build();
log.info("action=appmanagerAccessToken|empId=SYSTEM");
}
Response response = httpClient.newCall(request).execute();
ResponseBody responseBody = response.body();

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -1,6 +1,7 @@
package com.alibaba.tesla.appmanager.auth.config;
import com.alibaba.tesla.appmanager.autoconfig.AuthProperties;
import com.alibaba.tesla.appmanager.autoconfig.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
@ -20,6 +21,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private AuthProperties authProperties;
@Autowired
private SystemProperties systemProperties;
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
@ -44,15 +48,21 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
if (authProperties.getEnableAuth()) {
web.ignoring()
WebSecurity.IgnoredRequestConfigurer pre = web.ignoring()
.antMatchers("/status.taobao")
.antMatchers("/actuator/**")
.antMatchers("/traits**")
.antMatchers("/flow-manager/**")
.antMatchers("/traits/**")
.antMatchers(HttpMethod.POST, "/apps")
.antMatchers("/definition-schemas**")
.antMatchers(HttpMethod.GET, "/realtime/**");
if (systemProperties.isEnableOpenApiUi()) {
pre.antMatchers("/doc.html")
.antMatchers("/webjars**")
.antMatchers("/webjars/**")
.antMatchers("/v3/api-docs*")
.antMatchers("/v3/api-docs/*");
}
} else {
web.ignoring().antMatchers("/**");
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>tesla-appmanager</artifactId>
<groupId>com.alibaba.tesla</groupId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -22,6 +22,11 @@ public class SystemProperties {
*/
private boolean enableProductTaskExecutor = true;
/**
* 是否开启 doc.html (Knife4j)
*/
private boolean enableOpenApiUi = false;
/**
* 流程历史保留时长
*/

View File

@ -5,7 +5,8 @@
<parent>
<artifactId>tesla-appmanager</artifactId>
<groupId>com.alibaba.tesla</groupId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -91,10 +91,21 @@ public class GitServiceImpl implements GitService {
// 存在 repoPath 的时候需要将 repoPath 对应的目录拷贝到 dir 实际对应的目录中
if (StringUtils.isNotEmpty(request.getRepoPath())) {
Path fromdir = tmpDir.resolve(request.getRepoPath());
Path todir = dir.resolve(request.getRepoPath()).getParent();
Path fromdir;
Path todir;
if(request.getRepoPath().startsWith("/")){
fromdir = tmpDir.resolve(request.getRepoPath().substring(1));
}else{
fromdir = tmpDir.resolve(request.getRepoPath());
}
if(StringUtils.isNotEmpty(request.getRewriteRepoPath())){
todir = dir.resolve(request.getRewriteRepoPath());
FileUtils.moveDirectory(fromdir.toFile(), todir.toFile());
}else{
todir = dir.resolve(request.getRepoPath()).getParent();
FileUtils.moveDirectoryToDirectory(fromdir.toFile(), todir.toFile(), true);
}
}
} catch (IOException e) {
throw new AppException(AppErrorCode.UNKNOWN_ERROR, "cannot create temp directory", e);
} finally {
@ -180,7 +191,7 @@ public class GitServiceImpl implements GitService {
String rest = StringUtil.trimStringByString(repo, HTTPS_PREFIX);
return String.format("%s%s:%s@%s", HTTPS_PREFIX, ciAccount, ciToken, rest);
} else {
return String.format("http://%s:%s@gitlab-sc.alibaba-inc.com/%s", ciAccount, ciToken, repo);
throw new AppException(AppErrorCode.INVALID_USER_ARGS, "not supported");
}
}

View File

@ -8,7 +8,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -52,6 +52,11 @@ public class AppFlowVariableKey {
*/
public static final String CONFIGURATION = "CONFIGURATION";
/**
* 启动覆盖全局参数
*/
public static final String OVERWRITE_PARAMS = "OVERWRITE_PARAMS";
/**
* 当前系统中的组件包列表
*/

View File

@ -114,4 +114,9 @@ public class DefaultConstant {
public static final String UNIT = "Unit";
public static final String PRIVATE_ABM_CATEGORY = "专有云";
/**
* 默认 Workflow 分类
*/
public static final String WORKFLOW_CATEGORY = "DEFAULT";
}

View File

@ -0,0 +1,19 @@
package com.alibaba.tesla.appmanager.common.constants;
/**
* Pattern 常量
*
* @author yaoxing.gyx@alibaba-inc.com
*/
public class PatternConstant {
/**
* 合法 DNS REGEX
*/
public static final String DNS_REGEX = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$";
/**
* 字母/数字 REGEX
*/
public static final String ALPHANUMERIC_REGEX = "^[a-zA-Z0-9]+$";
}

View File

@ -0,0 +1,14 @@
package com.alibaba.tesla.appmanager.common.constants;
/**
* Plugin 常量
*
* @author yaoxing.gyx@alibaba-inc.com
*/
public class PluginConstant {
/**
* Plugin 的当前版本
*/
public static final String PLUGIN_CURRENT_VERSION = "current";
}

View File

@ -0,0 +1,34 @@
package com.alibaba.tesla.appmanager.common.constants;
/**
* Workflow Context 中内置 Key 常量清单
*
* @author yaoxing.gyx@alibaba-inc.com
*/
public class WorkflowContextKeyConstant {
/**
* 部署单覆盖参数 (用于 apply-components 的上下过程连接)
*/
public static final String DEPLOY_OVERWRITE_PARAMETERS = "_internal_overwrite_parameters";
/**
* 部署单覆盖参数 (用于 apply-components 的上下过程连接)
*/
public static final String DEPLOY_DELIVER_PARAMETERS = "_internal_deliver_parameters";
/**
* 终止后续执行
*/
public static final String CANCEL_EXECUTION = "_internal_cancel_execution";
/**
* 终止后续执行原因
*/
public static final String CANCEL_EXECUTION_REASON = "_internal_cancel_execution_reason";
/**
* 安静执行模式 (不需要人工确认)
*/
public static final String QUIET_MODE = "_internal_quiet_mode";
}

View File

@ -1,9 +1,5 @@
package com.alibaba.tesla.appmanager.common.enums;
import com.alibaba.tesla.appmanager.common.exception.AppErrorCode;
import com.alibaba.tesla.appmanager.common.exception.AppException;
import com.google.common.base.Enums;
/**
* 组件类型 Enum
*
@ -91,75 +87,25 @@ public enum ComponentTypeEnum {
*/
SCRIPT;
public static ComponentTypeEnum parse(String value) {
ComponentTypeEnum result = Enums.getIfPresent(ComponentTypeEnum.class, value).orNull();
if (result == null) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
String.format("invalid component type %s", value));
}
return result;
/**
* 返回指定的 componentType 是否为 addon
*
* @param componentType Component Type
* @return true or false
*/
public static boolean isAddon(String componentType) {
return RESOURCE_ADDON.toString().equals(componentType)
|| TRAIT_ADDON.toString().equals(componentType)
|| CUSTOM_ADDON.toString().equals(componentType);
}
/**
* 返回当前 component 类型是否为非 Addon
* 返回指定的 componentType 是否为 K8S_MICROSERVICE || K8S_JOB
*
* @param componentType Component Type
* @return true or false
*/
public boolean isNotAddon() {
return !RESOURCE_ADDON.equals(this) && !TRAIT_ADDON.equals(this) && !CUSTOM_ADDON.equals(this);
}
/**
* 返回当前 component 类型是否为 Addon
*
* @return true or false
*/
public boolean isAddon() {
return RESOURCE_ADDON.equals(this) || INTERNAL_ADDON.equals(this);
}
/**
* 返回当前 component 类型是否为 RESOURCE_ADDON
*
* @return true or false
*/
public boolean isResourceAddon() {
return RESOURCE_ADDON.equals(this);
}
/**
* 返回当前 component 类型是否为 INTERNAL_ADDON
*
* @return true or false
*/
public boolean isInternalAddon() {
return INTERNAL_ADDON.equals(this);
}
/**
* 返回当前 component 类型是否为 K8S_MICROSERVICE
*
* @return true or false
*/
public boolean isKubernetesMicroservice() {
return K8S_MICROSERVICE.equals(this);
}
/**
* 返回当前 component 类型是否为 K8S_JOB
*
* @return true or false
*/
public boolean isKubernetesJob() {
return K8S_JOB.equals(this);
}
/**
* 返回当前 component 类型是否为 HELM
*
* @return true or false
*/
public boolean isHelm() {
return HELM.equals(this);
public static boolean isMicroserviceOrJob(String componentType) {
return K8S_MICROSERVICE.toString().equals(componentType) || K8S_JOB.toString().equals(componentType);
}
}

View File

@ -20,5 +20,10 @@ public enum DeployAppAttrTypeEnum {
/**
* 全局变量 (初始化)
*/
GLOBAL_VARIABLES;
GLOBAL_VARIABLES,
/**
* 初始化时提供的覆盖变量 (用于 GLOBAL_PARAMS 的覆盖)
*/
OVERWRITE_PARAMS;
}

View File

@ -15,6 +15,11 @@ public enum PluginKindEnum {
*/
COMPONENT_DEFINITION("ComponentDefinition"),
/**
* Resource Addon
*/
RESOURCE_ADDON_DEFINITION("ResourceAddonDefinition"),
/**
* Trait
*/

View File

@ -80,7 +80,12 @@ public enum AppErrorCode {
/**
* 认证异常
*/
AUTHORIZED_ERROR(10013, "AUTHORIZED_ERROR");
AUTHORIZED_ERROR(10013, "AUTHORIZED_ERROR"),
/**
* Groovy 脚本异常
*/
GROOVY_ERROR(10014, "GROOVY_ERROR");
private final int code;
private final String description;

View File

@ -39,7 +39,7 @@ public class AddonUtil {
* @param addonId Addon ID
* @return Addon Key
*/
public static String combineAddonKey(ComponentTypeEnum componentType, String addonId) {
public static String combineAddonKey(String componentType, String addonId) {
return String.format("%s-%s", componentType, addonId);
}
}

View File

@ -0,0 +1,23 @@
package com.alibaba.tesla.appmanager.common.util;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
/**
* @ClassName: ExceptionUtil
* @Author: dyj
* @DATE: 2021-04-01
* @Description:
**/
public class ExceptionUtil {
public static String getStackTrace(Throwable aThrowable) {
if (aThrowable == null) {
return null;
}
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
aThrowable.printStackTrace(printWriter);
return result.toString();
}
}

View File

@ -117,4 +117,15 @@ public class PackageUtil {
}
}
}
/**
* 构造组件包 ZIP basename (componentType / 替换为 _)
*
* @param componentType 组件类型
* @param componentName 组件名称
* @return 构造后的一层文件名 basename
*/
public static String buildComponentPackageZipBasename(String componentType, String componentName) {
return String.format("%s_%s.zip", componentType.replaceAll("/", "_"), componentName);
}
}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -27,6 +27,10 @@
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager-api</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager-spring</artifactId>
</dependency>
<dependency>
<groupId>io.sreworks</groupId>

View File

@ -6,6 +6,7 @@ import com.alibaba.tesla.appmanager.domain.dto.DefinitionSchemaDTO;
import com.alibaba.tesla.appmanager.domain.req.DefinitionSchemaQueryReq;
import com.alibaba.tesla.common.base.TeslaBaseResult;
import com.alibaba.tesla.web.controller.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -18,6 +19,7 @@ import java.util.HashMap;
* @author yaoxing.gyx@alibaba-inc.com
*/
@Slf4j
@Tag(name = "DefinitionSchema API")
@RequestMapping("/definition-schemas")
@RestController
public class DefinitionSchemaController extends BaseController {

View File

@ -6,7 +6,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -1,11 +1,18 @@
package com.alibaba.tesla.appmanager.deployconfig.assembly;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.common.assembly.BaseDtoConvert;
import com.alibaba.tesla.appmanager.common.util.ClassUtil;
import com.alibaba.tesla.appmanager.common.util.SchemaUtil;
import com.alibaba.tesla.appmanager.deployconfig.repository.domain.DeployConfigDO;
import com.alibaba.tesla.appmanager.domain.dto.DeployConfigDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Deploy Config DTO Converter
*
@ -18,4 +25,27 @@ public class DeployConfigDtoConvert extends BaseDtoConvert<DeployConfigDTO, Depl
public DeployConfigDtoConvert() {
super(DeployConfigDTO.class, DeployConfigDO.class);
}
public DeployConfigDTO to(DeployConfigDO DeployConfigDO) {
if (DeployConfigDO == null) {
return null;
}
DeployConfigDTO result = new DeployConfigDTO();
ClassUtil.copy(DeployConfigDO, result);
if (StringUtils.isNotEmpty(result.getConfig())) {
String restStr = result.getConfig();
if (restStr.startsWith("!!map")) {
restStr = restStr.substring("!!map".length());
}
restStr = restStr.trim();
if (restStr.startsWith("-")) {
List<JSONObject> list = SchemaUtil.toSchemaList(JSONObject.class, result.getConfig());
result.setConfigJson(JSONArray.parseArray(JSONArray.toJSONString(list)));
} else {
result.setConfigJson(SchemaUtil.toSchema(JSONObject.class, result.getConfig()));
}
}
return result;
}
}

View File

@ -1,18 +1,21 @@
package com.alibaba.tesla.appmanager.deployconfig.provider.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.api.provider.DeployConfigProvider;
import com.alibaba.tesla.appmanager.common.pagination.Pagination;
import com.alibaba.tesla.appmanager.common.util.ClassUtil;
import com.alibaba.tesla.appmanager.deployconfig.assembly.DeployConfigDtoConvert;
import com.alibaba.tesla.appmanager.deployconfig.repository.condition.DeployConfigQueryCondition;
import com.alibaba.tesla.appmanager.deployconfig.repository.domain.DeployConfigDO;
import com.alibaba.tesla.appmanager.deployconfig.service.DeployConfigService;
import com.alibaba.tesla.appmanager.domain.dto.DeployConfigDTO;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigApplyTemplateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigDeleteReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigGenerateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.*;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigApplyTemplateRes;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigGenerateRes;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -60,6 +63,33 @@ public class DeployConfigProviderImpl implements DeployConfigProvider {
return deployConfigService.generate(req);
}
/**
* 根据指定查询条件获取列表不支持继承
*
* @param req 查询请求
* @return 部署配置列表
*/
@Override
public Pagination<DeployConfigDTO> list(DeployConfigListReq req) {
DeployConfigQueryCondition condition = new DeployConfigQueryCondition();
ClassUtil.copy(req, condition);
List<DeployConfigDO> results = deployConfigService.list(condition);
log.info("list deploy config from database|condition={}|resultSize={}",
JSONObject.toJSONString(condition), results.size());
return Pagination.valueOf(results, deployConfigDtoConvert::to);
}
/**
* 更新指定 apiVersion + appId + typeId + envId 对应的 DeployConfig 记录
*
* @param req 更新请求
* @return 更新后的对象
*/
@Override
public DeployConfigDTO upsert(DeployConfigUpsertReq req) {
return deployConfigDtoConvert.to(deployConfigService.update(req));
}
/**
* 删除指定 apiVersion + appId + typeId + envId 对应的 DeployConfig 记录
*

View File

@ -27,6 +27,11 @@ public class DeployConfigQueryCondition extends BaseCondition {
*/
private String typeId;
/**
* 类型 ID 前缀
*/
private String typeIdPrefix;
/**
* 环境 ID
*/

View File

@ -7,6 +7,7 @@ import com.alibaba.tesla.appmanager.deployconfig.repository.domain.DeployConfigD
import com.alibaba.tesla.appmanager.deployconfig.repository.domain.DeployConfigDOExample;
import com.alibaba.tesla.appmanager.deployconfig.repository.mapper.DeployConfigDOMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -60,6 +61,8 @@ public class DeployConfigRepositoryImpl implements DeployConfigRepository {
}
if (StringUtils.isNotBlank(condition.getTypeId())) {
criteria.andTypeIdEqualTo(condition.getTypeId());
} else if (StringUtils.isNotEmpty(condition.getTypeIdPrefix())) {
criteria.andTypeIdLike(StringEscapeUtils.escapeSql(condition.getTypeIdPrefix()) + "%");
}
if (condition.getEnvId() != null) {
criteria.andEnvIdEqualTo(condition.getEnvId());

View File

@ -46,7 +46,7 @@ public interface DeployConfigService {
* @param req 更新请求
* @return 更新后的对象
*/
DeployConfigDO update(DeployConfigUpdateReq req);
DeployConfigDO update(DeployConfigUpsertReq req);
/**
* 删除指定 apiVersion + appId + typeId + envId 对应的 DeployConfig 记录

View File

@ -17,10 +17,7 @@ import com.alibaba.tesla.appmanager.deployconfig.service.DeployConfigService;
import com.alibaba.tesla.appmanager.domain.container.DeployAppRevisionName;
import com.alibaba.tesla.appmanager.domain.container.DeployConfigEnvId;
import com.alibaba.tesla.appmanager.domain.container.DeployConfigTypeId;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigApplyTemplateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigDeleteReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigGenerateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.DeployConfigUpdateReq;
import com.alibaba.tesla.appmanager.domain.req.deployconfig.*;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigApplyTemplateRes;
import com.alibaba.tesla.appmanager.domain.res.deployconfig.DeployConfigGenerateRes;
import com.alibaba.tesla.appmanager.domain.schema.DeployAppSchema;
@ -165,7 +162,7 @@ public class DeployConfigServiceImpl implements DeployConfigService {
* @return 更新后的对象
*/
@Override
public DeployConfigDO update(DeployConfigUpdateReq req) {
public DeployConfigDO update(DeployConfigUpsertReq req) {
String apiVersion = req.getApiVersion();
String appId = req.getAppId();
String isolateNamespaceId = req.getIsolateNamespaceId();
@ -173,6 +170,14 @@ public class DeployConfigServiceImpl implements DeployConfigService {
String envId = req.getEnvId();
String typeId = req.getTypeId();
String config = req.getConfig();
JSONArray configJsonArray = req.getConfigJsonArray();
if (configJsonArray != null) {
config = SchemaUtil.toYamlStr(configJsonArray, JSONArray.class);
}
JSONObject configJsonObject = req.getConfigJsonObject();
if (configJsonObject != null) {
config = SchemaUtil.toYamlStr(configJsonObject, JSONObject.class);
}
boolean inherit = req.isInherit();
String productId = req.getProductId();
String releaseId = req.getReleaseId();
@ -233,6 +238,30 @@ public class DeployConfigServiceImpl implements DeployConfigService {
.build();
}
/**
* 将指定应用加入到指定环境中
*
* @param req 加入环境请求
*/
public void bindEnvironment(DeployConfigBindEnvironmentReq req) {
String appId = req.getAppId();
String isolateNamespaceId = req.getIsolateNamespaceId();
String isolateStageId = req.getIsolateStageId();
String envId = req.getEnvId();
String productId = req.getProductId();
String releaseId = req.getReleaseId();
String baselineBranch = req.getBaselineBranch();
// 写入 Type:envBinding 的类型记录
String apiVersion = DefaultConstant.API_VERSION_V1_ALPHA2;
DeployConfigTypeId typeId = new DeployConfigTypeId(DeployConfigTypeId.TYPE_ENV_BINDING);
applySingleConfig(apiVersion, appId, typeId.toString(), envId, "", true, false,
isolateNamespaceId, isolateStageId, productId, releaseId);
}
public void getGlobalTemplate(String isolateNamespaceId, String isolateStageId) {
}
/**
* 根据 deploy config 配置生成 application configuration
@ -290,7 +319,16 @@ public class DeployConfigServiceImpl implements DeployConfigService {
List<String> typeIds = CollectionUtils.isEmpty(req.getTypeIds())
? distinctTypeIds(appRecords)
: req.getTypeIds();
// step==0 traits 类型组装, step==1 traits 类型组装 (step==1 依赖 step==0 完成)
for (int step = 0; step < 2; step++) {
for (String typeId : typeIds) {
DeployConfigTypeId typeIdObj = DeployConfigTypeId.valueOf(typeId);
if (step == 0 && DeployConfigTypeId.TYPE_TRAITS.equals(typeIdObj.getType())) {
continue;
} else if (step == 1 && !DeployConfigTypeId.TYPE_TRAITS.equals(typeIdObj.getType())) {
continue;
}
List<DeployConfigDO> filterAppRecords = appRecords.stream()
.filter(item -> item.getTypeId().equals(typeId))
.collect(Collectors.toList());
@ -318,7 +356,7 @@ public class DeployConfigServiceImpl implements DeployConfigService {
JSONArray.toJSONString(filterRootRecords)));
}
}
switch (DeployConfigTypeId.valueOf(typeId).getType()) {
switch (typeIdObj.getType()) {
case DeployConfigTypeId.TYPE_PARAMETER_VALUES:
schema.getSpec().setParameterValues(
SchemaUtil.toSchemaList(DeployAppSchema.ParameterValue.class, config));
@ -328,6 +366,46 @@ public class DeployConfigServiceImpl implements DeployConfigService {
req, SchemaUtil.toSchema(DeployAppSchema.SpecComponent.class, config));
schema.getSpec().getComponents().add(component);
break;
case DeployConfigTypeId.TYPE_TRAITS:
String componentType = typeIdObj.getAttr(DeployConfigTypeId.ATTR_COMPONENT_TYPE);
String componentName = typeIdObj.getAttr(DeployConfigTypeId.ATTR_COMPONENT_NAME);
String traitName = typeIdObj.getAttr(DeployConfigTypeId.ATTR_TRAIT);
if (StringUtils.isAnyEmpty(componentType, componentName, traitName)) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
String.format("invalid trait typeId found, ComponentType/ComponentName/Trait " +
"are required|typeId=%s", typeId));
}
DeployAppSchema.SpecComponentTrait trait = SchemaUtil
.toSchema(DeployAppSchema.SpecComponentTrait.class, config);
trait.setName(traitName);
if (StringUtils.isEmpty(trait.getRuntime())) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
"the field 'runtime' is required in trait deploy config");
}
boolean componentFound = false;
for (DeployAppSchema.SpecComponent specComponent : schema.getSpec().getComponents()) {
DeployAppRevisionName revisionName = DeployAppRevisionName
.valueOf(specComponent.getRevisionName());
if (componentType.equalsIgnoreCase(revisionName.getComponentType())
&& componentName.equals(revisionName.getComponentName())) {
componentFound = true;
for (DeployAppSchema.SpecComponentTrait specComponentTrait
: specComponent.getTraits()) {
if (traitName.equals(specComponentTrait.getName())) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
String.format("conflict trait deploy config, which already " +
"exists at the component level|typeId=%s", typeId));
}
}
specComponent.getTraits().add(trait);
}
}
if (!componentFound) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
String.format("cannot find related component when processing trait " +
"deploy config|typeId=%s", typeId));
}
break;
case DeployConfigTypeId.TYPE_POLICIES:
schema.getSpec().setPolicies(SchemaUtil.toSchemaList(DeployAppSchema.Policy.class, config));
break;
@ -338,6 +416,7 @@ public class DeployConfigServiceImpl implements DeployConfigService {
break;
}
}
}
return schema;
}
@ -478,6 +557,9 @@ public class DeployConfigServiceImpl implements DeployConfigService {
List<DeployConfigDO> appRecords, List<DeployConfigDO> rootRecords, String unitId, String clusterId,
String namespaceId, String stageId) {
List<String> priorities = new ArrayList<>();
if (StringUtils.isNotEmpty(unitId) && StringUtils.isNotEmpty(namespaceId) && StringUtils.isNotEmpty(stageId)) {
priorities.add(DeployConfigEnvId.unitNamespaceStageStr(unitId, namespaceId, stageId));
}
if (StringUtils.isNotEmpty(stageId)) {
priorities.add(DeployConfigEnvId.stageStr(stageId));
}

View File

@ -0,0 +1,58 @@
package com.alibaba.tesla.appmanager.deployconfig.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.common.util.SchemaUtil;
/**
* 部署配置生成器
*
* @author yaoxing.gyx@alibaba-inc.com
*/
public class DeployConfigGenerator {
private final JSONObject config;
public DeployConfigGenerator() {
this.config = new JSONObject();
}
public DeployConfigGenerator addRevisionName(String componentType, String componentName) {
config.put("revisionName", String.format("%s|%s|_", componentType, componentName));
return this;
}
public DeployConfigGenerator addScope(String kind, String name) {
config.putIfAbsent("scopes", new JSONArray());
config.getJSONArray("scopes").add(new JSONObject());
int scopeLength = config.getJSONArray("scopes").size();
config.getJSONArray("scopes").getJSONObject(scopeLength - 1).put("scopeRef", new JSONObject());
config.getJSONArray("scopes").getJSONObject(scopeLength - 1)
.getJSONObject("scopeRef").put("apiVersion", "core.oam.dev/v1alpha2");
config.getJSONArray("scopes").getJSONObject(scopeLength - 1)
.getJSONObject("scopeRef").put("kind", kind);
config.getJSONArray("scopes").getJSONObject(scopeLength - 1)
.getJSONObject("scopeRef").put("name", name);
return this;
}
public DeployConfigGenerator addDataInputs(JSONArray dataInputs) {
if (dataInputs == null) {
return this;
}
config.put("dataInputs", dataInputs);
return this;
}
public DeployConfigGenerator addDataOutputs(JSONArray dataOutputs) {
if (dataOutputs == null) {
return this;
}
config.put("dataOutputs", dataOutputs);
return this;
}
public String toString() {
return SchemaUtil.createYaml(JSONObject.class).dumpAsMap(config);
}
}

View File

@ -0,0 +1,52 @@
package com.alibaba.tesla.appmanager.deployconfig.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.deployconfig.assembly.DeployConfigDtoConvert;
import com.alibaba.tesla.appmanager.deployconfig.repository.domain.DeployConfigDO;
import com.alibaba.tesla.appmanager.domain.dto.DeployConfigDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@Slf4j
public class TestDeployConfigDtoConverter {
@Test
public void testTo1() {
String yaml = "!!map\n" +
"- name: a\n" +
" value: b\n" +
"- name: c\n" +
" value: d";
DeployConfigDO record = new DeployConfigDO();
record.setConfig(yaml);
DeployConfigDTO dto = (new DeployConfigDtoConvert()).to(record);
assertThat(((JSONArray) dto.getConfigJson()).size()).isEqualTo(2);
}
@Test
public void testTo2() {
String yaml = "- name: c\n" +
" value: d";
DeployConfigDO record = new DeployConfigDO();
record.setConfig(yaml);
DeployConfigDTO dto = (new DeployConfigDtoConvert()).to(record);
assertThat(((JSONArray) dto.getConfigJson()).size()).isEqualTo(1);
}
@Test
public void testTo3() {
String yaml = "name: c\n" +
"value: d";
DeployConfigDO record = new DeployConfigDO();
record.setConfig(yaml);
DeployConfigDTO dto = (new DeployConfigDtoConvert()).to(record);
assertThat(((JSONObject) dto.getConfigJson()).get("name")).isEqualTo("c");
assertThat(((JSONObject) dto.getConfigJson()).get("value")).isEqualTo("d");
}
}

View File

@ -59,7 +59,7 @@ public class TestServiceDeployConfigApplyTemplate {
@Test
public void testWithExistsRecords() throws Exception {
String parameterValueTypeId = new DeployConfigTypeId(DeployConfigTypeId.TYPE_PARAMETER_VALUES).toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE, "aiops-server").toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE.toString(), "aiops-server").toString();
Mockito.doReturn(Collections.singletonList(DeployConfigHistoryDO.builder().revision(10).build()))
.when(deployConfigHistoryRepository)
.selectByExample(DeployConfigHistoryQueryCondition.builder()
@ -174,7 +174,7 @@ public class TestServiceDeployConfigApplyTemplate {
@Test
public void testWithNoRecords() throws Exception {
String parameterValueTypeId = new DeployConfigTypeId(DeployConfigTypeId.TYPE_PARAMETER_VALUES).toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE, "aiops-server").toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE.toString(), "aiops-server").toString();
String config = getConfig();
DeployConfigApplyTemplateRes<DeployConfigDO> res = deployConfigService.applyTemplate(
DeployConfigApplyTemplateReq.builder()

View File

@ -69,7 +69,7 @@ public class TestServiceDeployConfigGenerateByAddonInherit {
public void testGenerateInternalAddonWithInherit() throws Exception {
// 准备数据
String typeId = new DeployConfigTypeId(
ComponentTypeEnum.INTERNAL_ADDON, "productopsv2@productopsv2").toString();
ComponentTypeEnum.INTERNAL_ADDON.toString(), "productopsv2@productopsv2").toString();
Mockito.doReturn(
Collections.singletonList(DeployConfigDO.builder()
.appId(APP_ID)

View File

@ -60,6 +60,62 @@ public class TestServiceDeployConfigGenerateByConfiguration {
));
}
/**
* 测试生成 Trait ApplicationConfiguration
*/
@Test
public void testGenerateTraitNoInherit() throws Exception {
// 准备数据
String traitTypeId = "Type:traits::ComponentType:K8S_MICROSERVICE::ComponentName:aiops-server::Trait:test.abm.io";
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE.toString(), "aiops-server").toString();
String config = getConfig();
DeployAppSchema schema = SchemaUtil.toSchema(DeployAppSchema.class, config);
List<DeployConfigDO> mockResults = new ArrayList<>();
mockResults.add(DeployConfigDO.builder()
.appId(APP_ID)
.typeId(traitTypeId)
.envId("")
.apiVersion(API_VERSION)
.currentRevision(0)
.config(SchemaUtil.toYamlStr(schema.getSpec().getComponents().get(0).getTraits().get(0), DeployAppSchema.SpecComponentTrait.class))
.enabled(true)
.inherit(false)
.build());
// 删除 example 中的 traits
schema.getSpec().getComponents().get(0).setTraits(new ArrayList<>());
mockResults.add(DeployConfigDO.builder()
.appId(APP_ID)
.typeId(componentTypeId)
.envId("")
.apiVersion(API_VERSION)
.currentRevision(0)
.config(SchemaUtil.toYamlMapStr(schema.getSpec().getComponents().get(0)))
.enabled(true)
.inherit(false)
.build());
Mockito.doReturn(mockResults)
.when(deployConfigRepository)
.selectByCondition(DeployConfigQueryCondition.builder()
.apiVersion(API_VERSION)
.appId(APP_ID)
.enabled(true)
.build());
// 测试调用
DeployConfigGenerateReq req = DeployConfigGenerateReq.builder()
.apiVersion(API_VERSION)
.appId(APP_ID)
.appPackageId(APP_PACKAGE_ID)
.clusterId(CLUSTER_ID)
.namespaceId(NAMESPACE_ID)
.stageId(STAGE_ID)
.appInstanceName(APP_INSTANCE_NAME)
.build();
DeployConfigGenerateRes res = deployConfigService.generate(req);
log.info("generateRes: {}", JSONObject.toJSONString(res.getSchema()));
// DeployAppSchema generatedSchema = res.getSchema();
}
/**
* 测试生成 K8S Microservice ApplicationConfiguration
*/
@ -67,7 +123,7 @@ public class TestServiceDeployConfigGenerateByConfiguration {
public void testGenerateK8SMicroserviceNoInherit() throws Exception {
// 准备数据
String parameterValueTypeId = new DeployConfigTypeId(DeployConfigTypeId.TYPE_PARAMETER_VALUES).toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE, "aiops-server").toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE.toString(), "aiops-server").toString();
String config = getConfig();
DeployAppSchema schema = SchemaUtil.toSchema(DeployAppSchema.class, config);
List<DeployConfigDO> mockResults = new ArrayList<>();
@ -136,7 +192,7 @@ public class TestServiceDeployConfigGenerateByConfiguration {
public void testGenerateK8SMicroserviceWithInherit() throws Exception {
// 准备数据
String parameterValueTypeId = new DeployConfigTypeId(DeployConfigTypeId.TYPE_PARAMETER_VALUES).toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE, "aiops-server").toString();
String componentTypeId = new DeployConfigTypeId(ComponentTypeEnum.K8S_MICROSERVICE.toString(), "aiops-server").toString();
String config = getConfig();
DeployAppSchema schema = SchemaUtil.toSchema(DeployAppSchema.class, config);
Mockito.doReturn(

View File

@ -0,0 +1,50 @@
package com.alibaba.tesla.appmanager.deployconfig.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.tesla.appmanager.common.util.SchemaUtil;
import com.alibaba.tesla.appmanager.deployconfig.util.DeployConfigGenerator;
import com.alibaba.tesla.appmanager.domain.schema.DeployAppSchema;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@Slf4j
public class TestUtilDeployConfigGenerator {
/**
* 测试生成一个普通的 SpecComponent 配置
*/
@Test
public void testGenerate() {
DeployConfigGenerator config = new DeployConfigGenerator();
config.addRevisionName("HELM", "test");
config.addScope("Namespace", "testNamespace");
config.addScope("Stage", "testStage");
config.addDataInputs(JSONArray.parseArray(JSONArray.toJSONString(
Collections.singletonList(DeployAppSchema.DataInput.builder()
.valueFrom(DeployAppSchema.DataInputValueFrom.builder()
.dataOutputName("test")
.build())
.toFieldPaths(List.of("to1"))
.build()))));
config.addDataOutputs(JSONArray.parseArray(JSONArray.toJSONString(
Collections.singletonList(DeployAppSchema.DataOutput.builder()
.name("testname")
.fieldPath("testfieldpath")
.build()))));
DeployAppSchema.SpecComponent specComponent = SchemaUtil
.toSchema(DeployAppSchema.SpecComponent.class, config.toString());
assertThat(specComponent.getNamespaceId()).isEqualTo("testNamespace");
assertThat(specComponent.getStageId()).isEqualTo("testStage");
assertThat(specComponent.getRevisionName()).isEqualTo("HELM|test|_");
assertThat(specComponent.getDataInputs().get(0).getValueFrom().getDataOutputName()).isEqualTo("test");
assertThat(specComponent.getDataOutputs().get(0).getFieldPath()).isEqualTo("testfieldpath");
}
}

View File

@ -7,7 +7,7 @@
<parent>
<groupId>com.alibaba.tesla</groupId>
<artifactId>tesla-appmanager</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -8,7 +8,7 @@ public interface AppConfigComponentFluent<A extends AppConfigComponentFluent<A>>
String getRevisionName();
ComponentTypeEnum getComponentType();
String getComponentType();
String getComponentName();
@ -16,7 +16,7 @@ public interface AppConfigComponentFluent<A extends AppConfigComponentFluent<A>>
A withRevisionName(String revisionName);
A withRevisionName(ComponentTypeEnum componentType, String componentName, String packageVersion);
A withRevisionName(String componentType, String componentName, String packageVersion);
List<AppConfigParameterValue> getParameterValues();

View File

@ -20,7 +20,7 @@ public class AppConfigComponentFluentImpl<A extends AppConfigComponentFluent<A>>
}
@Override
public ComponentTypeEnum getComponentType() {
public String getComponentType() {
return DeployAppRevisionName.valueOf(this.revisionName).getComponentType();
}
@ -41,8 +41,8 @@ public class AppConfigComponentFluentImpl<A extends AppConfigComponentFluent<A>>
}
@Override
public A withRevisionName(ComponentTypeEnum componentType, String componentName, String packageVersion) {
this.revisionName = String.format("%s|%s|%s", componentType.toString(), componentName, packageVersion);
public A withRevisionName(String componentType, String componentName, String packageVersion) {
this.revisionName = String.format("%s|%s|%s", componentType, componentName, packageVersion);
return (A) this;
}

View File

@ -28,6 +28,8 @@ public class ComponentPackageTaskMessage {
private String stageId;
private String category;
private String operator;
private ComponentBinder component;

View File

@ -10,6 +10,7 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
@ -37,7 +38,7 @@ public class DeployAppRevisionName {
/**
* 组件类型
*/
private ComponentTypeEnum componentType;
private String componentType;
/**
* 组件名称
@ -60,8 +61,8 @@ public class DeployAppRevisionName {
private DeployAppRevisionName(String revisionName, boolean mirrorFlag) {
String[] splitNames = revisionName.split(SPLITTER, SPLIT_LIMIT);
assert splitNames.length == SPLIT_LIMIT;
this.componentType = Enums.getIfPresent(ComponentTypeEnum.class, splitNames[0]).orNull();
if (this.componentType == null) {
this.componentType = splitNames[0];
if (StringUtils.isEmpty(this.componentType)) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS,
String.format("cannot parse revisionName %s", revisionName));
}
@ -109,9 +110,9 @@ public class DeployAppRevisionName {
* @return addonId
*/
public String addonId() {
assert componentType.equals(ComponentTypeEnum.RESOURCE_ADDON)
|| componentType.equals(ComponentTypeEnum.TRAIT_ADDON)
|| componentType.equals(ComponentTypeEnum.CUSTOM_ADDON);
assert componentType.equals(ComponentTypeEnum.RESOURCE_ADDON.toString())
|| componentType.equals(ComponentTypeEnum.TRAIT_ADDON.toString())
|| componentType.equals(ComponentTypeEnum.CUSTOM_ADDON.toString());
String[] array = componentName.split("@", 2);
assert array.length == 2;
return array[0];
@ -123,9 +124,9 @@ public class DeployAppRevisionName {
* @return addonName
*/
public String addonName() {
assert componentType.equals(ComponentTypeEnum.RESOURCE_ADDON)
|| componentType.equals(ComponentTypeEnum.TRAIT_ADDON)
|| componentType.equals(ComponentTypeEnum.CUSTOM_ADDON);
assert componentType.equals(ComponentTypeEnum.RESOURCE_ADDON.toString())
|| componentType.equals(ComponentTypeEnum.TRAIT_ADDON.toString())
|| componentType.equals(ComponentTypeEnum.CUSTOM_ADDON.toString());
String[] array = componentName.split("@", 2);
assert array.length == 2;
return array[1];

View File

@ -55,6 +55,18 @@ public class DeployConfigEnvId {
return "Unit";
}
/**
* 返回 Unit + Namespace + Stage 字符串标识
*
* @param unitId Unit ID
* @param namespaceId Namespace ID
* @param stageId Stage ID
* @return 字符串标识
*/
public static String unitNamespaceStageStr(String unitId, String namespaceId, String stageId) {
return String.format("Unit:%s::Namespace:%s::Stage:%s", unitId, namespaceId, stageId);
}
/**
* 返回 Stage 字符串标识
*

View File

@ -4,6 +4,7 @@ import com.alibaba.tesla.appmanager.common.enums.ComponentTypeEnum;
import com.alibaba.tesla.appmanager.common.exception.AppErrorCode;
import com.alibaba.tesla.appmanager.common.exception.AppException;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
@ -16,13 +17,17 @@ import java.util.List;
*/
public class DeployConfigTypeId {
public static final String TYPE_ENV_BINDING = "envBinding";
public static final String TYPE_PARAMETER_VALUES = "parameterValues";
public static final String TYPE_COMPONENTS = "components";
public static final String TYPE_POLICIES = "policies";
public static final String TYPE_WORKFLOW = "workflow";
// 注意TYPE_COMPONENT_TRAITS 仅附属于 components无法独立存在
public static final String TYPE_TRAITS = "traits";
public static final String ATTR_COMPONENT_TYPE = "ComponentType";
public static final String ATTR_COMPONENT_NAME = "ComponentName";
public static final String ATTR_TRAIT = "Trait";
@Getter
private final String type;
@ -34,18 +39,14 @@ public class DeployConfigTypeId {
this.attrs = new ArrayList<>();
}
public DeployConfigTypeId(ComponentTypeEnum componentType) {
public DeployConfigTypeId(String componentType, String componentName) {
this.type = TYPE_COMPONENTS;
this.attrs = new ArrayList<>();
this.attrs.add(Pair.of(ATTR_COMPONENT_TYPE, componentType.toString()));
}
public DeployConfigTypeId(ComponentTypeEnum componentType, String componentName) {
this.type = TYPE_COMPONENTS;
this.attrs = new ArrayList<>();
this.attrs.add(Pair.of(ATTR_COMPONENT_TYPE, componentType.toString()));
this.attrs.add(Pair.of(ATTR_COMPONENT_TYPE, componentType));
if (StringUtils.isNotEmpty(componentName)) {
this.attrs.add(Pair.of(ATTR_COMPONENT_NAME, componentName));
}
}
/**
* 获取 DeployConfigType 中的指定 key 对应的属性值
@ -63,6 +64,9 @@ public class DeployConfigTypeId {
}
public static DeployConfigTypeId valueOf(String typeId) {
if (StringUtils.isEmpty(typeId)) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS, "empty typeId parameter");
}
String[] arr = typeId.split("::");
if (arr.length == 0) {
throw new AppException(AppErrorCode.INVALID_USER_ARGS, "typeId must have :: spliter");

View File

@ -0,0 +1,33 @@
package com.alibaba.tesla.appmanager.domain.core;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Groovy 脚本标识
*
* @author yaoxing.gyx@alibaba-inc.com
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ScriptIdentifier {
/**
* 类型
*/
private String kind;
/**
* 名称
*/
private String name;
/**
* 版本
*/
private Integer revision;
}

View File

@ -52,7 +52,7 @@ public class AppAddonDTO {
/**
* Addon 类型
*/
private ComponentTypeEnum addonType;
private String addonType;
/**
* Addon 唯一标识

View File

@ -1,29 +1,38 @@
package com.alibaba.tesla.appmanager.domain.dto;
import com.alibaba.tesla.appmanager.common.enums.ComponentTypeEnum;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 应用关联组件 DTO
*
* @author qianmo.zm@alibaba-inc.com
*/
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AppComponentDTO {
/**
* ID
*/
private Long id;
/**
* 应用 ID
* 是否为兼容记录 (true: 历史上的兼容记录, false: 通用记录)
*/
private String appId;
private boolean compatible;
/**
* 创建时间
*/
private Date gmtCreate;
/**
* 最后修改时间
*/
private Date gmtModified;
/**
* Namespace ID
@ -36,22 +45,37 @@ public class AppComponentDTO {
private String stageId;
/**
* 组件描述
* 应用 ID
*/
private String componentLabel;
private String appId;
/**
* 分类
*/
private String category;
/**
* 组件类型
*/
private ComponentTypeEnum componentType;
private String componentType;
/**
* 组件唯一标示
* 组件名称
*/
private String componentName;
/**
* 组件版本
* 组件对应的当前应用插件版本
*/
private String componentVersion;
private String pluginVersion;
/**
* 配置内容
*/
private JSONObject config;
/**
* 自动生成: 当前组件对应的类型 ID
*/
private String typeId;
}

View File

@ -1,6 +1,9 @@
package com.alibaba.tesla.appmanager.domain.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Definition Schema DTO
@ -8,6 +11,9 @@ import lombok.Data;
* @author yaoxing.gyx@alibaba-inc.com
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DefinitionSchemaDTO {
/**

View File

@ -1,5 +1,7 @@
package com.alibaba.tesla.appmanager.domain.dto;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -89,4 +91,9 @@ public class DeployConfigDTO {
* 发布版本 ID
*/
private String releaseId;
/**
* 自动生成: 配置内容的 JSON 形式
*/
private JSON configJson;
}

View File

@ -53,7 +53,7 @@ public class HelmMetaDTO {
/**
* 组件类型
*/
private ComponentTypeEnum componentType;
private String componentType;
/**
* 包类型

View File

@ -30,6 +30,11 @@ public class InitContainerDTO {
*/
private String dockerfilePath;
/**
* 仓库地址不填则默认继承container的repoPath
*/
private String repoPath;
public String createDockerFileTemplate() {
return "Dockerfile-" + createContainerName() + ".tpl";
}

View File

@ -66,7 +66,7 @@ public class K8sMicroServiceMetaDTO {
/**
* 组件类型
*/
private ComponentTypeEnum componentType;
private String componentType;
/**
* 架构

View File

@ -21,7 +21,10 @@ public class ParamBinderDTO {
*/
private String componentName;
private ComponentTypeEnum componentType;
/**
* 组件类型
*/
private String componentType;
/**
* 插件输出参数名

View File

@ -0,0 +1,56 @@
package com.alibaba.tesla.appmanager.domain.dto;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* Plugin Frontend 资源 DTO
*
* @author yaoxing.gyx@alibaba-inc.com
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PluginFrontendDTO {
/**
* ID
*/
private Long id;
/**
* 创建时间
*/
private Date gmtCreate;
/**
* 修改时间
*/
private Date gmtModified;
/**
* Plugin 唯一标识
*/
private String pluginName;
/**
* Plugin 版本 (SemVer)
*/
private String pluginVersion;
/**
* 名称
*/
private String name;
/**
* 页面配置
*/
private JSONObject config;
}

View File

@ -38,6 +38,11 @@ public class WorkflowInstanceDTO {
*/
private String appId;
/**
* 分类
*/
private String category;
/**
* 开始时间
*/
@ -78,6 +83,11 @@ public class WorkflowInstanceDTO {
*/
private String workflowCreator;
/**
* Workflow Context
*/
private JSONObject workflowContext;
/**
* 乐观锁版本
*/

View File

@ -1,5 +1,6 @@
package com.alibaba.tesla.appmanager.domain.option;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.tesla.appmanager.common.exception.AppErrorCode;
import com.alibaba.tesla.appmanager.common.exception.AppException;
import com.alibaba.tesla.appmanager.domain.schema.DeployAppSchema;
@ -17,6 +18,11 @@ import java.util.List;
@AllArgsConstructor
public class WorkflowInstanceOption {
/**
* Workflow 分类
*/
private String category;
/**
* Workflow Task 执行顺序 (不提供该参数则默认全量按需执行)
* <p>
@ -31,6 +37,11 @@ public class WorkflowInstanceOption {
*/
private String creator;
/**
* 初始化上下文
*/
private JSONObject initContext;
/**
* 计算并获取当前实际的 workflow instance 中的 workflow tasks 的执行顺序
*

View File

@ -1,27 +0,0 @@
package com.alibaba.tesla.appmanager.domain.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author qiuqiang.qq@alibaba-inc.com
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AddonInstanceQueryReq implements Serializable {
private static final long serialVersionUID = 2701332248815871881L;
private String namespaceId;
private String addonId;
private String addonVersion;
private String addonInstanceId;
}

View File

@ -37,5 +37,5 @@ public class AppAddonQueryReq extends BaseRequest {
/**
* 类型
*/
private List<ComponentTypeEnum> addonTypeList;
private List<String> addonTypeList;
}

Some files were not shown because too many files have changed in this diff Show More