Sha256: c5e83a964c3c23f8251853f9216c926a8c63b33f2b807612c2dd0e178f9f0dae

Contents?: true

Size: 1.84 KB

Versions: 45

Compression:

Stored size: 1.84 KB

Contents

#
# Author:: Lamont Granquist (<lamont@opscode.com>)
# Copyright:: Copyright (c) 2013 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/mixin/template'
require 'chef/file_content_management/content_base'

class Chef
  class Provider
    class Template

      class Content < Chef::FileContentManagement::ContentBase

        include Chef::Mixin::Template

        def template_location
          @template_file_cache_location ||= begin
            template_finder.find(@new_resource.source, :local => @new_resource.local, :cookbook => @new_resource.cookbook)
          end
        end

        private

        def file_for_provider
          context = TemplateContext.new(@new_resource.variables)
          context[:node] = @run_context.node
          context[:template_finder] = template_finder
          context._extend_modules(@new_resource.helper_modules)
          output = context.render_template(template_location)

          tempfile = Tempfile.open("chef-rendered-template")
          tempfile.binmode
          tempfile.write(output)
          tempfile.close
          tempfile
        end

        def template_finder
          @template_finder ||= begin
            TemplateFinder.new(run_context, @new_resource.cookbook_name, @run_context.node)
          end
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
chef-12.4.3-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.4.3 lib/chef/provider/template/content.rb
chef-12.4.2-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.4.2 lib/chef/provider/template/content.rb
chef-12.5.0.alpha.1 lib/chef/provider/template/content.rb
chef-12.4.1-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.4.1 lib/chef/provider/template/content.rb
chef-12.4.0 lib/chef/provider/template/content.rb
chef-12.4.0-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.4.0.rc.2 lib/chef/provider/template/content.rb
chef-12.4.0.rc.2-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.4.0.rc.0 lib/chef/provider/template/content.rb
chef-12.4.0.rc.0-universal-mingw32 lib/chef/provider/template/content.rb
chef-12.3.0-x86-mingw32 lib/chef/provider/template/content.rb
chef-12.3.0 lib/chef/provider/template/content.rb
chef-12.3.0.rc.0-x86-mingw32 lib/chef/provider/template/content.rb
chef-12.3.0.rc.0 lib/chef/provider/template/content.rb
chef-12.2.1-x86-mingw32 lib/chef/provider/template/content.rb
chef-12.2.1 lib/chef/provider/template/content.rb
chef-12.2.0.rc.2-x86-mingw32 lib/chef/provider/template/content.rb