Sha256: 982415a583395b30d85be03b15db27e006d8c59d3d4ba24ae3d10a136cf19fba
Contents?: true
Size: 924 Bytes
Versions: 9
Compression:
Stored size: 924 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) JsonDataProvider.new(name, paths) 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
9 entries across 9 versions & 1 rubygems