chef-cli 1.0.3 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/chef-cli.gemspec +2 -2
  4. data/lib/chef-cli/builtin_commands.rb +3 -0
  5. data/lib/chef-cli/cli.rb +3 -1
  6. data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -0
  7. data/lib/chef-cli/command/clean_policy_revisions.rb +1 -0
  8. data/lib/chef-cli/command/delete_policy.rb +1 -0
  9. data/lib/chef-cli/command/delete_policy_group.rb +1 -0
  10. data/lib/chef-cli/command/describe_cookbook.rb +1 -0
  11. data/lib/chef-cli/command/diff.rb +5 -3
  12. data/lib/chef-cli/command/env.rb +3 -3
  13. data/lib/chef-cli/command/export.rb +1 -0
  14. data/lib/chef-cli/command/generate.rb +1 -0
  15. data/lib/chef-cli/command/generator_commands/chef_exts/quieter_doc_formatter.rb +2 -4
  16. data/lib/chef-cli/command/generator_commands/generator_generator.rb +1 -0
  17. data/lib/chef-cli/command/install.rb +1 -0
  18. data/lib/chef-cli/command/push.rb +1 -0
  19. data/lib/chef-cli/command/push_archive.rb +1 -1
  20. data/lib/chef-cli/command/shell_init.rb +3 -2
  21. data/lib/chef-cli/command/show_policy.rb +1 -0
  22. data/lib/chef-cli/command/undelete.rb +1 -0
  23. data/lib/chef-cli/command/update.rb +1 -0
  24. data/lib/chef-cli/component_test.rb +2 -1
  25. data/lib/chef-cli/configurable.rb +3 -2
  26. data/lib/chef-cli/cookbook_profiler/null_scm.rb +1 -2
  27. data/lib/chef-cli/generator.rb +1 -1
  28. data/lib/chef-cli/helpers.rb +2 -1
  29. data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +1 -1
  30. data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
  31. data/lib/chef-cli/policyfile/chef_repo_cookbook_source.rb +1 -1
  32. data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +3 -3
  33. data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +5 -5
  34. data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
  35. data/lib/chef-cli/policyfile/comparison_base.rb +1 -0
  36. data/lib/chef-cli/policyfile/cookbook_location_specification.rb +4 -4
  37. data/lib/chef-cli/policyfile/cookbook_locks.rb +8 -5
  38. data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +1 -1
  39. data/lib/chef-cli/policyfile/differ.rb +6 -2
  40. data/lib/chef-cli/policyfile/dsl.rb +4 -2
  41. data/lib/chef-cli/policyfile/git_lock_fetcher.rb +2 -2
  42. data/lib/chef-cli/policyfile/included_policies_cookbook_source.rb +1 -1
  43. data/lib/chef-cli/policyfile/lister.rb +2 -2
  44. data/lib/chef-cli/policyfile/local_lock_fetcher.rb +7 -5
  45. data/lib/chef-cli/policyfile/lock_applier.rb +1 -1
  46. data/lib/chef-cli/policyfile/null_cookbook_source.rb +1 -2
  47. data/lib/chef-cli/policyfile/policyfile_location_specification.rb +3 -3
  48. data/lib/chef-cli/policyfile/remote_lock_fetcher.rb +1 -1
  49. data/lib/chef-cli/policyfile/solution_dependencies.rb +13 -11
  50. data/lib/chef-cli/policyfile/storage_config.rb +1 -0
  51. data/lib/chef-cli/policyfile/undo_record.rb +10 -8
  52. data/lib/chef-cli/policyfile/uploader.rb +3 -1
  53. data/lib/chef-cli/policyfile_compiler.rb +17 -13
  54. data/lib/chef-cli/policyfile_lock.rb +17 -15
  55. data/lib/chef-cli/policyfile_services/clean_policies.rb +3 -3
  56. data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +2 -2
  57. data/lib/chef-cli/policyfile_services/export_repo.rb +4 -2
  58. data/lib/chef-cli/policyfile_services/install.rb +3 -1
  59. data/lib/chef-cli/policyfile_services/push.rb +6 -5
  60. data/lib/chef-cli/policyfile_services/push_archive.rb +6 -5
  61. data/lib/chef-cli/policyfile_services/rm_policy.rb +6 -2
  62. data/lib/chef-cli/policyfile_services/rm_policy_group.rb +2 -2
  63. data/lib/chef-cli/policyfile_services/show_policy.rb +2 -2
  64. data/lib/chef-cli/policyfile_services/undelete.rb +2 -2
  65. data/lib/chef-cli/version.rb +1 -1
  66. data/lib/kitchen/provisioner/policyfile_zero.rb +3 -6
  67. data/spec/unit/cli_spec.rb +5 -5
  68. data/spec/unit/command/base_spec.rb +1 -1
  69. data/spec/unit/command/env_spec.rb +1 -1
  70. data/spec/unit/command/exec_spec.rb +1 -1
  71. data/spec/unit/command/export_spec.rb +1 -1
  72. data/spec/unit/command/generator_commands/recipe_spec.rb +2 -1
  73. data/spec/unit/command/generator_commands/repo_spec.rb +6 -6
  74. data/spec/unit/command/verify_spec.rb +1 -1
  75. data/spec/unit/policyfile/attribute_merge_checker_spec.rb +10 -8
  76. data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +4 -2
  77. data/spec/unit/policyfile/cookbook_locks_spec.rb +9 -9
  78. data/spec/unit/policyfile/git_lock_fetcher_spec.rb +5 -5
  79. data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +5 -3
  80. data/spec/unit/policyfile/lister_spec.rb +5 -5
  81. data/spec/unit/policyfile/local_lock_fetcher_spec.rb +1 -1
  82. data/spec/unit/policyfile/lock_applier_spec.rb +2 -2
  83. data/spec/unit/policyfile/reports/install_spec.rb +14 -14
  84. data/spec/unit/policyfile/reports/upload_spec.rb +3 -3
  85. data/spec/unit/policyfile/uploader_spec.rb +13 -12
  86. data/spec/unit/policyfile_demands_spec.rb +4 -4
  87. data/spec/unit/policyfile_includes_spec.rb +14 -7
  88. data/spec/unit/policyfile_install_with_includes_spec.rb +8 -7
  89. data/spec/unit/policyfile_lock_build_spec.rb +17 -18
  90. data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +5 -5
  91. data/spec/unit/policyfile_services/push_archive_spec.rb +6 -6
  92. data/spec/unit/policyfile_services/push_spec.rb +8 -8
  93. data/spec/unit/policyfile_services/rm_policy_group_spec.rb +5 -5
  94. data/spec/unit/policyfile_services/rm_policy_spec.rb +5 -5
  95. data/spec/unit/policyfile_services/update_attributes_spec.rb +2 -1
  96. data/spec/unit/service_exception_inspectors/http_spec.rb +7 -7
  97. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 179c29f00c37fe62da52748abb225ff5d69af99d02ae5dba65c5c717af18daf6
