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
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
Methods inherited from Base
#needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#chefdk_home, #err, #msg, #omnibus_apps_dir, #omnibus_bin_dir, #omnibus_chefdk_location, #omnibus_embedded_bin_dir, #omnibus_install?, #omnibus_root, #stderr, #stdout, #system_command
Constructor Details
#initialize(params) ⇒ Repo
Returns a new instance of Repo.
43 44 45 46 47 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 43 def initialize(params) @params_valid = true @repo_name = nil 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
88 89 90 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 88 def params_valid? @params_valid end |
#read_and_validate_params ⇒ Object
82 83 84 85 86 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 82 def read_and_validate_params arguments = (params) @repo_name_or_path = arguments[0] @params_valid = false unless @repo_name_or_path end |
#recipe ⇒ Object
66 67 68 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 66 def recipe "repo" end |
#repo_full_path ⇒ Object
78 79 80 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 78 def repo_full_path File.(repo_name_or_path, Dir.pwd) end |
#repo_name ⇒ Object
70 71 72 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 70 def repo_name File.basename(repo_full_path) end |
#repo_root ⇒ Object
74 75 76 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 74 def repo_root File.dirname(repo_full_path) end |
#run ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 49 def run read_and_validate_params if params_valid? setup_context chef_runner.converge else msg() 1 end end |
#setup_context ⇒ Object
60 61 62 63 64 |
# File 'lib/chef-dk/command/generator_commands/repo.rb', line 60 def setup_context super Generator.add_attr_to_context(:repo_root, repo_root) Generator.add_attr_to_context(:repo_name, repo_name) end |