Class: ChefApply::Action::GenerateCookbookFromRecipe

Inherits:
GenerateTempCookbook show all
Defined in:
lib/chef_apply/action/generate_temp_cookbook.rb

Instance Attribute Summary

Attributes inherited from GenerateTempCookbook

#generated_cookbook

Attributes inherited from Base

#config, #target_host

Instance Method Summary collapse

Methods inherited from GenerateTempCookbook

from_options, #initialize, #perform_action

Methods inherited from Base

#initialize, #name, #notify, #perform_action, #run

Constructor Details

This class inherits a constructor from ChefApply::Action::GenerateTempCookbook

Instance Method Details

#generateObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/chef_apply/action/generate_temp_cookbook.rb', line 54

def generate
  recipe_specifier = config.delete :recipe_spec
  repo_paths = config.delete :cookbook_repo_paths
  ChefApply::Log.debug("Beginning to look for recipe specified as #{recipe_specifier}")
  if File.file?(recipe_specifier)
    ChefApply::Log.debug("#{recipe_specifier} is a valid path to a recipe")
    recipe_path = recipe_specifier
  else
    require_relative "generate_temp_cookbook/recipe_lookup"
    rl = RecipeLookup.new(repo_paths)
    cookbook_path_or_name, optional_recipe_name = rl.split(recipe_specifier)
    cookbook = rl.load_cookbook(cookbook_path_or_name)
    recipe_path = rl.find_recipe(cookbook, optional_recipe_name)
  end
  generated_cookbook.from_existing_recipe(recipe_path)
end