4
- data.tar.gz: c1872be5f67110ce510c2a6e071afd127921bd40d3a789a25bf93ece784f9177
3
+ metadata.gz: 1985081b5bf2886c0caecfd05a999a3b57e772cbac8a9ae359052f555eef721c
4
+ data.tar.gz: ebe9aa6a7395a044c28e352c019dff6a94ade162c4313ca266f4ce3e24666100
5
5
  SHA512:
6
- metadata.gz: a0e0e9e83ee7c53cb2002f481eaf73a8419a9678583636be01f9355e4c51df0f280b583087693592d329e9c76b3712626bc1931d210f7906c5175a11f344dabb
7
- data.tar.gz: 28d71f03e2c067f17a48e33862934189564c038ec3b52ccf2e32d6734d2638a5cf978c7bea5d1a83c4706a157a178d55473cc97cb84efa52964abd68d7942da2
6
+ metadata.gz: 332b60af49070b9a9450e34d8782c760ccd319f801a45e423a66050af2202071dede00f605181c1c232e0e7bbb1c69f83845baadfb8bfedd37d9139d5705b361
7
+ data.tar.gz: ae9f8a2ec4a7c6c8f2e34fdc06925f3747cd6f9742d99e130cea3bfc3043186e59a3e8bb55fb018d53a4efee32f128d817c8b742e9babdd91d54e510756ba5ab
data/Gemfile CHANGED
@@ -9,6 +9,10 @@ group :docs do
9
9
  end
10
10
 
11
11
  group :test do
