FIX CI 修复参数设置的bug

This commit is contained in:
jasder 2021-03-05 15:48:08 +08:00
commit 899e7ccab8
1 changed files with 9 additions and 7 deletions

View File

@ -4,28 +4,26 @@ class Ci::SecretsController < Ci::BaseController
# 参数列表
def index
cloud_account = current_user.ci_cloud_account
result = Ci::Drone::API.new(@ci_user.user_hash, cloud_account.drone_url, params[:owner], params[:repo], nil).secrets
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], nil).secrets
@secrets = result
end
#新增、更新参数
def create
cloud_account = current_user.ci_cloud_account
options = {
name: params[:name],
data: params[:data]
}
id = params[:id]
if id
result = Ci::Drone::API.new(@ci_user.user_hash, cloud_account.drone_url, params[:owner], params[:repo], options).update_secret
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, cloud_account.drone_url, params[:owner], params[:repo], options).create_secret
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
@ -38,8 +36,7 @@ class Ci::SecretsController < Ci::BaseController
def destroy
name = params[:name]
if !name.blank?
cloud_account = current_user.ci_cloud_account
Ci::Drone::API.new(@ci_user.user_hash, cloud_account.drone_url, params[:owner], params[:repo], {name: name}).delete_secret
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
render_ok
else
render_error("参数名不能为空")
@ -48,4 +45,9 @@ class Ci::SecretsController < Ci::BaseController
render_ok
end
def ci_drone_url
user = User.find_by(login: params[:owner])
user&.ci_cloud_account.drone_url
end
end