ADD ci datbase config

This commit is contained in:
Jasder 2020-09-18 16:40:54 +08:00
parent 0467119605
commit 467f278de5
4 changed files with 7 additions and 6 deletions

View File

@ -6,15 +6,16 @@ module Ci::DbConnectable
# Dynamically sets the database connection.
def connect_to_ci_database
db_config = Rails.configuration.database_configuration[Rails.env]["ci_server_db"]
return render_error('ci database config missing') if db_config.blank?
config = Rails.application.config_for(:configuration).symbolize_keys!
db_config = config[:gitea].symbolize_keys!
raise 'ci database config missing' if db_config.blank?
req_params = {
host: db_config["host"],
username: db_config['username'],
password: db_config['password'],
port: db_config['port'],
database: "#{current_user.login}_#{db_config['database']}"
database: "#{current_user.login}_drone"
}
db_params = Ci::Database.get_connection_params(req_params)
Ci::Database.set_connection(db_params)

View File

@ -20,7 +20,7 @@ class Ci::Drone::Server
"service docker start; docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-e DRONE_DATABASE_DRIVER=mysql \
-e DRONE_DATABASE_DATASOURCE=#{database_username}:#{database_password}@tcp\\(#{database_host}:#{database_port}\\)/drone_#{user_login}?parseTime=true \
-e DRONE_DATABASE_DATASOURCE=#{database_username}:#{database_password}@tcp\\(#{database_host}:#{database_port}\\)/#{user_login}_drone?parseTime=true \
-e DRONE_GITEA_SERVER=#{gitea_url} \
-e DRONE_GITEA_CLIENT_ID=#{client_id} \
-e DRONE_GITEA_CLIENT_SECRET=#{client_secret} \

View File

@ -17,7 +17,7 @@ module Droneable
end
def ci_certification?
Ci::User.exists?(user_login: self.login)
devops_unverified? && Ci::User.exists?(user_login: self.login)
end
module ClassMethods

View File

@ -13,4 +13,4 @@ json.user_phone_binded @user.phone.present?
json.profile_completed @user.profile_completed?
json.professional_certification @user.professional_certification
json.devops_step @user.devops_step
json.ci_certification @user.ci_certification? if !@user.is_a?(AnonymousUser)
json.ci_certification @user.ci_certification? if !@user.is_a?(AnonymousUser) && @user.devops_unverified?