12
+ # For ruby 2.4 testing we need to use ohai 14
13
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
14
+ gem "ohai", "~> 14"
15
+ end
12
16
  gem "rake"
13
17
  gem "rspec", "~> 3.8"
14
18
  gem "rspec-expectations", "~> 3.8"
data/chef-cli.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
29
29
  gem.license = "Apache-2.0"
30
30
  gem.homepage = "https://www.chef.io/"
31
31
 
32
- gem.required_ruby_version = ">= 2.5"
32
+ gem.required_ruby_version = ">= 2.4"
33
33
 
34
34
  gem.files = %w{Rakefile LICENSE} +
35
35
  Dir.glob("Gemfile*") + # Includes Gemfile and locks
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
43
43
  gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
44
44
  gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
45
45
  gem.add_dependency "minitar", "~> 0.6"
46
- gem.add_dependency "chef", "~> 15.0"
46
+ gem.add_dependency "chef", ">= 14.0"
47
47
  gem.add_dependency "solve", "< 5.0", "> 2.0"
48
48
  gem.add_dependency "addressable", ">= 2.3.5", "< 2.6"
49
49
  gem.add_dependency "cookbook-omnifetch", "~> 0.5"
@@ -59,4 +59,7 @@ ChefCLI.commands do |c|
59
59
  desc: "Prints cookbook checksum information used for cookbook identifier"
60
60
 
61
61
  c.builtin "verify", :Verify, desc: "Test the embedded #{ChefCLI::Dist::PRODUCT} applications", hidden: true
62
+
63
+ # deprecated command that throws a failure warning if used. This was removed 4.2019
64
+ c.builtin "provision", :Provision, desc: "Provision VMs and clusters via cookbook", hidden: true
62
65
  end
data/lib/chef-cli/cli.rb CHANGED
@@ -120,6 +120,7 @@ module ChefCLI
120
120
  justify_length = subcommands.map(&:length).max + 2
121
121
  subcommand_specs.each do |name, spec|
122
122
  next if spec.hidden
123
+
123
124
  msg(" #{"#{name}".ljust(justify_length)}#{spec.description}")
124
125
  end
125
126
  end
@@ -155,7 +156,7 @@ module ChefCLI
155
156
  private
156
157
 
157
158
  def normalized_exit_code(maybe_integer)
158
- if maybe_integer.kind_of?(Integer) && (0..255).cover?(maybe_integer)
159
+ if maybe_integer.is_a?(Integer) && (0..255).cover?(maybe_integer)
159
160
  maybe_integer
160
161
  else
161
162
  0
@@ -186,6 +187,7 @@ module ChefCLI
186
187
  def sanity_check!
187
188
  # When installed outside of omnibus, trust the user to configure their PATH
188
189
  return true unless omnibus_install?
190
+
189
191
  paths = env[path_key].split(File::PATH_SEPARATOR)
190
192
  paths.map! { |p| drive_upcase(Chef::Util::PathHelper.cleanpath(p)) }
191
193
  embed_index = paths.index(drive_upcase(Chef::Util::PathHelper.cleanpath(omnibus_embedded_bin_dir)))
@@ -71,6 +71,7 @@ module ChefCLI
71
71
 
72
72
  def run(params)
73
73
  return 1 unless apply_params!(params)
74
+
74
75
  clean_policy_cookbooks_service.run
75
76
  0
76
77
  rescue PolicyfileServiceError => e
@@ -68,6 +68,7 @@ module ChefCLI
68
68
 
69
69
  def run(params)
70
70
  return 1 unless apply_params!(params)
71
+
71
72
  clean_policies_service.run
72
73
  0
73
74
  rescue PolicyfileServiceError => e
@@ -68,6 +68,7 @@ module ChefCLI
68
68
 
69
69
  def run(params)
70
70
  return 1 unless apply_params!(params)
71
+
71
72
  rm_policy_service.run
72
73
  ui.msg("This operation can be reversed by running `#{ChefCLI::Dist::EXEC} undelete --last`.")
73
74
  0
@@ -68,6 +68,7 @@ module ChefCLI
68
68
 
69
69
  def run(params)
70
70
  return 1 unless apply_params!(params)
71
+
71
72
  rm_policy_group_service.run
72
73
  ui.msg("This operation can be reversed by running `#{ChefCLI::Dist::EXEC} undelete --last`.")
73
74
  0
@@ -63,6 +63,7 @@ module ChefCLI
63
63
  def run(params = [])
64
64
  return 1 unless apply_params!(params)
65
65
  return 1 unless check_cookbook_path
66
+
66
67
  IdDumper.new(ui, cookbook_path).run
67
68
  end
68
69
 
@@ -125,6 +125,7 @@ module ChefCLI
125
125
 
126
126
  def run(params = [])
127
127
  return 1 unless apply_params!(params)
128
+
128
129
  print_diff
129
130
  0
130
131
  rescue PolicyfileServiceError => e
@@ -153,7 +154,7 @@ module ChefCLI
153
154
  end
154
155
  end
155
156
 
156
- def differ(ui = self.ui())
157
+ def differ(ui = self.ui)
157
158
  Policyfile::Differ.new(old_name: old_base.name,
158
159
  old_lock: old_lock,
159
160
  new_name: new_base.name,
@@ -163,8 +164,8 @@ module ChefCLI
163
164
 
164
165
  def http_client
165
166
  @http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
166
- signing_key_filename: chef_config.client_key,
167
- client_name: chef_config.node_name)
167
+ signing_key_filename: chef_config.client_key,
168
+ client_name: chef_config.node_name)
168
169
  end
