summaryrefslogtreecommitdiff
path: root/app/controllers/ci
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/ci')
-rw-r--r--app/controllers/ci/admin/application_controller.rb10
-rw-r--r--app/controllers/ci/admin/application_settings_controller.rb31
-rw-r--r--app/controllers/ci/admin/builds_controller.rb18
-rw-r--r--app/controllers/ci/admin/events_controller.rb9
-rw-r--r--app/controllers/ci/admin/projects_controller.rb19
-rw-r--r--app/controllers/ci/admin/runner_projects_controller.rb34
-rw-r--r--app/controllers/ci/admin/runners_controller.rb73
-rw-r--r--app/controllers/ci/application_controller.rb18
-rw-r--r--app/controllers/ci/lints_controller.rb2
-rw-r--r--app/controllers/ci/projects_controller.rb11
-rw-r--r--app/controllers/ci/runner_projects_controller.rb34
11 files changed, 6 insertions, 253 deletions
diff --git a/app/controllers/ci/admin/application_controller.rb b/app/controllers/ci/admin/application_controller.rb
deleted file mode 100644
index 4ec2dc9c2cf..00000000000
--- a/app/controllers/ci/admin/application_controller.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module Ci
- module Admin
- class ApplicationController < Ci::ApplicationController
- before_action :authenticate_user!
- before_action :authenticate_admin!
-
- layout "ci/admin"
- end
- end
-end
diff --git a/app/controllers/ci/admin/application_settings_controller.rb b/app/controllers/ci/admin/application_settings_controller.rb
deleted file mode 100644
index 71e253fac67..00000000000
--- a/app/controllers/ci/admin/application_settings_controller.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-module Ci
- class Admin::ApplicationSettingsController < Ci::Admin::ApplicationController
- before_action :set_application_setting
-
- def show
- end
-
- def update
- if @application_setting.update_attributes(application_setting_params)
- redirect_to ci_admin_application_settings_path,
- notice: 'Application settings saved successfully'
- else
- render :show
- end
- end
-
- private
-
- def set_application_setting
- @application_setting = Ci::ApplicationSetting.current
- @application_setting ||= Ci::ApplicationSetting.create_from_defaults
- end
-
- def application_setting_params
- params.require(:application_setting).permit(
- :all_broken_builds,
- :add_pusher,
- )
- end
- end
-end
diff --git a/app/controllers/ci/admin/builds_controller.rb b/app/controllers/ci/admin/builds_controller.rb
deleted file mode 100644
index 38abfdeafbf..00000000000
--- a/app/controllers/ci/admin/builds_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-module Ci
- class Admin::BuildsController < Ci::Admin::ApplicationController
- def index
- @scope = params[:scope]
- @builds = Ci::Build.order('created_at DESC').page(params[:page]).per(30)
-
- @builds =
- case @scope
- when "pending"
- @builds.pending
- when "running"
- @builds.running
- else
- @builds
- end
- end
- end
-end
diff --git a/app/controllers/ci/admin/events_controller.rb b/app/controllers/ci/admin/events_controller.rb
deleted file mode 100644
index 5939efff980..00000000000
--- a/app/controllers/ci/admin/events_controller.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module Ci
- class Admin::EventsController < Ci::Admin::ApplicationController
- EVENTS_PER_PAGE = 50
-
- def index
- @events = Ci::Event.admin.order('created_at DESC').page(params[:page]).per(EVENTS_PER_PAGE)
- end
- end
-end
diff --git a/app/controllers/ci/admin/projects_controller.rb b/app/controllers/ci/admin/projects_controller.rb
deleted file mode 100644
index 5bbd0ce7396..00000000000
--- a/app/controllers/ci/admin/projects_controller.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Ci
- class Admin::ProjectsController < Ci::Admin::ApplicationController
- def index
- @projects = Ci::Project.ordered_by_last_commit_date.page(params[:page]).per(30)
- end
-
- def destroy
- project.destroy
-
- redirect_to ci_projects_url
- end
-
- protected
-
- def project
- @project ||= Ci::Project.find(params[:id])
- end
- end
-end
diff --git a/app/controllers/ci/admin/runner_projects_controller.rb b/app/controllers/ci/admin/runner_projects_controller.rb
deleted file mode 100644
index e7de6eb12ca..00000000000
--- a/app/controllers/ci/admin/runner_projects_controller.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Ci
- class Admin::RunnerProjectsController < Ci::Admin::ApplicationController
- layout 'ci/project'
-
- def index
- @runner_projects = project.runner_projects.all
- @runner_project = project.runner_projects.new
- end
-
- def create
- @runner = Ci::Runner.find(params[:runner_project][:runner_id])
-
- if @runner.assign_to(project, current_user)
- redirect_to ci_admin_runner_path(@runner)
- else
- redirect_to ci_admin_runner_path(@runner), alert: 'Failed adding runner to project'
- end
- end
-
- def destroy
- rp = Ci::RunnerProject.find(params[:id])
- runner = rp.runner
- rp.destroy
-
- redirect_to ci_admin_runner_path(runner)
- end
-
- private
-
- def project
- @project ||= Ci::Project.find(params[:project_id])
- end
- end
-end
diff --git a/app/controllers/ci/admin/runners_controller.rb b/app/controllers/ci/admin/runners_controller.rb
deleted file mode 100644
index 0cafad27418..00000000000
--- a/app/controllers/ci/admin/runners_controller.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-module Ci
- class Admin::RunnersController < Ci::Admin::ApplicationController
- before_action :runner, except: :index
-
- def index
- @runners = Ci::Runner.order('id DESC')
- @runners = @runners.search(params[:search]) if params[:search].present?
- @runners = @runners.page(params[:page]).per(30)
- @active_runners_cnt = Ci::Runner.online.count
- end
-
- def show
- @builds = @runner.builds.order('id DESC').first(30)
- @projects = Ci::Project.all
- if params[:search].present?
- @gl_projects = ::Project.search(params[:search])
- @projects = @projects.where(gitlab_id: @gl_projects.select(:id))
- end
- @projects = @projects.where("ci_projects.id NOT IN (?)", @runner.projects.pluck(:id)) if @runner.projects.any?
- @projects = @projects.joins(:gl_project)
- @projects = @projects.page(params[:page]).per(30)
- end
-
- def update
- @runner.update_attributes(runner_params)
-
- respond_to do |format|
- format.js
- format.html { redirect_to ci_admin_runner_path(@runner) }
- end
- end
-
- def destroy
- @runner.destroy
-
- redirect_to ci_admin_runners_path
- end
-
- def resume
- if @runner.update_attributes(active: true)
- redirect_to ci_admin_runners_path, notice: 'Runner was successfully updated.'
- else
- redirect_to ci_admin_runners_path, alert: 'Runner was not updated.'
- end
- end
-
- def pause
- if @runner.update_attributes(active: false)
- redirect_to ci_admin_runners_path, notice: 'Runner was successfully updated.'
- else
- redirect_to ci_admin_runners_path, alert: 'Runner was not updated.'
- end
- end
-
- def assign_all
- Ci::Project.unassigned(@runner).all.each do |project|
- @runner.assign_to(project, current_user)
- end
-
- redirect_to ci_admin_runner_path(@runner), notice: "Runner was assigned to all projects"
- end
-
- private
-
- def runner
- @runner ||= Ci::Runner.find(params[:id])
- end
-
- def runner_params
- params.require(:runner).permit(:token, :description, :tag_list, :active)
- end
- end
-end
diff --git a/app/controllers/ci/application_controller.rb b/app/controllers/ci/application_controller.rb
index 848f2b4e314..c420b59c3a2 100644
--- a/app/controllers/ci/application_controller.rb
+++ b/app/controllers/ci/application_controller.rb
@@ -4,24 +4,16 @@ module Ci
"app/helpers/ci"
end
- helper_method :gl_project
-
private
- def authenticate_token!
- unless project.valid_token?(params[:token])
- return head(403)
- end
- end
-
def authorize_access_project!
- unless can?(current_user, :read_project, gl_project)
+ unless can?(current_user, :read_project, project)
return page_404
end
end
def authorize_manage_builds!
- unless can?(current_user, :manage_builds, gl_project)
+ unless can?(current_user, :manage_builds, project)
return page_404
end
end
@@ -31,7 +23,7 @@ module Ci
end
def authorize_manage_project!
- unless can?(current_user, :admin_project, gl_project)
+ unless can?(current_user, :admin_project, project)
return page_404
end
end
@@ -58,9 +50,5 @@ module Ci
count: count
}
end
-
- def gl_project
- ::Project.find(@project.gitlab_id)
- end
end
end
diff --git a/app/controllers/ci/lints_controller.rb b/app/controllers/ci/lints_controller.rb
index a4f6aff49b4..7ed78ff8e98 100644
--- a/app/controllers/ci/lints_controller.rb
+++ b/app/controllers/ci/lints_controller.rb
@@ -1,5 +1,5 @@
module Ci
- class LintsController < Ci::ApplicationController
+ class LintsController < ApplicationController
before_action :authenticate_user!
def show
diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb
index 8406399fb60..3004c2d27f0 100644
--- a/app/controllers/ci/projects_controller.rb
+++ b/app/controllers/ci/projects_controller.rb
@@ -3,13 +3,12 @@ module Ci
before_action :project, except: [:index]
before_action :authenticate_user!, except: [:index, :build, :badge]
before_action :authorize_access_project!, except: [:index, :badge]
- before_action :authorize_manage_project!, only: [:toggle_shared_runners, :dumped_yaml]
before_action :no_cache, only: [:badge]
protect_from_forgery
def show
# Temporary compatibility with CI badges pointing to CI project page
- redirect_to namespace_project_path(project.gl_project.namespace, project.gl_project)
+ redirect_to namespace_project_path(project.namespace, project)
end
# Project status badge
@@ -20,16 +19,10 @@ module Ci
send_file image.path, filename: image.name, disposition: 'inline', type:"image/svg+xml"
end
- def toggle_shared_runners
- project.toggle!(:shared_runners_enabled)
-
- redirect_to namespace_project_runners_path(project.gl_project.namespace, project.gl_project)
- end
-
protected
def project
- @project ||= Ci::Project.find(params[:id])
+ @project ||= Project.find_by(ci_id: params[:id].to_i)
end
def no_cache
diff --git a/app/controllers/ci/runner_projects_controller.rb b/app/controllers/ci/runner_projects_controller.rb
deleted file mode 100644
index 9d555313369..00000000000
--- a/app/controllers/ci/runner_projects_controller.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-module Ci
- class RunnerProjectsController < Ci::ApplicationController
- before_action :authenticate_user!
- before_action :project
- before_action :authorize_manage_project!
-
- def create
- @runner = Ci::Runner.find(params[:runner_project][:runner_id])
-
- return head(403) unless current_user.ci_authorized_runners.include?(@runner)
-
- path = runners_path(@project.gl_project)
-
- if @runner.assign_to(project, current_user)
- redirect_to path
- else
- redirect_to path, alert: 'Failed adding runner to project'
- end
- end
-
- def destroy
- runner_project = project.runner_projects.find(params[:id])
- runner_project.destroy
-
- redirect_to runners_path(@project.gl_project)
- end
-
- private
-
- def project
- @project ||= Ci::Project.find(params[:project_id])
- end
- end
-end