Class: ChefCLI::Command::GeneratorCommands::Policyfile
- Defined in:
- lib/chef-cli/command/generator_commands/policyfile.rb
Instance Attribute Summary collapse
-
#new_file_basename ⇒ Object
readonly
Returns the value of attribute new_file_basename.
-
#policy_name ⇒ Object
readonly
Returns the value of attribute policy_name.
-
#policy_run_list ⇒ Object
readonly
Returns the value of attribute policy_run_list.
-
#policyfile_dir ⇒ Object
readonly
Returns the value of attribute policyfile_dir.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(*args) ⇒ Policyfile
constructor
A new instance of Policyfile.
- #read_and_validate_params ⇒ Object
- #recipe ⇒ Object
- #run ⇒ Object
- #setup_context ⇒ Object
Methods inherited from Base
#chef_runner, #generator_cookbook_name, #generator_cookbook_path, #have_git?
Methods included from ChefCLI::Configurable
#chef_config, #chefcli_config, #config_loader, #generator_config, #knife_config, #reset_config!
Methods inherited from Base
#check_license_acceptance, #needs_help?, #needs_version?, #run_with_default_options
Methods included from Helpers
#err, #git_bin_dir, #git_windows_bin_dir, #msg, #omnibus_bin_dir, #omnibus_embedded_bin_dir, #omnibus_env, #omnibus_expand_path, #omnibus_install?, #omnibus_root, #package_home, #stderr, #stdout, #system_command, #usr_bin_path, #usr_bin_prefix
Constructor Details
#initialize(*args) ⇒ Policyfile
Returns a new instance of Policyfile.
36 37 38 39 40 41 42 43 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 36 def initialize(*args) super @new_file_basename = nil @policyfile_dir = nil @policy_name = nil @policy_run_list = nil @params_valid = true end |
Instance Attribute Details
#new_file_basename ⇒ Object (readonly)
Returns the value of attribute new_file_basename.
31 32 33 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 31 def new_file_basename @new_file_basename end |
#policy_name ⇒ Object (readonly)
Returns the value of attribute policy_name.
33 34 35 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 33 def policy_name @policy_name end |
#policy_run_list ⇒ Object (readonly)
Returns the value of attribute policy_run_list.
34 35 36 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 34 def policy_run_list @policy_run_list end |
#policyfile_dir ⇒ Object (readonly)
Returns the value of attribute policyfile_dir.
32 33 34 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 32 def policyfile_dir @policyfile_dir end |
Instance Method Details
#read_and_validate_params ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 71 def read_and_validate_params arguments = (params) case arguments.size when 0 if chef_repo_mode? err("ERROR: You must give a policy name when generating a policy in a chef-repo.") @params_valid = false false else use_default_policy_settings end when 1 derive_policy_settings_from_args(arguments[0]) else @params_valid = false err("ERROR: too many arguments") false end end |
#recipe ⇒ Object
45 46 47 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 45 def recipe "policyfile" end |
#run ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 59 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
49 50 51 52 53 54 55 56 57 |
# File 'lib/chef-cli/command/generator_commands/policyfile.rb', line 49 def setup_context super Generator.add_attr_to_context(:policyfile_dir, policyfile_dir) Generator.add_attr_to_context(:new_file_basename, new_file_basename) Generator.add_attr_to_context(:include_chef_repo_source, chef_repo_mode?) Generator.add_attr_to_context(:policy_name, policy_name) Generator.add_attr_to_context(:policy_run_list, policy_run_list) Generator.add_attr_to_context(:policy_local_cookbook, nil) end |