Skip to content

Latest commit

 

History

History
107 lines (92 loc) · 3.5 KB

4.md

File metadata and controls

107 lines (92 loc) · 3.5 KB

环境管理

一般公司都会有线上环境、测试环境(测试环境可能有多套: qa/release等).
同一服务不同环境,使用不同的资源实例,比如机器、数据库、域名等.
因此我们需要先管理环境,之后再把环境与不同服务关联起来.
在这基础之上才能管理服务不同环境的资源.

tag: 0.5.4

后端

涉及文件及目录

business/service/models.py
business/service/controllers/environment.py
business/service/apis/environment.py
business/service/urls/environment.py
business/service/urls/__init__.py
business/service/controllers/service.py
business/service/apis/service.py
business/service/urls/service.py
account/controllers/user.py
data/sql/rurality.sql

代码

business/service/models.py:
定义EnvironmentModel,以后会默认有一条线上环境记录,并且不允许删除.
环境的sign正常情况下不允许编辑,只有明确知道在干什么的情况下才行.


business/service/controllers/environment.py
business/service/apis/environment.py
business/service/urls/environment.py
business/service/urls/__init__.py

环境的增删改接口.


business/service/controllers/service.py
business/service/apis/service.py
business/service/urls/service.py

首先我迁移了一下文件位置,把apis、controllers、urls都弄成了目录.
然后里面都添加了服务关联环境的方法和接口.
在删除服务关联环境时,以后会增加不允许删除的判断,但具体不允许删除的限制条件以后再说.
有时候想想,所有服务肯定都有生产环境,那么是不是默认所有服务都有生产环境了呢?
但是我并没有那么做,我是基于所有服务都是新服务,然后从测试环境开始接入的,所以上来并没有生产环境.
(旧的服务接入,就自己创建关联就完事了).


account/controllers/user.py:
给admin用户赋予环境管理的菜单权限.


data/sql/rurality.sql:
最新的sql文件.

前端

涉及文件及目录

src/api/business/environment/url.js
src/api/business/environment/index.js
src/views/business/environment/index.vue
src/views/business/environment/components/ObjDialog/index.vue
src/router/modules/system.js
src/components/Field/EnvironmentField/index.vue
src/api/business/service/url.js
src/api/business/service/index.js
src/views/business/service/components/EnvironmentList/index.vue
src/views/business/service/components/EnvironmentList/components/ObjDialog/index.vue
src/views/business/service/detail.vue

代码

src/api/business/environment/url.js
src/api/business/environment/index.js
src/views/business/environment/index.vue
src/views/business/environment/components/ObjDialog/index.vue
src/router/modules/system.js

环境管理功能界面,一样最后放到了系统设置中.


src/components/Field/EnvironmentField/index.vue:
封装环境选择功能,以后有选择环境的地方,可以直接引入此组件.


src/api/business/service/url.js
src/api/business/service/index.js
src/views/business/service/components/EnvironmentList/index.vue
src/views/business/service/components/EnvironmentList/components/ObjDialog/index.vue
src/views/business/service/detail.vue

在服务详情中增加关联环境的功能,直接复制服务与部门关联的代码替换而成.

备注

现在所有服务详情页的样式只是临时的,以后会有变化.