Class: Chef::ChefFS::Knife
Instance Attribute Summary
Attributes inherited from Knife
#name_args, #ui
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Knife
#api_key, #apply_computed_config, category, chef_config_dir, common_name, #config_file_settings, config_loader, #create_object, #delete_object, dependency_loaders, #format_rest_error, guess_category, #humanize_exception, #humanize_http_exception, #initialize, list_commands, load_commands, load_config, load_deps, #merge_configs, msg, #noauth_rest, #parse_options, reset_config_loader!, reset_subcommands!, #rest, run, #run_with_pretty_exceptions, #server_url, #show_usage, snake_case_name, subcommand_category, subcommand_class_from, subcommand_loader, subcommands, subcommands_by_category, ui, unnamed?, use_separate_defaults?, #username
#constantize, #convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename
#enforce_path_sanity
Constructor Details
This class inherits a constructor from Chef::Knife
Class Method Details
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/chef/chef_fs/knife.rb', line 25
def self.deps
super do
require 'chef/config'
require 'chef/chef_fs/parallelizer'
require 'chef/chef_fs/config'
require 'chef/chef_fs/file_pattern'
require 'chef/chef_fs/path_utils'
yield
end
end
|
.inherited(c) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/chef/chef_fs/knife.rb', line 36
def self.inherited(c)
super
c.deps do
end
c.options.merge!(options)
end
|
Instance Method Details
76
77
78
|
# File 'lib/chef/chef_fs/knife.rb', line 76
def chef_fs
@chef_fs_config.chef_fs
end
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/chef/chef_fs/knife.rb', line 58
def configure_chef
super
Chef::Config[:repo_mode] = config[:repo_mode] if config[:repo_mode]
Chef::Config[:concurrency] = config[:concurrency].to_i if config[:concurrency]
if config[:chef_repo_path]
Chef::Config[:chef_repo_path] = config[:chef_repo_path]
%w(acl client cookbook container data_bag environment group node role user).each do |variable_name|
Chef::Config.delete("#{variable_name}_path".to_sym)
end
end
@chef_fs_config = Chef::ChefFS::Config.new(Chef::Config, Dir.pwd, config, ui)
Chef::ChefFS::Parallelizer.threads = (Chef::Config[:concurrency] || 10) - 1
end
|
#create_chef_fs ⇒ Object
80
81
82
|
# File 'lib/chef/chef_fs/knife.rb', line 80
def create_chef_fs
@chef_fs_config.create_chef_fs
end
|
#create_local_fs ⇒ Object
88
89
90
|
# File 'lib/chef/chef_fs/knife.rb', line 88
def create_local_fs
@chef_fs_config.create_local_fs
end
|
#discover_repo_dir(dir) ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/chef/chef_fs/knife.rb', line 119
def discover_repo_dir(dir)
%w(.chef cookbooks data_bags environments roles).each do |subdir|
return dir if File.directory?(File.join(dir, subdir))
end
parent = File.dirname(dir)
if parent && parent != dir
discover_repo_dir(parent)
else
nil
end
end
|
111
112
113
|
# File 'lib/chef/chef_fs/knife.rb', line 111
def format_path(entry)
@chef_fs_config.format_path(entry)
end
|
84
85
86
|
# File 'lib/chef/chef_fs/knife.rb', line 84
def local_fs
@chef_fs_config.local_fs
end
|
#parallelize(inputs, options = {}, &block) ⇒ Object
115
116
117
|
# File 'lib/chef/chef_fs/knife.rb', line 115
def parallelize(inputs, options = {}, &block)
Chef::ChefFS::Parallelizer.parallelize(inputs, options, &block)
end
|
#pattern_arg_from(arg) ⇒ Object
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/chef/chef_fs/knife.rb', line 100
def pattern_arg_from(arg)
if !@chef_fs_config.base_path && !Chef::ChefFS::PathUtils.is_absolute?(arg)
ui.error("Attempt to use relative path '#{arg}' when current directory is outside the repository path")
exit(1)
end
Chef::ChefFS::FilePattern.relative_to(@chef_fs_config.base_path, arg)
end
|
#pattern_args ⇒ Object
92
93
94
|
# File 'lib/chef/chef_fs/knife.rb', line 92
def pattern_args
@pattern_args ||= pattern_args_from(name_args)
end
|
#pattern_args_from(args) ⇒ Object
96
97
98
|
# File 'lib/chef/chef_fs/knife.rb', line 96
def pattern_args_from(args)
args.map { |arg| pattern_arg_from(arg) }
end
|