Class: ChefDK::Command::GeneratorCommands::Repo
- Defined in:
- lib/chef-dk/command/generator_commands/repo.rb
Overview
## Repo chef generate repo path/to/basename –generator-cookbook=path/to/generator –policy-only
Generates a full “chef-repo” directory structure.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#repo_name_or_path ⇒ Object
readonly
Returns the value of attribute repo_name_or_path.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(params) ⇒ Repo
constructor
A new instance of Repo.
- #params_valid? ⇒ Boolean
- #read_and_validate_params ⇒ Object
- #recipe ⇒ Object
- #repo_full_path ⇒ Object
- #repo_name ⇒ Object
- #repo_root ⇒ Object
- #run ⇒ Object
- #setup_context ⇒ Object
- #use_roles? ⇒ Boolean
Methods inherited from Base
#chef_runner, #generator_cookbook_name, #generator_cookbook_path, #have_git?
Methods included from ChefDK::Configurable
#chef_config, #chefdk_config, #config_loader, #generator_config, #knife_config
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#chefdk_home, #err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_chefdk_location, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_install?, #omnibus_root, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(params) ⇒ Repo
Returns a new instance of Repo.
56 57 58 59 60 61 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 56 def initialize(params) @params_valid = true @repo_name = nil @use_roles = true super end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
32 33 34 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 32 def errors @errors end |
#repo_name_or_path ⇒ Object (readonly)
Returns the value of attribute repo_name_or_path.
33 34 35 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 33 def repo_name_or_path @repo_name_or_path end |
Instance Method Details
#params_valid? ⇒ Boolean
117 118 119 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 117 def params_valid? @params_valid end |
#read_and_validate_params ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 102 def read_and_validate_params arguments = (params) @repo_name_or_path = arguments[0] unless @repo_name_or_path @params_valid = false end if !config[:roles].nil? && !config[:policy].nil? err("Roles and Policyfiles are exclusive. Please only select one.") @params_valid = false end if config[:policy] @use_roles = false end end |
#recipe ⇒ Object
82 83 84 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 82 def recipe "repo" end |
#repo_full_path ⇒ Object
94 95 96 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 94 def repo_full_path File.(repo_name_or_path, Dir.pwd) end |
#repo_name ⇒ Object
86 87 88 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 86 def repo_name File.basename(repo_full_path) end |
#repo_root ⇒ Object
90 91 92 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 90 def repo_root File.dirname(repo_full_path) end |
#run ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 63 def run read_and_validate_params if params_valid? setup_context chef_runner.converge 0 else err(opt_parser) 1 end end |
#setup_context ⇒ Object
75 76 77 78 79 80 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 75 def setup_context super Generator.add_attr_to_context(:repo_root, repo_root) Generator.add_attr_to_context(:repo_name, repo_name) Generator.add_attr_to_context(:use_roles, use_roles?) end |
#use_roles? ⇒ Boolean
98 99 100 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 98 def use_roles? @use_roles end |