Sha256: 38c3f2bd539c305a7c1dcbd23808bc68bf94fe06028ddc4db71921e468d1344a

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 KB

Contents

module Shipit
  class TasksController < ShipitController
    include Pagination

    before_action :stack

    self.default_page_size = 20

    def index
      paginator = paginate(stack.tasks)
      @tasks = paginator.to_a
      @links = paginator.links
    end

    def new
      @definition = stack.find_task_definition(params[:definition_id])
      @task = stack.tasks.build(definition: @definition)
    end

    def show
      task
      respond_to do |format|
        format.html
        format.text { render plain: @task.chunk_output }
      end
    end

    def create
      @definition = stack.find_task_definition(params[:definition_id])

      begin
        @task = stack.trigger_task(
          params[:definition_id],
          current_user,
          env: task_params[:env],
          force: params[:force].present?,
        )
        redirect_to [stack, @task]
      rescue Task::ConcurrentTaskRunning
        redirect_to new_stack_tasks_path(stack, @definition)
      end
    end

    def abort
      task.abort!(rollback_once_aborted: params[:rollback].present?, aborted_by: current_user)
      head :ok
    end

    def tail
      render json: TailTaskSerializer.new(task, context: params)
    end

    private

    def task
      @task ||= stack.tasks.find(params[:id])
    end

    def stack
      @stack ||= Stack.from_param!(params[:stack_id])
    end

    def task_params
      return {} unless params[:task]
      @definition = stack.find_task_definition(params[:definition_id])
      @task_params ||= params.require(:task).permit(env: @definition.variables.map(&:name))
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.27.1 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.27.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.26.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.25.1 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.25.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.24.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.23.1 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.23.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.22.0 app/controllers/shipit/tasks_controller.rb
shipit-engine-0.21.0 app/controllers/shipit/tasks_controller.rb