Sha256: 879c26e506d3ab7beafd71ec6a4f6fb18a9ad5998ba051a274a58f5ee2a26845

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module ForemanSalt
  module Concerns
    # Keys to allow as parameters in the SaltVariable controller
    module SaltVariableParameters
      extend ActiveSupport::Concern
      include Foreman::Controller::Parameters::LookupKey

      class_methods do
        def salt_variable_params_filter
          Foreman::ParameterFilter.new(::ForemanSalt::SaltVariable).tap do |filter|
            filter.permit :salt_module_id, salt_modules: [], salt_module_ids: [],
                                           salt_module_names: [], param_classes: [], param_classes_ids: [],
                                           param_classes_names: []
            filter.permit_by_context :required, nested: true
            filter.permit_by_context :id, ui: false, api: false, nested: true
            add_lookup_key_params_filter(filter)
          end
        end
      end

      def salt_variable_params
        param_name = parameter_filter_context.api? ? 'salt_variable' : 'foreman_salt_salt_variable'
        self.class.salt_variable_params_filter.filter_params(params, parameter_filter_context, param_name)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_salt-17.0.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-16.0.3 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-16.0.2 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-16.0.1 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-16.0.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.2.3 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.2.2 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.2.1 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.2.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.1.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-15.0.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb
foreman_salt-14.1.0 app/controllers/foreman_salt/concerns/salt_variable_parameters.rb