Sha256: 4037e916a12d6d07f6528f3bf2940f212ee1390fede98397c55f121d9d9d47e1

Contents?: true

Size: 672 Bytes

Versions: 4

Compression:

Stored size: 672 Bytes

Contents

class UpdatePuppetPortParamType < ActiveRecord::Migration[6.0]
  def up
    update_port_type :to_i
  end

  def down
    update_port_type :to_s
  end

  private

  def update_port_type(method)
    puppet_class = Puppetclass.find_by :name => 'foreman_scap_client'
    return unless puppet_class
    port_key = puppet_class.class_params.find_by :key => 'port'
    return unless port_key
    def_value = port_key.default_value

    if method == :to_i
      port_key.key_type =  "integer"
      port_key.default_value = def_value.to_i
    else
      port_key.key_type == "string"
      port_key.default_value = port_key.default_value.to_s
    end
    port_key.save!
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_openscap-4.2.0 db/migrate/20201202110213_update_puppet_port_param_type.rb
foreman_openscap-4.0.5 db/migrate/20201202110213_update_puppet_port_param_type.rb
foreman_openscap-4.1.2 db/migrate/20201202110213_update_puppet_port_param_type.rb
foreman_openscap-4.1.1 db/migrate/20201202110213_update_puppet_port_param_type.rb