169
170
 
170
171
  def old_lock
@@ -290,6 +291,7 @@ module ChefCLI
290
291
  def policy_group_comparison?(args)
291
292
  return false if args.empty?
292
293
  return true if args.size > 1
294
+
293
295
  !(args.first =~ /\.rb\Z/)
294
296
  end
295
297
 
@@ -57,10 +57,10 @@ module ChefCLI
57
57
  end
58
58
 
59
59
  def ruby_info
60
- Hash.new.tap do |ruby|
60
+ {}.tap do |ruby|
61
61
  ruby["Executable"] = Gem.ruby
62
62
  ruby["Version"] = RUBY_VERSION
63
- ruby["RubyGems"] = Hash.new.tap do |rubygems|
63
+ ruby["RubyGems"] = {}.tap do |rubygems|
64
64
  rubygems["RubyGems Version"] = Gem::VERSION
65
65
  rubygems["RubyGems Platforms"] = Gem.platforms.map(&:to_s)
66
66
  rubygems["Gem Environment"] = gem_environment
@@ -88,7 +88,7 @@ module ChefCLI
88
88
  end
89
89
 
90
90
  def policyfile_config
91
- Hash.new.tap do |h|
91
+ {}.tap do |h|
92
92
  h["Cache Path"] = CookbookOmnifetch.cache_path
93
93
  h["Storage Path"] = CookbookOmnifetch.storage_path.to_s
94
94
  end
@@ -84,6 +84,7 @@ module ChefCLI
84
84
 
85
85
  def run(params = [])
86
86
  return 1 unless apply_params!(params)
87
+
87
88
  export_service.run
88
89
  ui.msg("Exported policy '#{export_service.policyfile_lock.name}' to #{export_target}")
89
90
  unless archive?
@@ -111,6 +111,7 @@ module ChefCLI
111
111
  # we delegate the request to the specified generator.
112
112
  def needs_help?(params)
113
113
  return false if have_generator?(params[0])
114
+
114
115
  super
115
116
  end
116
117
 
@@ -28,11 +28,9 @@ module ChefCLI
28
28
  cli_name(:chefcli_doc)
29
29
 
30
30
  # Called when starting to collect gems from the cookbooks
31
- def cookbook_gem_start(gems)
32
- end
31
+ def cookbook_gem_start(gems); end
33
32
 
34
33
  # Called when cookbook loading starts.
35
- def library_load_start(file_count)
36
- end
34
+ def library_load_start(file_count); end
37
35
  end
38
36
  end
@@ -47,6 +47,7 @@ module ChefCLI
47
47
 
48
48
  def run
49
49
  return 1 unless verify_params!
50
+
50
51
  FileUtils.cp_r(source, destination_dir)
51
52
  update_metadata_rb
52
53
  ui.msg("Copied built-in generator cookbook to #{created_cookbook_path}")
@@ -71,6 +71,7 @@ module ChefCLI
71
71
 
72
72
  def run(params = [])
73
73
  return 1 unless apply_params!(params)
