Sha256: 4125f15133b519f364fd03d85af2e8fb4b0be580125ea77ca8a0391f0c2b32c6

Contents?: true

Size: 1.33 KB

Versions: 23

Compression:

Stored size: 1.33 KB

Contents

require File.expand_path('lib/foreman/dynflow/configuration', Rails.root)
require 'foreman_tasks/dynflow/persistence'

module ForemanTasks
  # Import all Dynflow configuration from Foreman, and add our own for Tasks
  class Dynflow::Configuration < ::Foreman::Dynflow::Configuration
    def world_config
      super.tap do |config|
        config.backup_deleted_plans = backup_settings[:backup_deleted_plans]
        config.backup_dir           = backup_settings[:backup_dir]
      end
    end

    def backup_settings
      return @backup_settings if @backup_settings
      backup_options = {
        :backup_deleted_plans => true,
        :backup_dir => default_backup_dir,
      }
      settings = SETTINGS[:'foreman-tasks'] && SETTINGS[:'foreman-tasks'][:backup]
      backup_options.merge!(settings) if settings
      @backup_settings = with_environment_override backup_options
    end

    def default_backup_dir
      File.join(Rails.root, 'tmp', 'task-backup')
    end

    def with_environment_override(options)
      env_var = ENV['TASK_BACKUP']
      unless env_var.nil?
        # Everything except 0, n, no, false is considered to be a truthy value
        options[:backup_deleted_plans] = !%w[0 n no false].include?(env_var.downcase)
      end
      options
    end

    def persistence_class
      ForemanTasks::Dynflow::Persistence
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
foreman-tasks-4.1.6 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.2.3 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.2.2 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.2.1 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.2.0 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.1.1 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.1.0 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.5 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.4 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.3 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-3.0.6 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-5.0.0 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.2 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.1 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.0.1 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.1.0 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-3.0.5 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-4.0.0 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-3.0.4 lib/foreman_tasks/dynflow/configuration.rb
foreman-tasks-3.0.3 lib/foreman_tasks/dynflow/configuration.rb