From 33984e16d0ac5590823d3cb0192fa6d5314adc76 Mon Sep 17 00:00:00 2001 From: victor <121183489011@qq.com> Date: Fri, 5 Mar 2021 15:26:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/secrets_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/ci/secrets_controller.rb b/app/controllers/ci/secrets_controller.rb index 4bc4196b9..c7ff99896 100644 --- a/app/controllers/ci/secrets_controller.rb +++ b/app/controllers/ci/secrets_controller.rb @@ -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 + ci_user = Ci::CloudAccount.find_by(account: params[:owner]) + ci_user&.drone_url + end + end \ No newline at end of file From d3df04fb977d6b4f9e5bf8e60f8658548535d6f7 Mon Sep 17 00:00:00 2001 From: victor <121183489011@qq.com> Date: Fri, 5 Mar 2021 15:43:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ci/secrets_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/ci/secrets_controller.rb b/app/controllers/ci/secrets_controller.rb index c7ff99896..698e7bbe0 100644 --- a/app/controllers/ci/secrets_controller.rb +++ b/app/controllers/ci/secrets_controller.rb @@ -46,8 +46,8 @@ class Ci::SecretsController < Ci::BaseController end def ci_drone_url - ci_user = Ci::CloudAccount.find_by(account: params[:owner]) - ci_user&.drone_url + user = User.find_by(login: params[:owner]) + user&.ci_cloud_account.drone_url end end \ No newline at end of file