74
+
74
75
  # Force config file to be loaded. We don't use the configuration
75
76
  # directly, but the user may have SSL configuration options that they
76
77
  # need to talk to a private supermarket (e.g., trusted_certs or
@@ -72,6 +72,7 @@ module ChefCLI
72
72
 
73
73
  def run(params = [])
74
74
  return 1 unless apply_params!(params)
75
+
75
76
  push.run
76
77
  0
77
78
  rescue PolicyfileServiceError => e
@@ -98,7 +98,7 @@ module ChefCLI
98
98
  policy_group: policy_group,
99
99
  ui: ui,
100
100
  config: chef_config
101
- )
101
+ )
102
102
  end
103
103
 
104
104
  def archive_file
@@ -96,7 +96,7 @@ module ChefCLI
96
96
  return 1
97
97
  elsif !SUPPORTED_SHELLS.include?(shell_name)
98
98
  err("Shell `#{shell_name}' is not currently supported")
99
- err("Supported shells are: #{SUPPORTED_SHELLS.join(' ')}")
99
+ err("Supported shells are: #{SUPPORTED_SHELLS.join(" ")}")
100
100
  return 1
101
101
  end
102
102
 
@@ -117,6 +117,7 @@ module ChefCLI
117
117
 
118
118
  def completion_for(shell)
119
119
  return "" unless (completion_template_basename = completion_template_for(shell))
120
+
120
121
  completion_template_path = expand_completion_template_path(completion_template_basename)
121
122
  erb = ERB.new(File.read(completion_template_path), nil, "-")
122
123
  context_binding = shell_completion_template_context.get_binding
@@ -166,7 +167,7 @@ module ChefCLI
166
167
  # /dev/null to avoid Fish's helpful warnings about nonexistent
167
168
  # PATH elements.
168
169
  if var == "PATH"
