Sha256: eac967cf7af3c3dad433abb662c977d3fa87fd63cc9e112b8abf782c94039376

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'chef_fs/file_system/base_fs_dir'
require 'chef_fs/file_system/rest_list_dir'
require 'chef_fs/file_system/cookbooks_dir'
require 'chef_fs/file_system/data_bags_dir'
require 'chef_fs/file_system/nodes_dir'

module ChefFS
  module FileSystem
    class ChefServerRootDir < BaseFSDir
      def initialize(root_name, config)
        super("", nil)
        @chef_server_url = config[:chef_server_url]
        @chef_username = config[:node_name]
        @chef_private_key = config[:client_key]
        @environment = config[:environment]
        @root_name = root_name
      end

      attr_reader :chef_server_url
      attr_reader :chef_username
      attr_reader :chef_private_key
      attr_reader :environment

      def rest
        Chef::REST.new(chef_server_url, chef_username, chef_private_key)
      end

      def api_path
        ""
      end

      def path_for_printing
        "#{@root_name}/"
      end

      def can_have_child?(name, is_dir)
        is_dir && children.any? { |child| child.name == name }
      end

      def children
        @children ||= [
          RestListDir.new("clients", self),
          CookbooksDir.new(self),
          DataBagsDir.new(self),
          RestListDir.new("environments", self),
          NodesDir.new(self),
          RestListDir.new("roles", self),
  #        RestListDir.new("sandboxes", self)
        ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-essentials-0.3.1 lib/chef_fs/file_system/chef_server_root_dir.rb