Puppet Function: complyadm::migrate::env_to_hash

Defined in:
lib/puppet/functions/complyadm/migrate/env_to_hash.rb
Function type:
Ruby 4.x API

Overview

complyadm::migrate::env_to_hash(Array[Hash] $env_json)Hash

Parameters:

  • env_json (Array[Hash])

Returns:

  • (Hash)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/puppet/functions/complyadm/migrate/env_to_hash.rb', line 1

Puppet::Functions.create_function(:'complyadm::migrate::env_to_hash') do
  dispatch :env_to_hash do
    param 'Array[Hash]', :env_json
    return_type 'Hash'
  end

  def env_to_hash(env_json)
    env_hash = {}
    env_json.each do |env_var|
      # ignore vars whose values are from secrets
      if env_var['value']
        env_hash[env_var['name']] = env_var['value']
      end
    end
    env_hash
  end
end