Compare commits

...

2 Commits

Author SHA1 Message Date
jasder 0468c8df53 ADD ci ssh server api bug 2021-04-09 10:56:58 +08:00
jasder 6be30ba278 ADD ci ssh server api 2021-04-09 10:54:47 +08:00
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,6 @@
class Ci::PipelinesController < Ci::BaseController
before_action :require_login, only: %i[list create content]
before_action :require_login, only: %i[list create content ssh_server]
skip_before_action :connect_to_ci_db, except: %i[list create destroy content]
before_action :load_project, only: %i[create content]
before_action :load_repo, only: %i[create content]
@ -291,4 +291,8 @@ class Ci::PipelinesController < Ci::BaseController
rescue Exception => ex
render_error(ex.message)
end
def ssh_server
render json: Ci::SSHServer.config
end
end

20
app/libs/ci/ssh_server.rb Normal file
View File

@ -0,0 +1,20 @@
module Ci::SSHServer
class << self
def config
gitea_config = {}
begin
config = Rails.application.config_for(:configuration).symbolize_keys!
ci_ssh_server = config[:ci_ssh_server].symbolize_keys!
raise 'gitea config missing' if ci_ssh_server.blank?
rescue => ex
raise ex if Rails.env.production?
puts %Q{\033[33m [warning] ci_ssh_server config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
ci_ssh_server = {}
end
ci_ssh_server
end
end
end

View File

@ -44,6 +44,7 @@ Rails.application.routes.draw do
resources :pipelines do
collection do
get :list
get :ssh_server
end
member do
get :content