1 个不稳定版本
| 0.2.1 | 2019年3月28日 | 
|---|
#10 in #reservation
68KB
 1.5K  SLoC
Bellhop
Bellhop是一个用于预订不同资产(如机器或IP地址)的Web应用程序
简介
目的
你是10人团队的一员,共享三个测试环境吗?你保留一个使用IP地址的电子表格吗?需要一种方法来跟踪谁在借用哪个虚拟机吗?
如果你对以上任何问题回答是,Bellhop可能能够帮助。Bellhop是一个超级简单的资产预订工具,它可以跟踪谁在使用什么,直到何时。
有关更多信息,包括实时演示,请访问bellhop.rs。
项目结构
- bellhop/- 实现Bellhop大多数功能的核心库。
- bellhop-demo/- 一个可运行的示例,演示添加钩子和启动服务器。
- bellhop-hook-email/- 当你的租约即将到期时发送电子邮件的钩子。
- bellhop-hook-jenkins/- 为每个事件启动Jenkins作业的钩子。
- bellhop-auth-dummy/- 只需要电子邮件地址的认证插件。
- bellhop-auth-header/- 基于头创建用户的认证插件。
设计
Bellhop设计为高度定制和内部安装。可以通过编写钩子(如bellhop-hook-jenkins)添加附加功能。认证也可以自定义,使用可插拔的模块,如bellhop-auth-header。
使用
目前,Bellhop更像是你组装成Web应用程序的一系列crate,而不是一个Web应用程序本身。
一个很好的起点是运行bellhop-demo,然后将其用作构建自己部署的示例。
首次设置
以下说明大致针对Ubuntu,但应该与平台相对类似。Bellhop定期为Ubuntu和OS X编译,并且应在Windows上编译。
安装Rust
项目需要最新的Rust夜间版。您可以使用rustup进行安装
$ curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
安装PostgreSQL
Bellhop使用PostgreSQL作为其数据库。任何大于或等于9.5的版本都应该工作。
Ubuntu/Debian
# Install the server and client libraries.
$ sudo apt install postgresql-9.5 postgresql-client libpq-dev
# Create a user, identified with a password.
$ sudo -u postgres createuser -P bellhop
# Create a new database owned by the same user.
$ sudo -u postgres createdb -O bellhop bellhop
OS X (Homebrew)
在 https://brew.sh.cn/ 安装 Homebrew
# Install the server and client libraries.
brew install postgres
brew services start postgresql
# Create a user, identified with a password.
createuser -P bellhop
# Create a new database owned by the same user.
createdb -O bellhop bellhop
安装 Diesel
要执行数据库迁移,您需要安装 diesel_cli
$ cargo install diesel_cli --no-default-features --features postgres
获取 Bellhop
获取所有组件的最简单方法是克隆 Bellhop 仓库
$ git clone https://github.com/bellhop-rs/bellhop
执行迁移
核心应用程序以及一些钩子都需要执行数据库迁移才能使应用程序正常运行。
# Make sure to update this line with the password supplied earlier.
$ export DATABASE_URL=postgres://bellhop:<password>@localhost/bellhop
# Apply the core application's migrations. Note: `bellhop` refers to this repo's `bellhop` subdirectory.
$ cd bellhop
$ diesel migration run
# Apply any hook's migrations.
$ cd ../bellhop-hook-jenkins
$ diesel migration run
最后运行 Bellhop
以“演示”模式运行 Bellhop
$ cargo run --bin bellhop-demo
请注意,bellhop-demo 登录不需要任何密码。它实际上并不适合未经定制的生产使用。
开发
生成 bellhop-client
bellhop-client 由 openapi-generator 生成。
重新生成 API 客户端库
$ openapi-generator generate \
   -i bellhop/openapi/bellhop.yaml \
   -g rust \
   -o bellhop-client \
   --skip-validate-spec \
   --library reqwest \
   --additional-properties packageName=bellhop-client
许可证
Bellhop 使用以下许可证
- Apache License, Version 2.0, (LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
贡献
除非您明确声明,否则您提交给 Bellhop 的任何有意贡献,如 Apache-2.0 许可证所述,应按上述方式许可,不附加任何额外条款或条件。
依赖关系
~33MB
~761K SLoC