Add option to sync single execution environment
This commit is contained in:
@@ -4,7 +4,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
before_action :set_docker_images, only: %i[create edit new update]
|
||||
before_action :set_execution_environment, only: MEMBER_ACTIONS + %i[execute_command shell statistics]
|
||||
before_action :set_execution_environment, only: MEMBER_ACTIONS + %i[execute_command shell statistics sync_to_runner_management]
|
||||
before_action :set_testing_framework_adapters, only: %i[create edit new update]
|
||||
|
||||
def authorize!
|
||||
@@ -166,6 +166,20 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
update_and_respond(object: @execution_environment, params: execution_environment_params)
|
||||
end
|
||||
|
||||
def sync_to_runner_management
|
||||
return unless Runner.management_active?
|
||||
|
||||
begin
|
||||
Runner.strategy_class.sync_environment(@execution_environment)
|
||||
rescue Runner::Error => e
|
||||
Rails.logger.debug { "Runner error while synchronizing execution environment with id #{@execution_environment.id}: #{e.message}" }
|
||||
Sentry.capture_exception(e)
|
||||
redirect_to @execution_environment, alert: t('execution_environments.index.synchronize.failure', error: e.message)
|
||||
else
|
||||
redirect_to @execution_environment, notice: t('execution_environments.index.synchronize.success')
|
||||
end
|
||||
end
|
||||
|
||||
def sync_all_to_runner_management
|
||||
authorize ExecutionEnvironment
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ExecutionEnvironmentPolicy < AdminOnlyPolicy
|
||||
%i[execute_command? shell? statistics? show?].each do |action|
|
||||
%i[execute_command? shell? statistics? show? sync_to_runner_management?].each do |action|
|
||||
define_method(action) { admin? || author? }
|
||||
end
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
h1
|
||||
= @execution_environment
|
||||
h1.d-inline-block = @execution_environment
|
||||
.btn-group.float-right
|
||||
= render('shared/edit_button', object: @execution_environment)
|
||||
button.btn.btn-secondary.float-right.dropdown-toggle data-toggle='dropdown' type='button'
|
||||
ul.dropdown-menu.dropdown-menu-right role='menu'
|
||||
li = link_to(t('execution_environments.index.synchronize.button'), sync_to_runner_management_execution_environment_path(@execution_environment), method: :post, class: 'dropdown-item text-dark') if policy(@execution_environment).sync_to_runner_management?
|
||||
li = link_to(t('execution_environments.index.shell'), shell_execution_environment_path(@execution_environment), class: 'dropdown-item text-dark') if policy(@execution_environment).shell?
|
||||
li = link_to(t('shared.statistics'), statistics_execution_environment_path(@execution_environment), 'data-turbolinks' => "false", class: 'dropdown-item text-dark') if policy(@execution_environment).statistics?
|
||||
li = link_to(t('shared.destroy'), @execution_environment, data: {confirm: t('shared.confirm_destroy')}, method: :delete, class: 'dropdown-item text-dark') if policy(@execution_environment).destroy?
|
||||
|
||||
= row(label: 'execution_environment.name', value: @execution_environment.name)
|
||||
= row(label: 'execution_environment.user', value: link_to_if(policy(@execution_environment.author).show?, @execution_environment.author, @execution_environment.author))
|
||||
|
Reference in New Issue
Block a user