169
- emit_shell_cmd(%Q{set -gx #{var} "#{val.split(':').join('" "')}" 2>/dev/null;})
170
+ emit_shell_cmd(%Q{set -gx #{var} "#{val.split(":").join('" "')}" 2>/dev/null;})
170
171
  else
171
172
  emit_shell_cmd(%Q{set -gx #{var} "#{val}";})
172
173
  end
@@ -87,6 +87,7 @@ module ChefCLI
87
87
 
88
88
  def run(params)
89
89
  return 1 unless apply_params!(params)
90
+
90
91
  show_policy_service.run
91
92
  0
92
93
  rescue PolicyfileServiceError => e
@@ -89,6 +89,7 @@ module ChefCLI
89
89
 
90
90
  def run(params)
91
91
  return 1 unless apply_params!(params)
92
+
92
93
  if list_undo_records?
93
94
  undelete_service.list
94
95
  else
@@ -90,6 +90,7 @@ module ChefCLI
90
90
 
91
91
  def run(params = [])
92
92
  return 1 unless apply_params!(params)
93
+
93
94
  attributes_updater.run
94
95
  installer.run(@cookbooks_to_update, config[:exclude_deps]) unless update_attributes_only?
95
96
  0
@@ -125,7 +125,7 @@ module ChefCLI
125
125
  # the return value of the test block. For tests that run a lot of commands,
126
126
  # this is inconvenient so you can use #sh! instead.
127
127
  def sh!(*args)
128
- sh(*args).tap { |result| result.error! }
128
+ sh(*args).tap(&:error!)
129
129
  end
130
130
 
131
131
  # Run a command, if the command returns zero, raise an error,
@@ -197,6 +197,7 @@ module ChefCLI
197
197
 
198
198
  def gem_base_dir
199
199
  return nil if @gem_name_for_base_dir.nil?
200
+
200
201
  # There is no way to say "give me the latest prerelease OR normal version of this gem.
201
202
  # So we first ask if there is a normal version, and if there is not, we ask if there
202
203
  # is a prerelease version. ">= 0.a" is how we ask for a prerelease version, because a
@@ -49,6 +49,7 @@ module ChefCLI
49
49
 
50
50
  def chef_config
51
51
  return @chef_config if @chef_config
52
+
52
53
  config_loader.load
53
54
  @chef_config = Chef::Config
54
55
  CookbookOmnifetch.integration.default_chef_server_http_client = default_chef_server_http_client
@@ -79,8 +80,8 @@ module ChefCLI
79
80
  def default_chef_server_http_client
80
81
  lambda do
81
82
  ChefServerAPIMulti.new(@chef_config.chef_server_url,
82
- signing_key_filename: @chef_config.client_key,
83
- client_name: @chef_config.node_name)
83
+ signing_key_filename: @chef_config.client_key,
84
+ client_name: @chef_config.node_name)
84
85
  end
85
86
  end
86
87
 
@@ -19,8 +19,7 @@ module ChefCLI
19
19
  module CookbookProfiler
20
20
  class NullSCM
21
21
 
22
- def initialize(cookbook_path)
23
- end
22
+ def initialize(cookbook_path); end
24
23
 
25
24
  def profile_data
26
25
  nil
@@ -24,7 +24,7 @@ module ChefCLI
24
24
  def self.add_attr(name)
25
25
  @attributes ||= [ ]
26
26
 
27
- if !@attributes.include?(name)
27
+ unless @attributes.include?(name)
28
28
  @attributes << name
29
29
  attr_accessor(name)
30
30
  end
@@ -130,7 +130,8 @@ module ChefCLI
130
130
 
131
131
  def omnibus_expand_path(*paths)
132
132
  dir = File.expand_path(File.join(paths))
133
- raise OmnibusInstallNotFound.new() unless dir && File.directory?(dir)
133
+ raise OmnibusInstallNotFound.new unless dir && File.directory?(dir)
134
+
134
135
  dir
135
136
  end
136
137
 
@@ -42,7 +42,7 @@ module ChefCLI
42
42
  end
43
43
 
44
44
  def ==(other)
45
- other.kind_of?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
45
+ other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
46
46
  end
47
47
 
48
48
  def preferred_for(*cookbook_names)
@@ -89,7 +89,7 @@ module ChefCLI
89
89
  def fill!(acc, source_name, path, hash)
90
90
  hash.each do |(key, val)|
91
91
  new_path = "#{path}[#{key}]"
92
- if val.kind_of?(Hash)
92
+ if val.is_a?(Hash)
93
93
  acc[key] ||= Mash.new
94
94
  fill!(acc[key], source_name, new_path, val)
95
95
  else
@@ -54,7 +54,7 @@ module ChefCLI
54
54
  end
55
55
 
56
56
  def ==(other)
57
- other.kind_of?(self.class) && other.path == path && other.preferred_cookbooks == preferred_cookbooks
57
+ other.is_a?(self.class) && other.path == path && other.preferred_cookbooks == preferred_cookbooks
58
58
  end
59
59
 
60
60
  # Calls the slurp_metadata! helper once to calculate the @universe_graph
@@ -40,7 +40,7 @@ module ChefCLI
40
40
  end
41
41
 
42
42
  def ==(other)
43
- other.kind_of?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
43
+ other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
44
44
  end
45
45
 
46
46
  def preferred_for(*cookbook_names)
@@ -84,8 +84,8 @@ module ChefCLI
84
84
  def http_connection_for(base_url)
85
85
  @http_connections[base_url] ||=
86
86
  ChefServerAPIMulti.new(base_url,
87
- signing_key_filename: chef_config.client_key,
88
- client_name: chef_config.node_name)
87
+ signing_key_filename: chef_config.client_key,
88
+ client_name: chef_config.node_name)
89
89
  end
90
90
 
91
91
  def full_chef_server_graph
@@ -73,11 +73,11 @@ module ChefCLI
73
73
  def errors
74
74
  error_messages = []
75
75
 
76
- [:server, :policy_name].each do |key|
76
+ %i{server policy_name}.each do |key|
77
77
  error_messages << "include_policy for #{name} is missing key #{key}" unless source_options[key]
78
78
  end
79
79
 
80
- if [:policy_revision_id, :policy_group].all? { |key| source_options[key].nil? }
80
+ if %i{policy_revision_id policy_group}.all? { |key| source_options[key].nil? }
81
81
  error_messages << "include_policy for #{name} must specify policy_revision_id or policy_group"
82
82
  end
83
83
 
@@ -101,7 +101,7 @@ module ChefCLI
101
101
  acc
102
102
  end
103
103
  source_options.merge!(options)
104
- raise ChefCLI::InvalidLockfile, "Invalid source_options provided from lock data: #{options_from_lock_file.inspect}" if !valid?
104
+ raise ChefCLI::InvalidLockfile, "Invalid source_options provided from lock data: #{options_from_lock_file.inspect}" unless valid?
105
105
  end
106
106
 
107
107
  # @return [String] of the policyfile lock data
@@ -158,8 +158,8 @@ module ChefCLI
158
158
  # @return [Hash] Returns a parsed JSON object... I think.
159
159
  def http_client
160
160
  @http_client ||= Chef::ServerAPI.new(source_options[:server],
161
- signing_key_filename: chef_config.client_key,
162
- client_name: chef_config.node_name)
161
+ signing_key_filename: chef_config.client_key,
162
+ client_name: chef_config.node_name)
163
163
  end
164
164
 
165
165
  end
@@ -48,7 +48,7 @@ module ChefCLI
48
48
  end
49
49
 
50
50
  def ==(other)
51
- other.kind_of?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
51
+ other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
52
52
  end
53
53
 
54
54
  def universe_graph
@@ -38,6 +38,7 @@ module ChefCLI
38
38
  def lock
39
39
  raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} does not exist" unless File.exist?(policyfile_lock_relpath)
40
40
  raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} cannot be read" unless File.readable?(policyfile_lock_relpath)
41
+
41
42
  FFI_Yajl::Parser.parse(IO.read(policyfile_lock_relpath))
42
43
  rescue FFI_Yajl::ParseError => e
43
44
  raise MalformedLockfile, "Invalid JSON in lockfile at #{policyfile_lock_relpath}:\n #{e.message}"
@@ -29,7 +29,7 @@ module ChefCLI
29
29
  # API contract
30
30
  include StorageConfigDelegation
31
31
 
32
- SOURCE_TYPES = [:git, :github, :path, :artifactserver, :chef_server, :chef_server_artifact, :artifactory].freeze
32
+ SOURCE_TYPES = %i{git github path artifactserver chef_server chef_server_artifact artifactory}.freeze
33
33
 
34
34
  #--
35
35
  # Required by CookbookOmnifetch API contract
@@ -54,7 +54,7 @@ module ChefCLI
54
54
  end
55
55
 
56
56
  def ==(other)
57
- other.kind_of?(self.class) &&
57
+ other.is_a?(self.class) &&
58
58
  other.name == name &&
59
59
  other.version_constraint == version_constraint &&
60
60
  other.source_options == source_options
@@ -69,7 +69,7 @@ module ChefCLI
69
69
  end
70
70
 
71
71
  def mirrors_canonical_upstream?
72
- [:git, :github, :artifactserver, :chef_server, :chef_server_artifact, :artifactory].include?(source_type)
72
+ %i{git github artifactserver chef_server chef_server_artifact artifactory}.include?(source_type)
73
73
  end
74
74
 
75
75
  def installed?
@@ -112,7 +112,7 @@ module ChefCLI
112
112
  end
113
113
 
114
114
  def version_fixed?
115
- [:git, :github, :path, :chef_server_artifact].include?(@source_type)
115
+ %i{git github path chef_server_artifact}.include?(@source_type)
116
116
  end
117
117
 
118
118
  def version
@@ -82,6 +82,7 @@ module ChefCLI
82
82
  def cookbook_location_spec
83
83
  raise InvalidCookbookLockData, "Cannot create CookbookLocationSpecification for #{name} without version" if version.nil?
84
84
  raise InvalidCookbookLockData, "Cannot create CookbookLocationSpecification for #{name} without source options" if source_options.nil?
85
+
85
86
  @location_spec ||= CookbookLocationSpecification.new(name, "= #{version}", source_options, storage_config)
86
87
  end
87
88
 
@@ -170,22 +171,22 @@ module ChefCLI
170
171
  end
171
172
 
172
173
  version = lock_data["version"]
173
- unless version.kind_of?(String)
174
+ unless version.is_a?(String)
174
175
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `version' attribute must be a string (got: #{version})"
175
176
  end
176
177
 
177
178
  identifier = lock_data["identifier"]
178
- unless identifier.kind_of?(String)
179
+ unless identifier.is_a?(String)
179
180
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `identifier' attribute must be a string (got: #{identifier})"
180
181
  end
181
182
 
182
183
  cache_key = lock_data["cache_key"]
183
- unless cache_key.kind_of?(String) || cache_key.nil?
184
+ unless cache_key.is_a?(String) || cache_key.nil?
184
185
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `cache_key' attribute must be a string (got: #{cache_key})"
185
186
  end
186
187
 
187
188
  source_options = lock_data["source_options"]
188
- unless source_options.kind_of?(Hash)
189
+ unless source_options.is_a?(Hash)
189
190
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `source_options' attribute must be a Hash (JSON object) (got: #{source_options})"
190
191
  end
191
192
  end
@@ -220,6 +221,7 @@ module ChefCLI
220
221
  if cache_key.nil?
221
222
  raise MissingCookbookLockData, "Cannot locate cached cookbook `#{name}' because the `cache_key' attribute is not set"
222
223
  end
224
+
223
225
  File.join(cache_path, cache_key)
224
226
  end
225
227
 
@@ -340,6 +342,7 @@ module ChefCLI
340
342
  unless File.exist?(cookbook_path)
341
343
  raise LocalCookbookNotFound, "Cookbook `#{name}' not found at path source `#{source}` (full path: `#{cookbook_path}')"
342
344
  end
345
+
343
346
  unless cookbook_version.name.to_s == name
344
347
  msg = "The cookbook at path source `#{source}' is expected to be named `#{name}', but is now named `#{cookbook_version.name}' (full path: #{cookbook_path})"
345
348
  raise MalformedCookbook, msg
@@ -385,7 +388,7 @@ module ChefCLI
385
388
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} is invalid. Lock data for a local cookbook must have a `source' attribute"
386
389
  end
387
390
 
388
- unless source.kind_of?(String)
391
+ unless source.is_a?(String)
389
392
  raise InvalidLockfile, "Lockfile cookbook_lock for #{name} is invalid: `source' attribute must be a String (got: #{source.inspect})"
