Merge branch 'develop' of https://git.trustie.net/jasder/forgeplus into dev_military
This commit is contained in:
commit
6570125a36
127
api_document.md
127
api_document.md
|
@ -1,4 +1,3 @@
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
# API文档
|
# API文档
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
|
|
||||||
|
|
||||||
### API接口
|
### API接口
|
||||||
---
|
|
||||||
|
|
||||||
#### 用户注册(通过其他平台)
|
#### 用户注册(通过其他平台)
|
||||||
```
|
```
|
||||||
|
@ -4864,8 +4862,133 @@ curl --location --request DELETE 'http://localhost:3000/api/ci/templates/10'
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
|
#### 参数列表查询
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /api/ci/secrets/secrets?owner={owner}&repo={repo}
|
||||||
|
```
|
||||||
|
|
||||||
|
*示例*
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request GET 'http://localhost:3000/api/ci/secrets?owner=test&repo=test'
|
||||||
|
```
|
||||||
|
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 必选 | 类型 | 说明 |
|
||||||
|
| ------ | ---- | ------ | ---------- |
|
||||||
|
| owner | 是 | string | 仓库所有人 |
|
||||||
|
| repo | 是 | string | 仓库名 |
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 说明 |
|
||||||
|
| ------ | ------ | ------ |
|
||||||
|
| name | string | 参数名 |
|
||||||
|
| data | string | 参数值 |
|
||||||
|
| repo | string | 仓库 |
|
||||||
|
|
||||||
|
返回值
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "test",
|
||||||
|
"data": "test",
|
||||||
|
"repo": "test"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
|
#### 参数新增/更新
|
||||||
|
|
||||||
|
```
|
||||||
|
POST /api/ci/secrets?owner={owner}&repo={repo}
|
||||||
|
```
|
||||||
|
|
||||||
|
*示例*
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request POST 'http://localhost:3000/api/ci/secrets?owner=test&repo=test' \
|
||||||
|
--data-raw ' {
|
||||||
|
"name": "ip",
|
||||||
|
"data": "1.1.1.1",
|
||||||
|
"id": 21
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 必选 | 类型 | 说明 |
|
||||||
|
| ------ | ---- | ------ | ------------ |
|
||||||
|
| owner | 是 | string | 仓库拥有者 |
|
||||||
|
| repo | 是 | string | 仓库名 |
|
||||||
|
| name | 是 | string | 参数名 |
|
||||||
|
| data | 是 | string | 参数值 |
|
||||||
|
| id | 否 | int | id,更新时传 |
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 说明 |
|
||||||
|
| ------- | ------ | ------------ |
|
||||||
|
| status | int | 状态码 0成功 |
|
||||||
|
| message | string | 消息 |
|
||||||
|
|
||||||
|
返回值
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": 0,
|
||||||
|
"message": "success"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
#### 参数删除
|
||||||
|
|
||||||
|
```
|
||||||
|
DELETE /api/ci/secrets/{id}?name={name}&owner={owner}&repo={repo}
|
||||||
|
```
|
||||||
|
|
||||||
|
*示例*
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --location --request DELETE 'http://localhost:3000/api/ci/secrets/1?name=p1&owner=victor&repo=trustieTest' \
|
||||||
|
```
|
||||||
|
|
||||||
|
*请求参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 必选 | 类型 | 说明 |
|
||||||
|
| ------ | ---- | ------ | ------ |
|
||||||
|
| name | 是 | string | 参数名 |
|
||||||
|
| id | 是 | int | 参数id |
|
||||||
|
|
||||||
|
*返回参数说明:*
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 说明 |
|
||||||
|
| ------- | ------ | ------------ |
|
||||||
|
| status | int | 状态码 0成功 |
|
||||||
|
| message | string | 返回消息 |
|
||||||
|
|
||||||
|
返回值
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"status": 0,
|
||||||
|
"message": "success"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### 解除CI服务器绑定
|
#### 解除CI服务器绑定
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
class Ci::SecretsController < Ci::BaseController
|
||||||
|
|
||||||
|
before_action :load_repo
|
||||||
|
|
||||||
|
# 参数列表
|
||||||
|
def index
|
||||||
|
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], nil).secrets
|
||||||
|
@secrets = result
|
||||||
|
end
|
||||||
|
|
||||||
|
#新增、更新参数
|
||||||
|
def create
|
||||||
|
options = {
|
||||||
|
name: params[:name],
|
||||||
|
data: params[:data]
|
||||||
|
}
|
||||||
|
id = params[:id]
|
||||||
|
if id
|
||||||
|
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).update_secret
|
||||||
|
if result["id"]
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error(result["message"])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret
|
||||||
|
if result["id"]
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error(result["message"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#删除参数
|
||||||
|
def destroy
|
||||||
|
name = params[:name]
|
||||||
|
if !name.blank?
|
||||||
|
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error("参数名不能为空")
|
||||||
|
end
|
||||||
|
rescue Exception => ex
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def ci_drone_url
|
||||||
|
user = User.find_by(login: params[:owner])
|
||||||
|
user&.ci_cloud_account.drone_url
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -85,4 +85,24 @@ class Ci::Drone::API < Ci::Drone::Request
|
||||||
post(endpoint, "/api/users", {login: options[:login], email: options[:email], avatar_url:options[:avatar_url],active:true, drone_token: options[:token]})
|
post(endpoint, "/api/users", {login: options[:login], email: options[:email], avatar_url:options[:avatar_url],active:true, drone_token: options[:token]})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Creates a secret.
|
||||||
|
def create_secret
|
||||||
|
post(endpoint, "/api/repos/#{owner}/#{repo}/secrets", {name: options[:name], data: options[:data], pull_request:true, drone_token: drone_token})
|
||||||
|
end
|
||||||
|
|
||||||
|
# Update a secret.
|
||||||
|
def update_secret
|
||||||
|
patch(endpoint, "/api/repos/#{owner}/#{repo}/secrets/#{options[:name]}", { data: options[:data], pull_request:true, drone_token: drone_token})
|
||||||
|
end
|
||||||
|
|
||||||
|
# list of secrets.
|
||||||
|
def secrets
|
||||||
|
get(endpoint, "/api/repos/#{owner}/#{repo}/secrets", drone_token: drone_token)
|
||||||
|
end
|
||||||
|
|
||||||
|
# delete secret.
|
||||||
|
def delete_secret
|
||||||
|
delete(endpoint, "/api/repos/#{owner}/#{repo}/secrets/#{options[:name]}", drone_token: drone_token)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
# sync_subject :boolean default("0")
|
# sync_subject :boolean default("0")
|
||||||
# sync_shixun :boolean default("0")
|
# sync_shixun :boolean default("0")
|
||||||
#
|
#
|
||||||
# Indexes
|
|
||||||
#
|
|
||||||
# index_laboratories_on_identifier (identifier) UNIQUE
|
|
||||||
# index_laboratories_on_school_id (school_id)
|
|
||||||
#
|
|
||||||
|
|
||||||
class Laboratory < ApplicationRecord
|
class Laboratory < ApplicationRecord
|
||||||
belongs_to :school, optional: true
|
belongs_to :school, optional: true
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
# laboratory_id :integer
|
# laboratory_id :integer
|
||||||
# config :text(65535)
|
# config :text(65535)
|
||||||
#
|
#
|
||||||
# Indexes
|
|
||||||
#
|
|
||||||
# index_laboratory_settings_on_laboratory_id (laboratory_id)
|
|
||||||
#
|
|
||||||
|
|
||||||
class LaboratorySetting < ApplicationRecord
|
class LaboratorySetting < ApplicationRecord
|
||||||
belongs_to :laboratory
|
belongs_to :laboratory
|
||||||
|
|
|
@ -1,72 +1,73 @@
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: projects
|
# Table name: projects
|
||||||
#
|
#
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# name :string(255) default(""), not null
|
# name :string(255) default(""), not null
|
||||||
# description :text(4294967295)
|
# description :text(4294967295)
|
||||||
# homepage :string(255) default("")
|
# homepage :string(255) default("")
|
||||||
# is_public :boolean default("1"), not null
|
# is_public :boolean default("1"), not null
|
||||||
# parent_id :integer
|
# parent_id :integer
|
||||||
# created_on :datetime
|
# created_on :datetime
|
||||||
# updated_on :datetime
|
# updated_on :datetime
|
||||||
# identifier :string(255)
|
# identifier :string(255)
|
||||||
# status :integer default("1"), not null
|
# status :integer default("1"), not null
|
||||||
# lft :integer
|
# lft :integer
|
||||||
# rgt :integer
|
# rgt :integer
|
||||||
# inherit_members :boolean default("0"), not null
|
# inherit_members :boolean default("0"), not null
|
||||||
# project_type :integer default("0")
|
# project_type :integer default("0")
|
||||||
# hidden_repo :boolean default("0"), not null
|
# hidden_repo :boolean default("0"), not null
|
||||||
# attachmenttype :integer default("1")
|
# attachmenttype :integer default("1")
|
||||||
# user_id :integer
|
# user_id :integer
|
||||||
# dts_test :integer default("0")
|
# dts_test :integer default("0")
|
||||||
# enterprise_name :string(255)
|
# enterprise_name :string(255)
|
||||||
# organization_id :integer
|
# organization_id :integer
|
||||||
# project_new_type :integer
|
# project_new_type :integer
|
||||||
# gpid :integer
|
# gpid :integer
|
||||||
# forked_from_project_id :integer
|
# forked_from_project_id :integer
|
||||||
# forked_count :integer default("0")
|
# forked_count :integer default("0")
|
||||||
# publish_resource :integer default("0")
|
# publish_resource :integer default("0")
|
||||||
# visits :integer default("0")
|
# visits :integer default("0")
|
||||||
# hot :integer default("0")
|
# hot :integer default("0")
|
||||||
# invite_code :string(255)
|
# invite_code :string(255)
|
||||||
# qrcode :string(255)
|
# qrcode :string(255)
|
||||||
# qrcode_expiretime :integer default("0")
|
# qrcode_expiretime :integer default("0")
|
||||||
# script :text(65535)
|
# script :text(65535)
|
||||||
# training_status :integer default("0")
|
# training_status :integer default("0")
|
||||||
# rep_identifier :string(255)
|
# rep_identifier :string(255)
|
||||||
# project_category_id :integer
|
# project_category_id :integer
|
||||||
# project_language_id :integer
|
# project_language_id :integer
|
||||||
# license_id :integer
|
# license_id :integer
|
||||||
# ignore_id :integer
|
# ignore_id :integer
|
||||||
# praises_count :integer default("0")
|
# praises_count :integer default("0")
|
||||||
# watchers_count :integer default("0")
|
# watchers_count :integer default("0")
|
||||||
# issues_count :integer default("0")
|
# issues_count :integer default("0")
|
||||||
# pull_requests_count :integer default("0")
|
# pull_requests_count :integer default("0")
|
||||||
# language :string(255)
|
# language :string(255)
|
||||||
# versions_count :integer default("0")
|
# versions_count :integer default("0")
|
||||||
# issue_tags_count :integer default("0")
|
# issue_tags_count :integer default("0")
|
||||||
# closed_issues_count :integer default("0")
|
# closed_issues_count :integer default("0")
|
||||||
# open_devops :boolean default("0")
|
# open_devops :boolean default("0")
|
||||||
# gitea_webhook_id :integer
|
# gitea_webhook_id :integer
|
||||||
# open_devops_count :integer default("0")
|
# open_devops_count :integer default("0")
|
||||||
# recommend :boolean default("0")
|
# recommend :boolean default("0")
|
||||||
# platform :integer default("0")
|
# platform :integer default("0")
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||||
# index_projects_on_identifier (identifier)
|
# index_projects_on_identifier (identifier)
|
||||||
# index_projects_on_is_public (is_public)
|
# index_projects_on_is_public (is_public)
|
||||||
# index_projects_on_lft (lft)
|
# index_projects_on_lft (lft)
|
||||||
# index_projects_on_name (name)
|
# index_projects_on_name (name)
|
||||||
# index_projects_on_platform (platform)
|
# index_projects_on_platform (platform)
|
||||||
# index_projects_on_project_type (project_type)
|
# index_projects_on_project_type (project_type)
|
||||||
# index_projects_on_recommend (recommend)
|
# index_projects_on_recommend (recommend)
|
||||||
# index_projects_on_rgt (rgt)
|
# index_projects_on_rgt (rgt)
|
||||||
# index_projects_on_status (status)
|
# index_projects_on_status (status)
|
||||||
# index_projects_on_updated_on (updated_on)
|
# index_projects_on_updated_on (updated_on)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Project < ApplicationRecord
|
class Project < ApplicationRecord
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
json.id secret['id']
|
||||||
|
json.name secret['name']
|
|
@ -0,0 +1,3 @@
|
||||||
|
json.array! @secrets do |secret|
|
||||||
|
json.partial! "/ci/secrets/index", secret: secret
|
||||||
|
end
|
|
@ -39,6 +39,9 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :secrets do
|
||||||
|
end
|
||||||
|
|
||||||
resources :pipelines do
|
resources :pipelines do
|
||||||
collection do
|
collection do
|
||||||
get :list
|
get :list
|
||||||
|
|
Loading…
Reference in New Issue