summaryrefslogtreecommitdiffstats
path: root/lib/puppet/file_serving/mount/modules.rb
blob: bf0bad02b544794aa7f7446e5a58f5fc77210c73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
require 'puppet/file_serving/mount'

# This is the modules-specific mount: it knows how to search through
# modules for files.  Yay.
class Puppet::FileServing::Mount::Modules < Puppet::FileServing::Mount
    # Return an instance of the appropriate class.
    def find(path, options = {})
        module_name, relative_path = path.split("/", 2)
        return nil unless mod = environment(options[:node]).module(module_name)

        mod.file(relative_path)
    end

    def search(path, options = {})
        module_name, relative_path = path.split("/", 2)
        return nil unless mod = environment(options[:node]).module(module_name)

        return nil unless path = mod.file(relative_path)
        return [path]
    end

    def valid?
        true
    end
end