390
393
  end
391
394
  end
@@ -60,7 +60,7 @@ module ChefCLI
60
60
  end
61
61
 
62
62
  def ==(other)
63
- other.kind_of?(self.class) && other.uri == uri
63
+ other.is_a?(self.class) && other.uri == uri
64
64
  end
65
65
 
66
66
  def default_source_args
@@ -95,6 +95,7 @@ module ChefCLI
95
95
 
96
96
  def report_run_list_changes
97
97
  return nil unless updated_sections.include?("run_list")
98
+
98
99
  h1("RUN LIST CHANGED")
99
100
 
100
101
  old_run_list = old_lock["run_list"]
@@ -105,6 +106,7 @@ module ChefCLI
105
106
 
106
107
  def report_removed_cookbooks
107
108
  return nil if removed_cookbooks.empty?
109
+
108
110
  h1("REMOVED COOKBOOKS")
109
111
  removed_cookbooks.each do |cb_name|
110
112
  ui.print("\n")
@@ -117,6 +119,7 @@ module ChefCLI
117
119
 
118
120
  def report_added_cookbooks
119
121
  return nil if added_cookbooks.empty?
122
+
120
123
  h1("ADDED COOKBOOKS")
121
124
  added_cookbooks.each do |cb_name|
122
125
  ui.print("\n")
@@ -129,6 +132,7 @@ module ChefCLI
129
132
 
130
133
  def report_modified_cookbooks
131
134
  return nil if modified_cookbooks.empty?
135
+
132
136
  h1("MODIFIED COOKBOOKS")
133
137
  modified_cookbooks.each do |cb_name|
134
138
  ui.print("\n")
@@ -202,7 +206,7 @@ module ChefCLI
202
206
 
203
207
  maybe_contiguous_hunks = (previous_hunk.nil? || hunk.merge(previous_hunk))
204
208
 
205
- if !maybe_contiguous_hunks
209
+ unless maybe_contiguous_hunks
206
210
  print_color_diff("#{previous_hunk.diff(FORMAT)}\n")
207
211
  end
208
212
  previous_hunk = hunk
@@ -231,7 +235,7 @@ module ChefCLI
231
235
  end
232
236
 
233
237
  def pretty_json(data)
234
- FFI_Yajl::Encoder.encode(data, pretty: true).lines.map { |l| l.chomp }
238
+ FFI_Yajl::Encoder.encode(data, pretty: true).lines.map(&:chomp)
235
239
  end
236
240
 
237
241
  def detect_cookbook_changes