Sha256: 8cf036333b0324218900168a127b0f855cc9f7e893eb56607f0324ca68d9c8f4
Contents?: true
Size: 968 Bytes
Versions: 8
Compression:
Stored size: 968 Bytes
Contents
# This file is loaded by the autoloader, and it does not find the data function support unless required relative # require 'json' require_relative 'hiera_interpolate' module Puppet::DataProviders class JsonDataProviderFactory < Puppet::Plugins::DataProviders::FileBasedDataProviderFactory def create(name, paths, parent_data_provider) JsonDataProvider.new(name, paths, parent_data_provider) end def path_extension '.json' end end class JsonDataProvider < Puppet::Plugins::DataProviders::PathBasedDataProvider include HieraInterpolate def initialize_data(path, lookup_invocation) JSON.parse(File.read(path)) rescue JSON::ParserError => ex # Filename not included in message, so we add it here. raise Puppet::DataBinding::LookupError, "Unable to parse (#{path}): #{ex.message}" end def post_process(value, lookup_invocation) interpolate(value, lookup_invocation, true) end end end
Version data entries
8 entries across 8 versions & 1 rubygems