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.
- checksums.yaml +4 -4
- data/.git_revision +1 -1
- data/NEWS +17 -0
- data/bin/machinery +10 -2
- data/html/comparison.html.haml +1 -1
- data/html/index.html.haml +2 -2
- data/html/partials/{config_files.html.haml → changed_config_files.html.haml} +10 -10
- data/html/partials/compare/changed_config_files.html.haml +48 -0
- data/html/partials/compare/{config_file_list.html.haml → changed_config_files_list.html.haml} +0 -0
- data/html/partials/compare/unmanaged_file_list.html.haml +1 -1
- data/html/partials/compare/unmanaged_files.html.haml +2 -2
- data/html/partials/patterns.html.haml +5 -0
- data/html/upgrade.html.haml +49 -0
- data/lib/{analyze_config_file_diffs_task.rb → analyze_changed_config_files_diffs_task.rb} +8 -8
- data/lib/autoyast.rb +12 -13
- data/lib/build_task.rb +2 -2
- data/lib/cli.rb +39 -32
- data/lib/compare_task.rb +1 -1
- data/lib/config_base.rb +1 -1
- data/lib/deploy_task.rb +4 -4
- data/lib/docker_system.rb +1 -1
- data/lib/element_filter.rb +3 -3
- data/lib/export_task.rb +3 -3
- data/lib/file_validator.rb +8 -5
- data/lib/filter.rb +5 -5
- data/lib/filter_option_parser.rb +3 -3
- data/lib/hint.rb +9 -4
- data/lib/html.rb +3 -3
- data/lib/inspect_task.rb +3 -3
- data/lib/json_schema_monkey_patch.rb +2 -2
- data/lib/json_validation_error_cleaner.rb +1 -1
- data/lib/json_validator.rb +2 -2
- data/lib/kiwi_config.rb +39 -14
- data/lib/list_task.rb +1 -1
- data/lib/local_system.rb +4 -4
- data/lib/machinery.rb +1 -1
- data/lib/machinery_logger.rb +4 -4
- data/lib/manifest.rb +5 -5
- data/lib/migration.rb +4 -4
- data/lib/object.rb +6 -10
- data/lib/remove_task.rb +1 -1
- data/lib/renderer.rb +5 -5
- data/lib/scope_file_access_archive.rb +2 -2
- data/lib/scope_file_access_flat.rb +3 -3
- data/lib/scope_file_store.rb +3 -3
- data/lib/serve_html_task.rb +15 -2
- data/lib/server.rb +32 -12
- data/lib/system.rb +1 -1
- data/lib/system_description.rb +16 -14
- data/lib/system_description_store.rb +5 -6
- data/lib/ui.rb +1 -1
- data/lib/upgrade_format_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/workload_mapper.rb +11 -11
- data/lib/zypper.rb +1 -1
- data/machinery-helper/Rakefile +1 -1
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/manual/docs/machinery-analyze.1.md +3 -3
- data/manual/docs/machinery-compare.1.md +2 -2
- data/manual/docs/machinery-inspect-docker.1.md +1 -1
- data/manual/docs/machinery-inspect.1.md +4 -1
- data/manual/docs/machinery-show.1.md +2 -2
- data/manual/docs/machinery_main_general.1.md +1 -1
- data/manual/docs/machinery_main_scopes.1.md +8 -6
- data/manual/site/machinery-analyze.1/index.html +3 -3
- data/manual/site/machinery-compare.1/index.html +2 -2
- data/manual/site/machinery-inspect-docker.1/index.html +1 -1
- data/manual/site/machinery-inspect.1/index.html +3 -1
- data/manual/site/machinery-show.1/index.html +2 -2
- data/manual/site/machinery_main_general.1/index.html +1 -1
- data/manual/site/machinery_main_scopes.1/index.html +8 -6
- data/manual/site/mkdocs/search_index.json +17 -17
- data/manual/site/sitemap.xml +23 -23
- data/plugins/{config_files/config_files.yml → changed_config_files/changed_config_files.yml} +3 -3
- data/plugins/{config_files/config_files_inspector.rb → changed_config_files/changed_config_files_inspector.rb} +14 -10
- data/plugins/{config_files/config_files_model.rb → changed_config_files/changed_config_files_model.rb} +1 -1
- data/plugins/{config_files/config_files_renderer.rb → changed_config_files/changed_config_files_renderer.rb} +9 -9
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- data/plugins/changed_config_files/schema/system-description-changed-config-files.schema-v8.json +160 -0
- data/plugins/changed_managed_files/changed_managed_files_inspector.rb +6 -2
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +1 -1
- data/plugins/changed_managed_files/schema/system-description-changed-managed-files.schema-v8.json +160 -0
- data/plugins/environment/schema/system-description-environment.schema-v8.json +17 -0
- data/plugins/groups/groups_inspector.rb +1 -1
- data/plugins/groups/groups_renderer.rb +1 -1
- data/plugins/groups/schema/system-description-groups.schema-v8.json +49 -0
- data/plugins/os/os_inspector.rb +6 -6
- data/plugins/os/os_renderer.rb +1 -1
- data/plugins/os/schema/system-description-os.schema-v8.json +21 -0
- data/plugins/packages/packages_inspector.rb +1 -1
- data/plugins/packages/schema/system-description-packages.schema-v8.json +115 -0
- data/plugins/patterns/patterns.yml +5 -3
- data/plugins/patterns/patterns_inspector.rb +4 -3
- data/plugins/patterns/patterns_renderer.rb +5 -1
- data/plugins/patterns/schema/system-description-patterns.schema-v8.json +58 -0
- data/plugins/repositories/repositories_inspector.rb +2 -1
- data/plugins/repositories/schema/system-description-repositories.schema-v8.json +165 -0
- data/plugins/services/schema/system-description-services.schema-v8.json +93 -0
- data/plugins/services/services.yml +1 -1
- data/plugins/services/services_inspector.rb +1 -1
- data/plugins/unmanaged_files/schema/system-description-unmanaged-files.schema-v8.json +124 -0
- data/plugins/unmanaged_files/unmanaged_files_inspector.rb +9 -4
- data/plugins/unmanaged_files/unmanaged_files_model.rb +12 -5
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +1 -1
- data/plugins/users/schema/system-description-users.schema-v8.json +86 -0
- data/plugins/users/users_inspector.rb +7 -7
- data/schema/migrations/migrate1to2.rb +4 -4
- data/schema/migrations/migrate2to3.rb +1 -1
- data/schema/migrations/migrate3to4.rb +9 -9
- data/schema/migrations/migrate7to8.rb +47 -0
- data/schema/system-description-global.schema-v8.json +43 -0
- data/workload_mapper/rails/setup/setup.rb.erb +1 -1
- data/workload_mapper/wordpress/setup/setup.rb.erb +1 -1
- metadata +31 -17
- 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]
|
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
|
-
|
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
|
180
|
+
# scope and ignore-scope
|
181
181
|
raise Machinery::Errors::InvalidCommandLine.new("You cannot provide the --scope and " \
|
182
|
-
"--
|
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
|
-
#
|
189
|
+
# ignore-scope only
|
190
190
|
scope_list = Inspector.all_scopes - parse_scopes(exclude_scopes)
|
191
191
|
else
|
192
|
-
# neither scope nor
|
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
|
-
|
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-
|
275
|
-
the package for the
|
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-
|
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
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
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 ["
|
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["
|
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 ["
|
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["
|
545
|
+
scope_list = process_scope_option(options[:scope], options["ignore-scope"])
|
539
546
|
name = options[:name] || host
|
540
547
|
|
541
548
|
|
542
|
-
|
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[:
|
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 ["
|
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["
|
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
|
-
|
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
|
-
|
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")
|
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.
|
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
|
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
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
95
|
+
created = !File.exist?(archive)
|
96
96
|
out = File.open(archive, "w")
|
97
97
|
begin
|
98
98
|
helper = MachineryHelper.new(self)
|
data/lib/element_filter.rb
CHANGED
@@ -22,7 +22,7 @@ class ElementFilter
|
|
22
22
|
@path = path
|
23
23
|
@matchers = {}
|
24
24
|
|
25
|
-
|
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
|
-
|
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
|
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", "
|
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.
|
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)
|
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")
|
data/lib/file_validator.rb
CHANGED
@@ -22,7 +22,7 @@ class FileValidator
|
|
22
22
|
|
23
23
|
@format_version = @json_hash["meta"]["format_version"] if @json_hash["meta"]
|
24
24
|
|
25
|
-
|
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
|
-
|
36
|
-
|
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")
|
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.
|
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}'")
|
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.
|
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
|
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
|
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
|
155
|
+
next unless pointer
|
156
156
|
|
157
157
|
begin
|
158
158
|
pointer.delete_if do |element|
|
data/lib/filter_option_parser.rb
CHANGED
@@ -36,7 +36,7 @@ class FilterOptionParser
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def exclude_definitions(exclude)
|
39
|
-
return []
|
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 []
|
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
|
-
|
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
|
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 ""
|
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)
|