Class: ChefCLI::Command::GeneratorCommands::Repo
  
  
  
  
  
    - Inherits:
 
    - 
      Base
      
        
          - Object
 
          
            - Base
 
          
            - Base
 
          
            - ChefCLI::Command::GeneratorCommands::Repo
 
          
        
        show all
      
     
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/chef-cli/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
  
  
  
  Attributes inherited from Base
  #params
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Base
  #chef_runner, #generator_cookbook_name, #generator_cookbook_path, #have_git?
  
  
  
  
  
  
  
  
  
  #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(params)  ⇒ Repo 
  
  
  
  
    
Returns a new instance of Repo.
   
 
  
  
    
      
64
65
66
67
68
69
70 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 64
def initialize(params)
  @params_valid = true
  @repo_name = nil
  @use_policy = true
  @verbose = false
  super
end 
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #errors  ⇒ Object  
  
  
  
  
    
Returns the value of attribute errors.
   
 
  
  
    
      
33
34
35 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 33
def errors
  @errors
end 
     | 
  
 
    
      
      
      
  
  
    #repo_name_or_path  ⇒ Object  
  
  
  
  
    
Returns the value of attribute repo_name_or_path.
   
 
  
  
    
      
34
35
36 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 34
def repo_name_or_path
  @repo_name_or_path
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #params_valid?  ⇒ Boolean 
  
  
  
  
    
      
134
135
136 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 134
def params_valid?
  @params_valid
end 
     | 
  
 
    
      
  
  
    #read_and_validate_params  ⇒ Object 
  
  
  
  
    
      
119
120
121
122
123
124
125
126
127
128
129
130
131
132 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 119
def read_and_validate_params
  arguments = parse_options(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[:roles]
    @use_policy = false
  end
end
     | 
  
 
    
      
  
  
    #recipe  ⇒ Object 
  
  
  
  
    
      
95
96
97 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 95
def recipe
  "repo"
end 
     | 
  
 
    
      
  
  
    #repo_full_path  ⇒ Object 
  
  
  
  
    
      
107
108
109 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 107
def repo_full_path
  File.expand_path(repo_name_or_path, Dir.pwd)
end 
     | 
  
 
    
      
  
  
    #repo_name  ⇒ Object 
  
  
  
  
    
      
99
100
101 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 99
def repo_name
  File.basename(repo_full_path)
end 
     | 
  
 
    
      
  
  
    #repo_root  ⇒ Object 
  
  
  
  
    
      
103
104
105 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 103
def repo_root
  File.dirname(repo_full_path)
end 
     | 
  
 
    
      
  
  
    #run  ⇒ Object 
  
  
  
  
    
      
72
73
74
75
76
77
78
79
80
81
82
83
84
85 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 72
def run
  read_and_validate_params
  if params_valid?
    setup_context
    msg("Generating Chef Infra repo #{repo_name}")
    chef_runner.converge
    msg("")
    msg("Your new Chef Infra repo is ready! Type `cd #{repo_name}` to enter it.")
    0
  else
    err(opt_parser)
    1
  end
end
     | 
  
 
    
      
    
      
  
  
    #use_policy?  ⇒ Boolean 
  
  
  
  
    
      
111
112
113 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 111
def use_policy?
  @use_policy
end 
     | 
  
 
    
      
  
  
    #verbose?  ⇒ Boolean 
  
  
  
  
    
      
115
116
117 
     | 
    
      # File 'lib/chef-cli/command/generator_commands/repo.rb', line 115
def verbose?
  @verbose
end 
     |