FIx code review

This commit is contained in:
Jasder 2020-08-26 16:24:51 +08:00
parent 518e966a87
commit 2866c060c7
3 changed files with 10 additions and 4 deletions

View File

@ -3,6 +3,7 @@ class Ci::ProjectsController < Ci::BaseController
include RepositoriesHelper
before_action :load_project
before_action :load_repo, only: [:update_trustie_pipeline]
def authorize
@user = current_user
@ -31,7 +32,7 @@ class Ci::ProjectsController < Ci::BaseController
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, params[:owner], params.merge(identifier: @project.identifier))
if interactor.success?
@file = interactor.result
Ci::Drone::API.new(current_user.cloud_account.drone_token, current_user.cloud_account.drone_url, params[:owner], @project.identifier, config_path: '.trustie-pipeline.yml').config_yml
@repo.config_trustie_pipeline
render_result(1, "更新成功")
else
render_error(interactor.error)

View File

@ -3,5 +3,8 @@ class Ci::RemoteBase < ApplicationRecord
establish_connection Rails.configuration.database_configuration[Rails.env]["ci_server_db"]
def generate_code
[*'a'..'z',*'0'..'9',*'A'..'Z'].sample(32).join
end
end

View File

@ -16,11 +16,13 @@ class Ci::Repo < Ci::RemoteBase
[user, repo]
end
def enable
def config_trustie_pipeline
update_column(:repo_config, '.trustie-pipeline.yml')
end
def activate
# repo_active、repo_signer、repo_secret、repo_updated
update_columns(repo_active: 1, repo_signer: generate_code, repo_secret: generate_code, repo_updated: Time.now.to_i)
end
end