Sha256: e3fadbad5b74b3b09bf63b01894070624272ceb4506f564b3b5b9947832ab245

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# -*- encoding: utf-8 -*-
#
# Author:: Matt Wrock (<matt@mattwrock.com>)
#
# Copyright (C) 2015, Matt Wrock
#
# 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/role'

module Kitchen
  module Provisioner
    # fetches roles from kitchen roles directory
    class RunListExpansionFromKitchen < ::Chef::RunList::RunListExpansion
      def initialize(environment, run_list_items, source = nil, role_dir = nil)
        @role_dir = role_dir
        super(environment, run_list_items, source)
      end

      def fetch_role(name, included_by)
        role_file = File.join(@role_dir, "#{name}.json")
        ::Chef::Role.json_create(JSON.parse(File.read(role_file)))
      rescue ::Chef::Exceptions::RoleNotFound
        role_not_found(name, included_by)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kitchen-nodes-0.7.0 lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
kitchen-nodes-0.6.6 lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
kitchen-nodes-0.6.5 lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
kitchen-nodes-0.6.4 lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
kitchen-nodes-0.6.4.dev lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb
kitchen-nodes-0.6.3 lib/kitchen/provisioner/run_list_expansion_from_kitchen.rb