FIX devops 所有仓库相关的请求参数repo_id 改为project_id
This commit is contained in:
parent
3d99dee31b
commit
3c7b257462
29
README.md
29
README.md
|
@ -2368,7 +2368,7 @@ curl -X POST \
|
||||||
-d "account=xx" \
|
-d "account=xx" \
|
||||||
-d "secret=xxx" \
|
-d "secret=xxx" \
|
||||||
-d "ip_num=xx.xx.xx.xx" \
|
-d "ip_num=xx.xx.xx.xx" \
|
||||||
-d "repo_id=5988" \
|
-d "project_id=5988" \
|
||||||
https://localhost:3000/api/dev_ops/cloud_accounts.json | jq
|
https://localhost:3000/api/dev_ops/cloud_accounts.json | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2379,7 +2379,7 @@ https://localhost:3000/api/dev_ops/cloud_accounts.json | jq
|
||||||
|account |是|string |云服务器ssh连接登录用户名 |
|
|account |是|string |云服务器ssh连接登录用户名 |
|
||||||
|secret |是|string |云服务器ssh连接登录秘密 |
|
|secret |是|string |云服务器ssh连接登录秘密 |
|
||||||
|ip_num |否|string |云服务器公网IP |
|
|ip_num |否|string |云服务器公网IP |
|
||||||
|repo_id |否|string |repository id|
|
|project_id |否|string |project's id|
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
|
||||||
|
@ -2406,14 +2406,14 @@ GET /api/dev_ops/builds/get_trustie_pipeline
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
-d "id=4844" \
|
-d "project_id=4844" \
|
||||||
http://localhost:3000/api/dev_ops/builds/get_trustie_pipeline.json | jq
|
http://localhost:3000/api/dev_ops/builds/get_trustie_pipeline.json | jq
|
||||||
```
|
```
|
||||||
*请求参数说明:*
|
*请求参数说明:*
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |是|int |repository's id |
|
|project_id |是|int |project's id |
|
||||||
|ref |否|string |分支名称、tag名称或是提交记录id,默认为master分支 |
|
|ref |否|string |分支名称、tag名称或是提交记录id,默认为master分支 |
|
||||||
|
|
||||||
|
|
||||||
|
@ -2421,7 +2421,6 @@ http://localhost:3000/api/dev_ops/builds/get_trustie_pipeline.json | jq
|
||||||
|
|
||||||
|参数名|类型|说明|
|
|参数名|类型|说明|
|
||||||
|-|-|-|
|
|-|-|-|
|
||||||
|id |int |id |
|
|
||||||
|name |string|文件夹或文件名称|
|
|name |string|文件夹或文件名称|
|
||||||
|path |string|文件夹或文件相对路径|
|
|path |string|文件夹或文件相对路径|
|
||||||
|content |string|文件内容,|
|
|content |string|文件内容,|
|
||||||
|
@ -2544,7 +2543,7 @@ GET /api/dev_ops/builds
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
-d 'id=4844' \
|
-d 'project_id=4844' \
|
||||||
http://localhost:3000/api/dev_ops/builds | jq
|
http://localhost:3000/api/dev_ops/builds | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2552,7 +2551,7 @@ http://localhost:3000/api/dev_ops/builds | jq
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |是|int |repository's id |
|
|project_id |是|int |project's id |
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
|
||||||
|
@ -2606,7 +2605,7 @@ GET /api/dev_ops/builds/:number
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
-d 'id=4844' \
|
-d 'project_id=4844' \
|
||||||
http://ocalhost:3000/api/dev_ops/builds/1 | jq
|
http://ocalhost:3000/api/dev_ops/builds/1 | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2614,7 +2613,7 @@ http://ocalhost:3000/api/dev_ops/builds/1 | jq
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |int|repository's id|
|
|project_id |int|project's id|
|
||||||
|number |是|int |build's number |
|
|number |是|int |build's number |
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
@ -2714,7 +2713,7 @@ POST /api/dev_ops/builds/:number
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X POST \
|
curl -X POST \
|
||||||
-d 'id=4844' \
|
-d 'project_id=4844' \
|
||||||
http://localhost:3000/api/dev_ops/builds/1 | jq
|
http://localhost:3000/api/dev_ops/builds/1 | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2722,7 +2721,7 @@ http://localhost:3000/api/dev_ops/builds/1 | jq
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |int|repository's id|
|
|project_id |int|project's id|
|
||||||
|number |是|int |build's number |
|
|number |是|int |build's number |
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
@ -2774,7 +2773,7 @@ DELETE /api/dev_ops/builds/:number
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X DELETE \
|
curl -X DELETE \
|
||||||
-d 'id=4844' \
|
-d 'project_id=4844' \
|
||||||
http://localhost:3000/api/dev_ops/builds/2 | jq
|
http://localhost:3000/api/dev_ops/builds/2 | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2782,7 +2781,7 @@ http://localhost:3000/api/dev_ops/builds/2 | jq
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |int|repository's id|
|
|project_id |int|project's id|
|
||||||
|number |是|int |build's number |
|
|number |是|int |build's number |
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
@ -2882,7 +2881,7 @@ GET /api/dev_ops/builds/:number/logs/:stage/:step
|
||||||
*示例*
|
*示例*
|
||||||
```
|
```
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
-d 'id=4844' \
|
-d 'project_id=4844' \
|
||||||
http://localhost:3000/api/dev_ops/builds/2/logs/1/1 | jq
|
http://localhost:3000/api/dev_ops/builds/2/logs/1/1 | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2890,7 +2889,7 @@ http://localhost:3000/api/dev_ops/builds/2/logs/1/1 | jq
|
||||||
|
|
||||||
|参数名|必选|类型|说明|
|
|参数名|必选|类型|说明|
|
||||||
|-|-|-|-|
|
|-|-|-|-|
|
||||||
|id |int|repository's id|
|
|project_id |int|project's id|
|
||||||
|number |是|int |build's number |
|
|number |是|int |build's number |
|
||||||
|stage |是|int |build's stage number |
|
|stage |是|int |build's stage number |
|
||||||
|step |是|int |build's step number |
|
|step |是|int |build's step number |
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
class ::DevOps::BuildsController < ApplicationController
|
class DevOps::BuildsController < ApplicationController
|
||||||
include RepositoriesHelper
|
include RepositoriesHelper
|
||||||
|
|
||||||
before_action :require_login
|
before_action :require_login
|
||||||
before_action :find_repo
|
before_action :find_project
|
||||||
|
|
||||||
def index
|
def index
|
||||||
cloud_account = @repo.dev_ops_cloud_account
|
cloud_account = @project.dev_ops_cloud_account
|
||||||
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @repo.user.login, @repo.identifier).builds
|
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @project.owner.login, @project.identifier).builds
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
def detail
|
def detail
|
||||||
cloud_account = @repo.dev_ops_cloud_account
|
cloud_account = @project.dev_ops_cloud_account
|
||||||
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @repo.user.login, @repo.identifier, number: params[:number]).build
|
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @project.owner.login, @project.identifier, number: params[:number]).build
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
def restart
|
def restart
|
||||||
cloud_account = @repo.dev_ops_cloud_account
|
cloud_account = @project.dev_ops_cloud_account
|
||||||
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @repo.user.login, @repo.identifier, number: params[:number]).restart
|
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @project.owner.login, @project.identifier, number: params[:number]).restart
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
cloud_account = @repo.dev_ops_cloud_account
|
cloud_account = @project.dev_ops_cloud_account
|
||||||
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @repo.user.login, @repo.identifier, number: params[:number]).stop
|
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @project.owner.login, @project.identifier, number: params[:number]).stop
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
|
||||||
def logs
|
def logs
|
||||||
cloud_account = @repo.dev_ops_cloud_account
|
cloud_account = @project.dev_ops_cloud_account
|
||||||
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @repo.user.login, @repo.identifier, build: params[:number], stage: params[:stage], step: params[:step]).logs
|
result = DevOps::Drone::API.new(cloud_account.drone_token, cloud_account.drone_url, @project.owner.login, @project.identifier, build: params[:number], stage: params[:stage], step: params[:step]).logs
|
||||||
|
|
||||||
render json: result
|
render json: result
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ class ::DevOps::BuildsController < ApplicationController
|
||||||
# get .trustie-pipeline.yml file
|
# get .trustie-pipeline.yml file
|
||||||
def get_trustie_pipeline
|
def get_trustie_pipeline
|
||||||
file_path_uri = URI.parse('.trustie-pipeline.yml')
|
file_path_uri = URI.parse('.trustie-pipeline.yml')
|
||||||
interactor = Repositories::EntriesInteractor.call(@repo.user, @repo.identifier, file_path_uri, ref: params[:ref] || "master")
|
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: params[:ref] || "master")
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
file = interactor.result
|
file = interactor.result
|
||||||
return render json: {} if file[:status]
|
return render json: {} if file[:status]
|
||||||
|
@ -52,7 +52,7 @@ class ::DevOps::BuildsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_repo
|
def find_project
|
||||||
@repo = ::Repository.find params[:id]
|
@project = Project.find params[:project_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,13 +14,13 @@ class DevOps::CloudAccountsController < ApplicationController
|
||||||
logger.info "######### create_params: #{create_params}"
|
logger.info "######### create_params: #{create_params}"
|
||||||
|
|
||||||
|
|
||||||
if cloud_account = @repo.dev_ops_cloud_account
|
if cloud_account = @project.dev_ops_cloud_account
|
||||||
return render_error('该仓库已绑定了云帐号.')
|
return render_error('该仓库已绑定了云帐号.')
|
||||||
else
|
else
|
||||||
cloud_account = DevOps::CloudAccount.new(create_params)
|
cloud_account = DevOps::CloudAccount.new(create_params)
|
||||||
cloud_account.user = current_user
|
cloud_account.user = current_user
|
||||||
cloud_account.repo_id = @repo.id
|
cloud_account.repo_id = @project.repository.id
|
||||||
cloud_account.project_id = @repo.project.id
|
cloud_account.project_id = @project.id
|
||||||
cloud_account.save!
|
cloud_account.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class DevOps::CloudAccountsController < ApplicationController
|
||||||
redirect_uri: gitea_oauth['redirect_uris'],
|
redirect_uri: gitea_oauth['redirect_uris'],
|
||||||
gitea_oauth_id: gitea_oauth['id'],
|
gitea_oauth_id: gitea_oauth['id'],
|
||||||
user_id: current_user.id,
|
user_id: current_user.id,
|
||||||
project_id: @repo.project.id)
|
project_id: @project.id)
|
||||||
oauth.save
|
oauth.save
|
||||||
|
|
||||||
rpc_secret = SecureRandom.hex 16
|
rpc_secret = SecureRandom.hex 16
|
||||||
|
@ -64,10 +64,10 @@ class DevOps::CloudAccountsController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
def devops_params
|
def devops_params
|
||||||
params.permit(:account, :secret, :ip_num, :repo_id)
|
params.permit(:account, :secret, :ip_num, :project_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_project
|
def find_project
|
||||||
@repo = Repository.find params[:repo_id]
|
@project = Project.find params[:project_id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
class DevOps::CreateCloudAccountForm
|
class DevOps::CreateCloudAccountForm
|
||||||
include ActiveModel::Model
|
include ActiveModel::Model
|
||||||
|
|
||||||
attr_accessor :repo_id, :ip_num, :account, :secret
|
attr_accessor :project_id, :ip_num, :account, :secret
|
||||||
|
|
||||||
validates :repo_id, :account, :secret, presence: true
|
validates :project_id, :account, :secret, presence: true
|
||||||
validates :ip_num, presence: true, format: { with: CustomRegexp::IP, multiline: true, message: 'IP 地址格式不对' }
|
validates :ip_num, presence: true, format: { with: CustomRegexp::IP, multiline: true, message: 'IP 地址格式不对' }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue