machinery-tool 1.18.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +17 -0
  4. data/bin/machinery +10 -2
  5. data/html/comparison.html.haml +1 -1
  6. data/html/index.html.haml +2 -2
  7. data/html/partials/{config_files.html.haml → changed_config_files.html.haml} +10 -10
  8. data/html/partials/compare/changed_config_files.html.haml +48 -0
  9. data/html/partials/compare/{config_file_list.html.haml → changed_config_files_list.html.haml} +0 -0
  10. data/html/partials/compare/unmanaged_file_list.html.haml +1 -1
  11. data/html/partials/compare/unmanaged_files.html.haml +2 -2
  12. data/html/partials/patterns.html.haml +5 -0
  13. data/html/upgrade.html.haml +49 -0
  14. data/lib/{analyze_config_file_diffs_task.rb → analyze_changed_config_files_diffs_task.rb} +8 -8
  15. data/lib/autoyast.rb +12 -13
  16. data/lib/build_task.rb +2 -2
  17. data/lib/cli.rb +39 -32
  18. data/lib/compare_task.rb +1 -1
  19. data/lib/config_base.rb +1 -1
  20. data/lib/deploy_task.rb +4 -4
  21. data/lib/docker_system.rb +1 -1
  22. data/lib/element_filter.rb +3 -3
  23. data/lib/export_task.rb +3 -3
  24. data/lib/file_validator.rb +8 -5
  25. data/lib/filter.rb +5 -5
  26. data/lib/filter_option_parser.rb +3 -3
  27. data/lib/hint.rb +9 -4
  28. data/lib/html.rb +3 -3
  29. data/lib/inspect_task.rb +3 -3
  30. data/lib/json_schema_monkey_patch.rb +2 -2
  31. data/lib/json_validation_error_cleaner.rb +1 -1
  32. data/lib/json_validator.rb +2 -2
  33. data/lib/kiwi_config.rb +39 -14
  34. data/lib/list_task.rb +1 -1
  35. data/lib/local_system.rb +4 -4
  36. data/lib/machinery.rb +1 -1
  37. data/lib/machinery_logger.rb +4 -4
  38. data/lib/manifest.rb +5 -5
  39. data/lib/migration.rb +4 -4
  40. data/lib/object.rb +6 -10
  41. data/lib/remove_task.rb +1 -1
  42. data/lib/renderer.rb +5 -5
  43. data/lib/scope_file_access_archive.rb +2 -2
  44. data/lib/scope_file_access_flat.rb +3 -3
  45. data/lib/scope_file_store.rb +3 -3
  46. data/lib/serve_html_task.rb +15 -2
  47. data/lib/server.rb +32 -12
  48. data/lib/system.rb +1 -1
  49. data/lib/system_description.rb +16 -14
  50. data/lib/system_description_store.rb +5 -6
  51. data/lib/ui.rb +1 -1
  52. data/lib/upgrade_format_task.rb +2 -2
  53. data/lib/version.rb +1 -1
  54. data/lib/workload_mapper.rb +11 -11
  55. data/lib/zypper.rb +1 -1
  56. data/machinery-helper/Rakefile +1 -1
  57. data/machinery-helper/version.go +1 -1
  58. data/man/generated/machinery.1.gz +0 -0
  59. data/manual/docs/machinery-analyze.1.md +3 -3
  60. data/manual/docs/machinery-compare.1.md +2 -2
  61. data/manual/docs/machinery-inspect-docker.1.md +1 -1
  62. data/manual/docs/machinery-inspect.1.md +4 -1
  63. data/manual/docs/machinery-show.1.md +2 -2
  64. data/manual/docs/machinery_main_general.1.md +1 -1
  65. data/manual/docs/machinery_main_scopes.1.md +8 -6
  66. data/manual/site/machinery-analyze.1/index.html +3 -3
  67. data/manual/site/machinery-compare.1/index.html +2 -2
  68. data/manual/site/machinery-inspect-docker.1/index.html +1 -1
  69. data/manual/site/machinery-inspect.1/index.html +3 -1
  70. data/manual/site/machinery-show.1/index.html +2 -2
  71. data/manual/site/machinery_main_general.1/index.html +1 -1
  72. data/manual/site/machinery_main_scopes.1/index.html +8 -6
  73. data/manual/site/mkdocs/search_index.json +17 -17
  74. data/manual/site/sitemap.xml +23 -23
  75. data/plugins/{config_files/config_files.yml → changed_config_files/changed_config_files.yml} +3 -3
  76. data/plugins/{config_files/config_files_inspector.rb → changed_config_files/changed_config_files_inspector.rb} +14 -10
  77. data/plugins/{config_files/config_files_model.rb → changed_config_files/changed_config_files_model.rb} +1 -1
  78. data/plugins/{config_files/config_files_renderer.rb → changed_config_files/changed_config_files_renderer.rb} +9 -9
  79. data/plugins/{config_files/schema/system-description-config-files.schema-v1.json → changed_config_files/schema/system-description-changed-config-files.schema-v1.json} +0 -0
  80. data/plugins/{config_files/schema/system-description-config-files.schema-v2.json → changed_config_files/schema/system-description-changed-config-files.schema-v2.json} +0 -0
  81. data/plugins/{config_files/schema/system-description-config-files.schema-v3.json → changed_config_files/schema/system-description-changed-config-files.schema-v3.json} +0 -0
  82. data/plugins/{config_files/schema/system-description-config-files.schema-v4.json → changed_config_files/schema/system-description-changed-config-files.schema-v4.json} +0 -0
  83. data/plugins/{config_files/schema/system-description-config-files.schema-v5.json → changed_config_files/schema/system-description-changed-config-files.schema-v5.json} +0 -0
  84. data/plugins/{config_files/schema/system-description-config-files.schema-v6.json → changed_config_files/schema/system-description-changed-config-files.schema-v6.json} +0 -0
  85. data/plugins/{config_files/schema/system-description-config-files.schema-v7.json → changed_config_files/schema/system-description-changed-config-files.schema-v7.json} +0 -0
  86. data/plugins/changed_config_files/schema/system-description-changed-config-files.schema-v8.json +160 -0
  87. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +6 -2
  88. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +1 -1
  89. data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v8.json +160 -0
  90. data/plugins/environment/schema/system-description-environment.schema-v8.json +17 -0
  91. data/plugins/groups/groups_inspector.rb +1 -1
  92. data/plugins/groups/groups_renderer.rb +1 -1
  93. data/plugins/groups/schema/system-description-groups.schema-v8.json +49 -0
  94. data/plugins/os/os_inspector.rb +6 -6
  95. data/plugins/os/os_renderer.rb +1 -1
  96. data/plugins/os/schema/system-description-os.schema-v8.json +21 -0
  97. data/plugins/packages/packages_inspector.rb +1 -1
  98. data/plugins/packages/schema/system-description-packages.schema-v8.json +115 -0
  99. data/plugins/patterns/patterns.yml +5 -3
  100. data/plugins/patterns/patterns_inspector.rb +4 -3
  101. data/plugins/patterns/patterns_renderer.rb +5 -1
  102. data/plugins/patterns/schema/system-description-patterns.schema-v8.json +58 -0
  103. data/plugins/repositories/repositories_inspector.rb +2 -1
  104. data/plugins/repositories/schema/system-description-repositories.schema-v8.json +165 -0
  105. data/plugins/services/schema/system-description-services.schema-v8.json +93 -0
  106. data/plugins/services/services.yml +1 -1
  107. data/plugins/services/services_inspector.rb +1 -1
  108. data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v8.json +124 -0
  109. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +9 -4
  110. data/plugins/unmanaged_files/unmanaged_files_model.rb +12 -5
  111. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +1 -1
  112. data/plugins/users/schema/system-description-users.schema-v8.json +86 -0
  113. data/plugins/users/users_inspector.rb +7 -7
  114. data/schema/migrations/migrate1to2.rb +4 -4
  115. data/schema/migrations/migrate2to3.rb +1 -1
  116. data/schema/migrations/migrate3to4.rb +9 -9
  117. data/schema/migrations/migrate7to8.rb +47 -0
  118. data/schema/system-description-global.schema-v8.json +43 -0
  119. data/workload_mapper/rails/setup/setup.rb.erb +1 -1
  120. data/workload_mapper/wordpress/setup/setup.rb.erb +1 -1
  121. metadata +31 -17
  122. data/html/partials/compare/config_files.html.haml +0 -48
data/lib/cli.rb CHANGED
@@ -41,7 +41,7 @@ class Cli
41
41
  end
42
42
 
43
43
  post do |global_options,command,options,args|
44
- if command.is_a?(GLI::Commands::Help) && !global_options[:version] && ARGV == ["help"]
44
+ if (command.is_a?(GLI::Commands::Help) && !global_options[:version]) || ARGV == ["help"]
45
45
 
46
46
  Machinery::Ui.puts "\nFor more detailed information, open the documentation by typing " \
47
47
  "'machinery man --html'.\nIf you are unable to find a solution within the man page " \
@@ -168,7 +168,7 @@ class Cli
168
168
  end
169
169
 
170
170
  def self.shift_arg(args, name)
171
- if !res = args.shift
171
+ unless res = args.shift
172
172
  raise GLI::BadCommandLine.new("You need to provide the required argument #{name}.")
173
173
  end
174
174
  res
@@ -177,19 +177,19 @@ class Cli
177
177
  def self.process_scope_option(scopes, exclude_scopes)
178
178
  if scopes
179
179
  if exclude_scopes
180
- # scope and exclude-scope
180
+ # scope and ignore-scope
181
181
  raise Machinery::Errors::InvalidCommandLine.new("You cannot provide the --scope and " \
182
- "--exclude-scope option at the same time.")
182
+ "--ignore-scope option at the same time.")
183
183
  else
184
184
  # scope only
185
185
  scope_list = parse_scopes(scopes)
186
186
  end
187
187
  else
188
188
  if exclude_scopes
189
- # exclude-scope only
189
+ # ignore-scope only
190
190
  scope_list = Inspector.all_scopes - parse_scopes(exclude_scopes)
191
191
  else
192
- # neither scope nor exclude-scope
192
+ # neither scope nor ignore-scope
193
193
  scope_list = Inspector.all_scopes
194
194
  end
195
195
  end
@@ -205,11 +205,18 @@ class Cli
205
205
  scopes = []
206
206
 
207
207
  scope_string.split(",").each do |scope|
208
- if !(scope =~ /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/)
208
+ unless scope =~ /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/
209
209
  invalid_scopes << scope
210
210
  next
211
211
  end
212
212
 
213
+ if scope == "config-files"
214
+ Machinery::Ui.warn(
215
+ "The scope name `config-files` is deprecated. The new name is `changed-config-files`."
216
+ )
217
+ scope = "changed-config-files"
218
+ end
219
+
213
220
  # convert cli scope naming to internal one
214
221
  scope.tr!("-", "_")
215
222
 
@@ -271,28 +278,28 @@ class Cli
271
278
 
272
279
  The supported operations are:
273
280
 
274
- - config-file-diffs: Generate diffs against the original version from
275
- the package for the modified config files
281
+ - changed-config-files-diffs: Generate diffs against the original version from
282
+ the package for the changed configuration files
276
283
  LONGDESC
277
284
  arg "NAME"
278
285
  command "analyze" do |c|
279
286
  c.flag [:operation, :o], type: String, required: false,
280
- desc: "The analyze operation to perform", arg_name: "OPERATION", default_value: "config-file-diffs"
287
+ desc: "The analyze operation to perform", arg_name: "OPERATION", default_value: "changed-config-files-diffs"
281
288
 
282
289
  c.action do |global_options,options,args|
283
290
  name = shift_arg(args, "NAME")
284
291
  description = SystemDescription.load(name, system_description_store)
285
292
 
286
293
  case options[:operation]
287
- when "config-file-diffs"
288
- task = AnalyzeConfigFileDiffsTask.new
289
- task.analyze(description)
290
- Hint.print(:show_analyze_data, name: name)
291
- else
292
- raise Machinery::Errors::InvalidCommandLine.new(
293
- "The operation '#{options[:operation]}' is not supported. " \
294
- "Valid operations are: config-file-diffs."
295
- )
294
+ when "changed-config-files-diffs"
295
+ task = AnalyzeConfigFileDiffsTask.new
296
+ task.analyze(description)
297
+ Hint.print(:show_analyze_data, name: name)
298
+ else
299
+ raise Machinery::Errors::InvalidCommandLine.new(
300
+ "The operation '#{options[:operation]}' is not supported. " \
301
+ "Valid operations are: changed-config-files-diffs."
302
+ )
296
303
  end
297
304
  end
298
305
  end
@@ -341,7 +348,7 @@ class Cli
341
348
  command "compare" do |c|
342
349
  c.flag [:scope, :s], type: String, required: false,
343
350
  desc: "Compare specified scopes", arg_name: "SCOPE_LIST"
344
- c.flag ["exclude-scope", :e], type: String, required: false,
351
+ c.flag ["ignore-scope", :e], type: String, required: false,
345
352
  desc: "Exclude specified scopes", arg_name: "SCOPE_LIST"
346
353
  c.switch "show-all", required: false, negatable: false,
347
354
  desc: "Show also common properties"
@@ -368,7 +375,7 @@ class Cli
368
375
  store = system_description_store
369
376
  description1 = SystemDescription.load(name1, store)
370
377
  description2 = SystemDescription.load(name2, store)
371
- scope_list = process_scope_option(options[:scope], options["exclude-scope"])
378
+ scope_list = process_scope_option(options[:scope], options["ignore-scope"])
372
379
 
373
380
  task = CompareTask.new
374
381
  opts = {
@@ -511,7 +518,7 @@ class Cli
511
518
  desc: "Store system description under the specified name"
512
519
  c.flag [:scope, :s], type: String, required: false,
513
520
  desc: "Show specified scopes", arg_name: "SCOPE_LIST"
514
- c.flag ["exclude-scope", :e], type: String, required: false,
521
+ c.flag ["ignore-scope", :e], type: String, required: false,
515
522
  desc: "Exclude specified scopes", arg_name: "SCOPE_LIST"
516
523
  c.flag "skip-files", required: false, negatable: false,
517
524
  desc: "Do not consider given files or directories during inspection. " \
@@ -535,11 +542,11 @@ class Cli
535
542
  end
536
543
 
537
544
  def self.parse_inspect_command_options(host, options)
538
- scope_list = process_scope_option(options[:scope], options["exclude-scope"])
545
+ scope_list = process_scope_option(options[:scope], options["ignore-scope"])
539
546
  name = options[:name] || host
540
547
 
541
548
 
542
- if !scope_list.empty?
549
+ unless scope_list.empty?
543
550
  inspected_scopes = " for #{Machinery::Ui.internal_scope_list_to_string(scope_list)}"
544
551
  end
545
552
  Machinery::Ui.puts "Inspecting #{host}#{inspected_scopes}..."
@@ -552,7 +559,7 @@ class Cli
552
559
  inspect_options[:verbose] = true
553
560
  end
554
561
  if options["extract-files"] || options["extract-changed-config-files"]
555
- inspect_options[:extract_changed_config_files] = true
562
+ inspect_options[:extract_changed_changed_config_files] = true
556
563
  end
557
564
  if options["extract-files"] || options["extract-changed-managed-files"]
558
565
  inspect_options[:extract_changed_managed_files] = true
@@ -773,12 +780,12 @@ class Cli
773
780
  supports_filtering(c)
774
781
  c.flag [:scope, :s], type: String, required: false,
775
782
  desc: "Show specified scopes", arg_name: "SCOPE_LIST"
776
- c.flag ["exclude-scope", :e], type: String, required: false,
783
+ c.flag ["ignore-scope", :e], type: String, required: false,
777
784
  desc: "Exclude specified scopes", arg_name: "SCOPE_LIST"
778
785
  c.switch "pager", required: false, default_value: true,
779
786
  desc: "Pipe output into a pager"
780
787
  c.switch "show-diffs", required: false, negatable: false,
781
- desc: "Show diffs of configuration files changes."
788
+ desc: "Show diffs of changed configuration files changes."
782
789
  c.switch "html", required: false, negatable: false,
783
790
  desc: "Open system description in HTML format in your web browser."
784
791
  c.switch "verbose", required: false, negatable: false,
@@ -802,7 +809,7 @@ class Cli
802
809
  end
803
810
 
804
811
  description = SystemDescription.load(name, system_description_store)
805
- scope_list = process_scope_option(options[:scope], options["exclude-scope"])
812
+ scope_list = process_scope_option(options[:scope], options["ignore-scope"])
806
813
 
807
814
  filter = FilterOptionParser.parse("show", options)
808
815
 
@@ -815,12 +822,12 @@ class Cli
815
822
  details += "\n Type of inspected container: #{description[:environment].system_type}\n"
816
823
  end
817
824
 
818
- if !inspected_filters.empty?
825
+ unless inspected_filters.empty?
819
826
  details += "\n The following filters were applied during inspection:"
820
827
  details += "\n * " + inspected_filters.join("\n * ") + "\n\n"
821
828
  end
822
829
 
823
- if !filter.empty?
830
+ unless filter.empty?
824
831
  details += "\n The following filters were applied before showing the description:"
825
832
  details += "\n * " + filter.to_array.join("\n * ") + "\n\n"
826
833
  end
@@ -869,7 +876,7 @@ class Cli
869
876
  desc: "Keep backup after migration and ingnore validation errors"
870
877
 
871
878
  c.action do |global_options,options,args|
872
- name = shift_arg(args, "NAME") if !options[:all]
879
+ name = shift_arg(args, "NAME") unless options[:all]
873
880
 
874
881
  task = UpgradeFormatTask.new
875
882
  task.upgrade(
@@ -968,7 +975,7 @@ class Cli
968
975
  end
969
976
 
970
977
  def self.system_description_store
971
- if ENV.has_key?("MACHINERY_DIR")
978
+ if ENV.key?("MACHINERY_DIR")
972
979
  SystemDescriptionStore.new(ENV["MACHINERY_DIR"])
973
980
  else
974
981
  SystemDescriptionStore.new
data/lib/compare_task.rb CHANGED
@@ -74,7 +74,7 @@ EOF
74
74
  output = "\n" + output unless output.empty?
75
75
  output = "Compared descriptions are identical." + output
76
76
  elsif !identical_scopes.empty?
77
- phrase = Machinery::pluralize(identical_scopes.count, "scope is", "scopes are")
77
+ phrase = Machinery.pluralize(identical_scopes.count, "scope is", "scopes are")
78
78
  output += "Following #{phrase} identical in both descriptions: " + identical_scopes.join(",")
79
79
  end
80
80
 
data/lib/config_base.rb CHANGED
@@ -29,7 +29,7 @@ class ConfigBase
29
29
  apply_custom_config(@file) if File.exist?(@file)
30
30
  end
31
31
 
32
- abstract_method :default_config_files
32
+ abstract_method :default_changed_config_files
33
33
 
34
34
  abstract_method :define_entries
35
35
  abstract_method :deprecated_entries
data/lib/deploy_task.rb CHANGED
@@ -21,14 +21,14 @@ class DeployTask
21
21
  LocalSystem.validate_existence_of_packages(["python-glanceclient", "kiwi", "kiwi-desc-vmxboot"])
22
22
  description.validate_build_compatibility
23
23
 
24
- if !File.exists?(cloud_config)
24
+ unless File.exist?(cloud_config)
25
25
  raise(Machinery::Errors::DeployFailed,
26
26
  "The cloud config file '#{cloud_config}' could not be found."
27
27
  )
28
28
  end
29
29
 
30
30
  if options[:image_dir]
31
- if !Dir.exists?(options[:image_dir])
31
+ unless Dir.exist?(options[:image_dir])
32
32
  raise(Machinery::Errors::DeployFailed,
33
33
  "The image directory does not exist."
34
34
  )
@@ -50,7 +50,7 @@ class DeployTask
50
50
  )
51
51
  end
52
52
 
53
- if !File.exists?(image_file)
53
+ unless File.exist?(image_file)
54
54
  raise(Machinery::Errors::DeployFailed,
55
55
  "The image file '#{image_file}' does not exist."
56
56
  )
@@ -74,7 +74,7 @@ class DeployTask
74
74
 
75
75
  def load_meta_data(meta_dir)
76
76
  meta_file = File.join(meta_dir, Machinery::IMAGE_META_DATA_FILE)
77
- if !File.exists?(meta_file)
77
+ unless File.exist?(meta_file)
78
78
  raise(Machinery::Errors::DeployFailed,
79
79
  "The meta data file '#{meta_file}' could not be found."
80
80
  )
data/lib/docker_system.rb CHANGED
@@ -92,7 +92,7 @@ class DockerSystem < System
92
92
 
93
93
  # Retrieves files specified in file_list from the container and creates an archive.
94
94
  def create_archive(file_list, archive, exclude = [])
95
- created = !File.exists?(archive)
95
+ created = !File.exist?(archive)
96
96
  out = File.open(archive, "w")
97
97
  begin
98
98
  helper = MachineryHelper.new(self)
@@ -22,7 +22,7 @@ class ElementFilter
22
22
  @path = path
23
23
  @matchers = {}
24
24
 
25
- if ![NilClass, String, Array].include?(matchers.class)
25
+ unless [NilClass, String, Array].include?(matchers.class)
26
26
  raise Machinery::Errors::InvalidFilter.new("Wrong filter type")
27
27
  end
28
28
 
@@ -34,7 +34,7 @@ class ElementFilter
34
34
  end
35
35
 
36
36
  def add_matchers(operator, matchers)
37
- if ![Filter::OPERATOR_EQUALS, Filter::OPERATOR_EQUALS_NOT].include?(operator)
37
+ unless [Filter::OPERATOR_EQUALS, Filter::OPERATOR_EQUALS_NOT].include?(operator)
38
38
  raise Machinery::Errors::InvalidFilter.new("Wrong filter operator '#{operator}'")
39
39
  end
40
40
 
@@ -69,7 +69,7 @@ class ElementFilter
69
69
  if operator == Filter::OPERATOR_EQUALS
70
70
  return true if values_equal
71
71
  elsif operator == Filter::OPERATOR_EQUALS_NOT
72
- return true if !values_equal
72
+ return true unless values_equal
73
73
  end
74
74
  end
75
75
  end
data/lib/export_task.rb CHANGED
@@ -23,7 +23,7 @@ class ExportTask
23
23
  def export(output_dir, options)
24
24
  @exporter.system_description.assert_scopes("os")
25
25
 
26
- ["unmanaged_files", "changed_managed_files", "config_files"].each do |scope|
26
+ ["unmanaged_files", "changed_managed_files", "changed_config_files"].each do |scope|
27
27
  if @exporter.system_description[scope] &&
28
28
  !@exporter.system_description.scope_extracted?(scope)
29
29
  raise Machinery::Errors::MissingExtractedFiles.new(@exporter.system_description, [scope])
@@ -31,7 +31,7 @@ class ExportTask
31
31
  end
32
32
 
33
33
  output_dir = File.join(output_dir, @exporter.export_name)
34
- if File.exists?(output_dir)
34
+ if File.exist?(output_dir)
35
35
  if options[:force]
36
36
  FileUtils.rm_r(output_dir)
37
37
  else
@@ -43,7 +43,7 @@ class ExportTask
43
43
  end
44
44
 
45
45
  begin
46
- FileUtils.mkdir_p(output_dir, mode: 0700) if !Dir.exists?(output_dir)
46
+ FileUtils.mkdir_p(output_dir, mode: 0700) unless Dir.exist?(output_dir)
47
47
  rescue Errno::EACCES
48
48
  raise(Machinery::Errors::ExportFailed, \
49
49
  "Permission denied. Directory '#{output_dir}' is not writable")
@@ -22,7 +22,7 @@ class FileValidator
22
22
 
23
23
  @format_version = @json_hash["meta"]["format_version"] if @json_hash["meta"]
24
24
 
25
- if !@format_version
25
+ unless @format_version
26
26
  raise Machinery::Errors::SystemDescriptionValidationFailed.new(
27
27
  ["Could not determine format version"]
28
28
  )
@@ -32,13 +32,16 @@ class FileValidator
32
32
  def validate
33
33
  errors = []
34
34
 
35
- ["config_files", "changed_managed_files", "unmanaged_files"].each do |scope|
36
- next if !scope_extracted?(scope)
35
+ # the deprecated config_files is still needed to be able to validate older descriptions
36
+ [
37
+ "changed_config_files", "config_files", "changed_managed_files", "unmanaged_files"
38
+ ].each do |scope|
39
+ next unless scope_extracted?(scope)
37
40
 
38
41
  expected_files = expected_files(scope)
39
42
  file_errors = validate_scope(ScopeFileStore.new(@base_path, scope.to_s), expected_files)
40
43
 
41
- errors << "Scope '#{scope}':\n" + file_errors.join("\n") if !file_errors.empty?
44
+ errors << "Scope '#{scope}':\n" + file_errors.join("\n") unless file_errors.empty?
42
45
  end
43
46
 
44
47
  errors
@@ -94,7 +97,7 @@ class FileValidator
94
97
  end
95
98
 
96
99
  def missing_files(file_list)
97
- file_list.select { |file| !File.exists?(file) }
100
+ file_list.select { |file| !File.exist?(file) }
98
101
  end
99
102
 
100
103
  def additional_files(file_list, file_store)
data/lib/filter.rb CHANGED
@@ -54,7 +54,7 @@ class Filter
54
54
  Array(filter_definitions).each do |definition|
55
55
  path, operator, matcher_definition = definition.scan(/([a-zA-Z_\/]+)(.*=)(.*)/)[0]
56
56
 
57
- raise Machinery::Errors::InvalidFilter.new("Invalid filter: '#{definition}'") if !operator
57
+ raise Machinery::Errors::InvalidFilter.new("Invalid filter: '#{definition}'") unless operator
58
58
  element_filters[path] ||= ElementFilter.new(path)
59
59
  if matcher_definition.index(",")
60
60
  matchers = matcher_definition.split(/(?<!\\),/)
@@ -73,7 +73,7 @@ class Filter
73
73
  filter = Filter.new
74
74
 
75
75
  default_filters_file = File.join(Machinery::ROOT, "filters", "default_filters.json")
76
- if File.exists?(default_filters_file)
76
+ if File.exist?(default_filters_file)
77
77
  default_filters = JSON.parse(File.read(default_filters_file))
78
78
  if default_filters[command]
79
79
  default_filters[command].each do |definition|
@@ -134,7 +134,7 @@ class Filter
134
134
 
135
135
  def matches?(path, value)
136
136
  filter = element_filter_for(path)
137
- return false if !filter
137
+ return false unless filter
138
138
 
139
139
  filter.matches?(value)
140
140
  end
@@ -147,12 +147,12 @@ class Filter
147
147
  pointer = system_description
148
148
  container = nil
149
149
  steps.each do |step|
150
- break if !pointer
150
+ break unless pointer
151
151
  pointer = pointer[step]
152
152
  container ||= pointer if pointer.is_a?(Machinery::Array)
153
153
  end
154
154
 
155
- next if !pointer
155
+ next unless pointer
156
156
 
157
157
  begin
158
158
  pointer.delete_if do |element|
@@ -36,7 +36,7 @@ class FilterOptionParser
36
36
  private
37
37
 
38
38
  def exclude_definitions(exclude)
39
- return [] if !exclude
39
+ return [] unless exclude
40
40
 
41
41
  filters = if exclude.start_with?("@")
42
42
  expand_filter_file(exclude)
@@ -49,7 +49,7 @@ class FilterOptionParser
49
49
  end
50
50
 
51
51
  def skip_files_definitions(skip_files)
52
- return [] if !skip_files
52
+ return [] unless skip_files
53
53
 
54
54
  files = skip_files.split(/(?<!\\),/) # Do not split on escaped commas
55
55
  files = files.flat_map do |file|
@@ -69,7 +69,7 @@ class FilterOptionParser
69
69
  def expand_filter_file(path)
70
70
  filename = File.expand_path(path[1..-1])
71
71
 
72
- if !File.exists?(filename)
72
+ unless File.exist?(filename)
73
73
  raise Machinery::Errors::MachineryError.new(
74
74
  "The filter file '#{filename}' does not exist."
75
75
  )
data/lib/hint.rb CHANGED
@@ -18,13 +18,13 @@
18
18
  class Hint
19
19
  class << self
20
20
  def print(method, options = {})
21
- return if !Machinery::Config.new.hints
21
+ return unless Machinery::Config.new.hints
22
22
 
23
23
  Machinery::Ui.puts to_string(method, options)
24
24
  end
25
25
 
26
26
  def to_string(method, options = {})
27
- return "" if !Machinery::Config.new.hints
27
+ return "" unless Machinery::Config.new.hints
28
28
 
29
29
  "\nHint: #{send(method, options)}\n"
30
30
  end
@@ -41,10 +41,15 @@ class Hint
41
41
 
42
42
  def which_machinery
43
43
  `which machinery 2>/dev/null`.chomp
44
+ rescue Errno::EPIPE => e
45
+ Machinery.logger.debug "Command `which machinery 2>/dev/null` crashed. " \
46
+ "Error was #{e.class}: #{e}"
44
47
  end
45
48
 
46
49
  def get_started(_options)
47
- "You can get started by inspecting a system. Run:\n#{program_name} inspect HOSTNAME"
50
+ "You can get started by inspecting a system. Run:\n'#{program_name} inspect HOSTNAME'\n" \
51
+ "To inspect a system as a user with sudo rights instead of root run:\n" \
52
+ "'#{program_name} inspect --remote-user USER HOSTNAME'"
48
53
  end
49
54
 
50
55
  def upgrade_format_force(options)
@@ -58,7 +63,7 @@ class Hint
58
63
 
59
64
  def show_analyze_data(options)
60
65
  "To show the config file diffs you just created run:\n" \
61
- "#{program_name} show --scope config-files --show-diffs #{options[:name]}"
66
+ "#{program_name} show --scope changed-config-files --show-diffs #{options[:name]}"
62
67
  end
63
68
 
64
69
  def do_complete_inspection(options)