machinery-tool 1.22.1 → 1.22.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.git_revision +1 -1
  3. data/NEWS +10 -0
  4. data/bin/machinery +1 -1
  5. data/lib/analyze_changed_config_files_diffs_task.rb +6 -6
  6. data/lib/autoyast.rb +2 -2
  7. data/lib/build_task.rb +10 -7
  8. data/lib/cli.rb +1005 -801
  9. data/lib/compare_task.rb +11 -7
  10. data/lib/comparison.rb +2 -2
  11. data/lib/config_base.rb +1 -1
  12. data/lib/config_task.rb +1 -1
  13. data/lib/containerize_task.rb +3 -3
  14. data/lib/containerized_app.rb +1 -1
  15. data/lib/copy_task.rb +1 -1
  16. data/lib/current_user.rb +1 -1
  17. data/lib/deploy_task.rb +6 -4
  18. data/lib/diff_widget.rb +67 -63
  19. data/lib/docker_system.rb +12 -8
  20. data/lib/dpkg_database.rb +1 -1
  21. data/lib/element_filter.rb +7 -4
  22. data/lib/exceptions.rb +23 -5
  23. data/lib/export_task.rb +1 -1
  24. data/lib/exporter.rb +1 -1
  25. data/lib/file_diff.rb +1 -1
  26. data/lib/file_scope.rb +1 -1
  27. data/lib/file_validator.rb +7 -4
  28. data/lib/filter.rb +97 -93
  29. data/lib/filter_option_parser.rb +2 -2
  30. data/lib/hint.rb +64 -59
  31. data/lib/html.rb +1 -1
  32. data/lib/inspect_task.rb +12 -12
  33. data/lib/inspector.rb +3 -3
  34. data/lib/json_validation_error_cleaner.rb +1 -1
  35. data/lib/json_validator.rb +4 -4
  36. data/lib/kiwi_config.rb +8 -4
  37. data/lib/list_task.rb +10 -9
  38. data/lib/local_system.rb +11 -5
  39. data/lib/logged_cheetah.rb +1 -1
  40. data/lib/man_task.rb +10 -6
  41. data/lib/managed_files_database.rb +1 -1
  42. data/lib/manifest.rb +5 -5
  43. data/lib/migration.rb +16 -10
  44. data/lib/mountpoints.rb +1 -1
  45. data/lib/move_task.rb +1 -1
  46. data/lib/remote_system.rb +7 -7
  47. data/lib/remove_task.rb +1 -1
  48. data/lib/renderer.rb +177 -172
  49. data/lib/rpm.rb +4 -4
  50. data/lib/rpm_database.rb +1 -1
  51. data/lib/scope.rb +2 -2
  52. data/lib/scope_file_access_archive.rb +1 -1
  53. data/lib/scope_file_access_flat.rb +1 -1
  54. data/lib/scope_file_store.rb +1 -1
  55. data/lib/serve_html_task.rb +6 -2
  56. data/lib/server.rb +19 -12
  57. data/lib/show_task.rb +10 -6
  58. data/lib/static_html.rb +1 -1
  59. data/lib/system.rb +10 -10
  60. data/lib/system_description.rb +14 -13
  61. data/lib/system_description_memory_store.rb +1 -1
  62. data/lib/system_description_store.rb +9 -9
  63. data/lib/tarball.rb +8 -2
  64. data/lib/upgrade_format_task.rb +11 -6
  65. data/lib/validate_task.rb +2 -2
  66. data/lib/version.rb +1 -1
  67. data/lib/workload_mapper.rb +2 -2
  68. data/lib/workload_mapper_dsl.rb +1 -1
  69. data/lib/zypper.rb +40 -17
  70. data/machinery-helper/machinery_helper.go +35 -16
  71. data/machinery-helper/version.go +1 -1
  72. data/man/generated/machinery.1.gz +0 -0
  73. data/manual/site/sitemap.xml +24 -24
  74. data/plugins/changed_config_files/changed_config_files_inspector.rb +59 -56
  75. data/plugins/changed_config_files/changed_config_files_model.rb +23 -21
  76. data/plugins/changed_config_files/changed_config_files_renderer.rb +56 -52
  77. data/plugins/changed_managed_files/changed_managed_files_inspector.rb +52 -50
  78. data/plugins/changed_managed_files/changed_managed_files_model.rb +23 -21
  79. data/plugins/changed_managed_files/changed_managed_files_renderer.rb +43 -39
  80. data/plugins/environment/environment_inspector.rb +25 -23
  81. data/plugins/environment/environment_model.rb +5 -3
  82. data/plugins/groups/groups_inspector.rb +30 -28
  83. data/plugins/groups/groups_model.rb +18 -17
  84. data/plugins/groups/groups_renderer.rb +29 -25
  85. data/plugins/os/os_inspector.rb +120 -118
  86. data/plugins/os/os_model.rb +139 -134
  87. data/plugins/os/os_renderer.rb +13 -9
  88. data/plugins/packages/packages_inspector.rb +99 -86
  89. data/plugins/packages/packages_model.rb +35 -34
  90. data/plugins/packages/packages_renderer.rb +47 -39
  91. data/plugins/patterns/patterns_inspector.rb +70 -68
  92. data/plugins/patterns/patterns_model.rb +19 -18
  93. data/plugins/patterns/patterns_renderer.rb +36 -32
  94. data/plugins/repositories/repositories_inspector.rb +162 -156
  95. data/plugins/repositories/repositories_model.rb +50 -49
  96. data/plugins/repositories/repositories_renderer.rb +48 -44
  97. data/plugins/repositories/schema/system-description-repositories.schema-v10.json +0 -1
  98. data/plugins/services/services_inspector.rb +187 -176
  99. data/plugins/services/services_model.rb +37 -36
  100. data/plugins/services/services_renderer.rb +28 -24
  101. data/plugins/unmanaged_files/unmanaged_files_inspector.rb +102 -99
  102. data/plugins/unmanaged_files/unmanaged_files_model.rb +64 -56
  103. data/plugins/unmanaged_files/unmanaged_files_renderer.rb +44 -40
  104. data/plugins/users/users_inspector.rb +67 -65
  105. data/plugins/users/users_model.rb +37 -36
  106. data/plugins/users/users_renderer.rb +31 -27
  107. data/schema/migrations/migrate1to2.rb +1 -1
  108. data/schema/migrations/migrate2to3.rb +1 -1
  109. data/schema/migrations/migrate3to4.rb +1 -1
  110. data/schema/migrations/migrate4to5.rb +1 -1
  111. data/schema/migrations/migrate5to6.rb +1 -1
  112. data/schema/migrations/migrate6to7.rb +1 -1
  113. data/schema/migrations/migrate7to8.rb +1 -1
  114. data/schema/migrations/migrate8to9.rb +1 -1
  115. data/schema/migrations/migrate9to10.rb +1 -1
  116. metadata +2 -2
data/lib/export_task.rb CHANGED
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class ExportTask
18
+ class Machinery::ExportTask
19
19
  def initialize(exporter)
20
20
  @exporter = exporter
21
21
  end
data/lib/exporter.rb CHANGED
@@ -16,7 +16,7 @@
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
18
  # Interface class for exporter
19
- class Exporter
19
+ class Machinery::Exporter
20
20
  attr_reader :system_description
21
21
 
22
22
  abstract_method :write
data/lib/file_diff.rb CHANGED
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class FileDiff
18
+ class Machinery::FileDiff
19
19
  def self.diff(description1, description2, scope, path)
20
20
  return nil if !description1.scope_extracted?(scope) || !description2.scope_extracted?(scope)
21
21
 
data/lib/file_scope.rb CHANGED
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class FileScope < Machinery::Array
18
+ class Machinery::FileScope < Machinery::Array
19
19
  def compare_with(other)
20
20
  only_self, only_other, changed, common = super(other)
21
21
 
@@ -15,7 +15,7 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class FileValidator
18
+ class Machinery::FileValidator
19
19
  def initialize(json_hash, base_path)
20
20
  @json_hash = json_hash
21
21
  @base_path = base_path
@@ -39,7 +39,10 @@ class FileValidator
39
39
  next unless scope_extracted?(scope)
40
40
 
41
41
  expected_files = expected_files(scope)
42
- file_errors = validate_scope(ScopeFileStore.new(@base_path, scope.to_s), expected_files)
42
+ file_errors = validate_scope(
43
+ Machinery::ScopeFileStore.new(@base_path, scope.to_s),
44
+ expected_files
45
+ )
43
46
 
44
47
  errors << "Scope '#{scope}':\n" + file_errors.join("\n") unless file_errors.empty?
45
48
  end
@@ -58,7 +61,7 @@ class FileValidator
58
61
 
59
62
  def scope_extracted?(scope)
60
63
  if @format_version == 1
61
- @json_hash[scope] && ScopeFileStore.new(@base_path, scope.to_s).path
64
+ @json_hash[scope] && Machinery::ScopeFileStore.new(@base_path, scope.to_s).path
62
65
  elsif @format_version < 6
63
66
  @json_hash[scope] && @json_hash[scope]["extracted"]
64
67
  else
@@ -92,7 +95,7 @@ class FileValidator
92
95
  end.map { |file| file["name"] }
93
96
  end
94
97
 
95
- store_base_path = ScopeFileStore.new(@base_path, scope.to_s).path
98
+ store_base_path = Machinery::ScopeFileStore.new(@base_path, scope.to_s).path
96
99
  expected_files.map { |file| File.join(store_base_path, file) }
97
100
  end
98
101
 
data/lib/filter.rb CHANGED
@@ -43,129 +43,133 @@
43
43
  #
44
44
  # More details about how the filter work can be found at
45
45
  # https://github.com/SUSE/machinery/blob/master/docs/Filtering-Design.md
46
- class Filter
47
- attr_accessor :element_filters
48
-
49
- OPERATOR_EQUALS = "="
50
- OPERATOR_EQUALS_NOT = "!="
51
-
52
- def self.parse_filter_definitions(filter_definitions)
53
- element_filters = {}
54
- Array(filter_definitions).each do |definition|
55
- path, operator, matcher_definition = definition.scan(/([a-zA-Z_\/]+)(.*=)(.*)/)[0]
56
-
57
- raise Machinery::Errors::InvalidFilter.new("Invalid filter: '#{definition}'") unless operator
58
- element_filters[path] ||= ElementFilter.new(path)
59
- if matcher_definition.index(",")
60
- matchers = matcher_definition.split(/(?<!\\),/)
61
- matchers.map! { |matcher| matcher.gsub("\\,", ",") } # Unescape escaped commas
62
-
63
- element_filters[path].add_matchers(operator, [matchers])
64
- else
65
- element_filters[path].add_matchers(operator, matcher_definition)
46
+ module Machinery
47
+ class Filter
48
+ attr_accessor :element_filters
49
+
50
+ OPERATOR_EQUALS = "=".freeze
51
+ OPERATOR_EQUALS_NOT = "!=".freeze
52
+
53
+ def self.parse_filter_definitions(filter_definitions)
54
+ element_filters = {}
55
+ Array(filter_definitions).each do |definition|
56
+ path, operator, matcher_definition = definition.scan(/([a-zA-Z_\/]+)(.*=)(.*)/)[0]
57
+
58
+ raise Machinery::Errors::InvalidFilter.new(
59
+ "Invalid filter: '#{definition}'"
60
+ ) unless operator
61
+ element_filters[path] ||= ElementFilter.new(path)
62
+ if matcher_definition.index(",")
63
+ matchers = matcher_definition.split(/(?<!\\),/)
64
+ matchers.map! { |matcher| matcher.gsub("\\,", ",") } # Unescape escaped commas
65
+
66
+ element_filters[path].add_matchers(operator, [matchers])
67
+ else
68
+ element_filters[path].add_matchers(operator, matcher_definition)
69
+ end
66
70
  end
67
- end
68
71
 
69
- element_filters
70
- end
72
+ element_filters
73
+ end
71
74
 
72
- def self.from_default_definition(command)
73
- filter = Filter.new
75
+ def self.from_default_definition(command)
76
+ filter = Filter.new
74
77
 
75
- default_filters_file = File.join(Machinery::ROOT, "filters", "default_filters.json")
76
- if File.exist?(default_filters_file)
77
- default_filters = JSON.parse(File.read(default_filters_file))
78
- if default_filters[command]
79
- default_filters[command].each do |definition|
80
- filter.add_element_filter_from_definition(definition)
78
+ default_filters_file = File.join(Machinery::ROOT, "filters", "default_filters.json")
79
+ if File.exist?(default_filters_file)
80
+ default_filters = JSON.parse(File.read(default_filters_file))
81
+ if default_filters[command]
82
+ default_filters[command].each do |definition|
83
+ filter.add_element_filter_from_definition(definition)
84
+ end
81
85
  end
82
86
  end
83
- end
84
87
 
85
- filter
86
- end
88
+ filter
89
+ end
87
90
 
88
- def initialize(definitions = [])
89
- @element_filters = Filter.parse_filter_definitions(definitions)
90
- end
91
+ def initialize(definitions = [])
92
+ @element_filters = Filter.parse_filter_definitions(definitions)
93
+ end
91
94
 
92
- def add_element_filter_from_definition(filter_definition)
93
- add_element_filters(Filter.parse_filter_definitions(filter_definition).values)
94
- end
95
+ def add_element_filter_from_definition(filter_definition)
96
+ add_element_filters(Filter.parse_filter_definitions(filter_definition).values)
97
+ end
95
98
 
96
- def add_element_filters(element_filters)
97
- Array(element_filters).each do |element_filter|
98
- path = element_filter.path
99
- @element_filters[path] ||= ElementFilter.new(path)
99
+ def add_element_filters(element_filters)
100
+ Array(element_filters).each do |element_filter|
101
+ path = element_filter.path
102
+ @element_filters[path] ||= ElementFilter.new(path)
100
103
 
101
- element_filter.matchers.each do |operator, matchers|
102
- @element_filters[path].add_matchers(operator, matchers)
104
+ element_filter.matchers.each do |operator, matchers|
105
+ @element_filters[path].add_matchers(operator, matchers)
106
+ end
103
107
  end
104
108
  end
105
- end
106
-
107
- def element_filter_for(path)
108
- element_filters[path]
109
- end
110
109
 
111
- def element_filters_for_scope(scope)
112
- @element_filters.values.select do |element_filter|
113
- element_filter.filters_scope?(scope)
110
+ def element_filter_for(path)
111
+ element_filters[path]
114
112
  end
115
- end
116
113
 
117
- def set_element_filters_for_scope(scope, element_filters)
118
- @element_filters.reject! do |_path, element_filter|
119
- element_filter.filters_scope?(scope)
114
+ def element_filters_for_scope(scope)
115
+ @element_filters.values.select do |element_filter|
116
+ element_filter.filters_scope?(scope)
117
+ end
120
118
  end
121
119
 
122
- add_element_filters(element_filters)
123
- end
120
+ def set_element_filters_for_scope(scope, element_filters)
121
+ @element_filters.reject! do |_path, element_filter|
122
+ element_filter.filters_scope?(scope)
123
+ end
124
+
125
+ add_element_filters(element_filters)
126
+ end
124
127
 
125
- def to_array
126
- @element_filters.flat_map do |path, element_filter|
127
- element_filter.matchers.flat_map do |operator, matchers|
128
- matchers.map do |matcher|
129
- "#{path}#{operator}#{Array(matcher).join(",")}"
128
+ def to_array
129
+ @element_filters.flat_map do |path, element_filter|
130
+ element_filter.matchers.flat_map do |operator, matchers|
131
+ matchers.map do |matcher|
132
+ "#{path}#{operator}#{Array(matcher).join(",")}"
133
+ end
130
134
  end
131
135
  end
132
136
  end
133
- end
134
137
 
135
- def matches?(path, value)
136
- filter = element_filter_for(path)
137
- return false unless filter
138
+ def matches?(path, value)
139
+ filter = element_filter_for(path)
140
+ return false unless filter
138
141
 
139
- filter.matches?(value)
140
- end
142
+ filter.matches?(value)
143
+ end
141
144
 
142
- def apply!(system_description)
143
- element_filters.each do |path, element_filter|
144
- steps = path.split("/").reject(&:empty?)
145
- target = steps.pop
146
-
147
- pointer = system_description
148
- container = nil
149
- steps.each do |step|
150
- break unless pointer
151
- pointer = pointer[step]
152
- container ||= pointer if pointer.is_a?(Machinery::Array)
153
- end
145
+ def apply!(system_description)
146
+ element_filters.each do |path, element_filter|
147
+ steps = path.split("/").reject(&:empty?)
148
+ target = steps.pop
149
+
150
+ pointer = system_description
151
+ container = nil
152
+ steps.each do |step|
153
+ break unless pointer
154
+ pointer = pointer[step]
155
+ container ||= pointer if pointer.is_a?(Machinery::Array)
156
+ end
154
157
 
155
- next unless pointer
158
+ next unless pointer
156
159
 
157
- begin
158
- pointer.delete_if do |element|
159
- element_filter.matches?(element[target])
160
+ begin
161
+ pointer.delete_if do |element|
162
+ element_filter.matches?(element[target])
163
+ end
164
+ rescue Machinery::Errors::ElementFilterTypeMismatch => e
165
+ Machinery::Ui.warn("Warning: Filter '#{e.failed_matcher}' tries to match an array, " \
166
+ "but the according element is not an array.")
160
167
  end
161
- rescue Machinery::Errors::ElementFilterTypeMismatch => e
162
- Machinery::Ui.warn("Warning: Filter '#{e.failed_matcher}' tries to match an array, " \
163
- "but the according element is not an array.")
164
168
  end
165
169
  end
166
- end
167
170
 
168
- def empty?
169
- element_filters.empty?
171
+ def empty?
172
+ element_filters.empty?
173
+ end
170
174
  end
171
175
  end
@@ -17,10 +17,10 @@
17
17
 
18
18
  # This class takes care of transforming the user-provided filter options into
19
19
  # actual Filter objects.
20
- class FilterOptionParser
20
+ class Machinery::FilterOptionParser
21
21
  class <<self
22
22
  def parse(command, options)
23
- filter = Filter.from_default_definition(command)
23
+ filter = Machinery::Filter.from_default_definition(command)
24
24
 
25
25
  definitions = skip_files_definitions(options.delete("skip-files"))
26
26
  definitions += exclude_definitions(options["exclude"])
data/lib/hint.rb CHANGED
@@ -15,78 +15,83 @@
15
15
  # To contact SUSE about this file by physical or electronic mail,
16
16
  # you may find current contact information at www.suse.com
17
17
 
18
- class Hint
19
- class << self
20
- def print(method, options = {})
21
- return unless Machinery::Config.new.hints
18
+ module Machinery
19
+ class Ui
20
+ class Hint
21
+ class << self
22
+ def print(method, options = {})
23
+ return unless Machinery::Config.new.hints
22
24
 
23
- Machinery::Ui.puts to_string(method, options)
24
- end
25
+ Machinery::Ui.puts to_string(method, options)
26
+ end
25
27
 
26
- def to_string(method, options = {})
27
- return "" unless Machinery::Config.new.hints
28
+ def to_string(method, options = {})
29
+ return "" unless Machinery::Config.new.hints
28
30
 
29
- "\nHint: #{send(method, options)}\n"
30
- end
31
+ "\nHint: #{send(method, options)}\n"
32
+ end
31
33
 
32
- def program_name
33
- if which_machinery == $PROGRAM_NAME
34
- "machinery"
35
- else
36
- $PROGRAM_NAME
37
- end
38
- end
34
+ def program_name
35
+ if which_machinery == $PROGRAM_NAME
36
+ "machinery"
37
+ else
38
+ $PROGRAM_NAME
39
+ end
40
+ end
39
41
 
40
- private
42
+ private
41
43
 
42
- def which_machinery
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}"
47
- end
44
+ def which_machinery
45
+ `which machinery 2>/dev/null`.chomp
46
+ rescue Errno::EPIPE => e
47
+ Machinery.logger.debug "Command `which machinery 2>/dev/null` crashed. " \
48
+ "Error was #{e.class}: #{e}"
49
+ end
48
50
 
49
- def get_started(_options)
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'"
53
- end
51
+ def get_started(_options)
52
+ "You can get started by inspecting a system. Run:\n'#{program_name} inspect HOSTNAME'\n" \
53
+ "To inspect a system as a user with sudo rights instead of root run:\n" \
54
+ "'#{program_name} inspect --remote-user USER HOSTNAME'"
55
+ end
54
56
 
55
- def upgrade_format_force(options)
56
- "To force an upgrade of system descriptions run:\n" \
57
- "#{program_name} upgrade-format --force #{options[:name]}"
58
- end
57
+ def upgrade_format_force(options)
58
+ "To force an upgrade of system descriptions run:\n" \
59
+ "#{program_name} upgrade-format --force #{options[:name]}"
60
+ end
59
61
 
60
- def show_data(options)
61
- "To show the data of the system you just inspected run:\n#{program_name} show #{options[:name]}"
62
- end
62
+ def show_data(options)
63
+ "To show the data of the system you just inspected "\
64
+ "run:\n#{program_name} show #{options[:name]}"
65
+ end
63
66
 
64
- def show_analyze_data(options)
65
- "To show the config file diffs you just created run:\n" \
66
- "#{program_name} show --scope changed-config-files --show-diffs #{options[:name]}"
67
- end
67
+ def show_analyze_data(options)
68
+ "To show the config file diffs you just created run:\n" \
69
+ "#{program_name} show --scope changed-config-files --show-diffs #{options[:name]}"
70
+ end
68
71
 
69
- def do_complete_inspection(options)
70
- if options[:host]
71
- "To do a full inspection containing all scopes and to extract files run:\n" \
72
- "#{program_name} inspect #{options[:host]} --name #{options[:name]} --extract-files"
73
- elsif options[:docker_container]
74
- "To do a full inspection containing all scopes and to extract files run:\n" \
75
- "#{program_name} inspect-container #{options[:docker_container]} " \
76
- "--name #{options[:name]} --extract-files"
77
- end
78
- end
72
+ def do_complete_inspection(options)
73
+ if options[:host]
74
+ "To do a full inspection containing all scopes and to extract files run:\n" \
75
+ "#{program_name} inspect #{options[:host]} --name #{options[:name]} --extract-files"
76
+ elsif options[:docker_container]
77
+ "To do a full inspection containing all scopes and to extract files run:\n" \
78
+ "#{program_name} inspect-container #{options[:docker_container]} " \
79
+ "--name #{options[:name]} --extract-files"
80
+ end
81
+ end
79
82
 
80
- def upgrade_system_description(_options)
81
- "To upgrade all system descriptions run:\n" \
82
- "#{program_name} upgrade-format --all"
83
- end
83
+ def upgrade_system_description(_options)
84
+ "To upgrade all system descriptions run:\n" \
85
+ "#{program_name} upgrade-format --all"
86
+ end
84
87
 
85
- def share_html_contents(options)
86
- dir = options[:directory] || ""
87
- index_file = File.join(dir, "index.html")
88
- assets_dir = File.join(dir, "assets/")
89
- "Share the file: '#{index_file}' and the directory: '#{assets_dir}' as needed."
88
+ def share_html_contents(options)
89
+ dir = options[:directory] || ""
90
+ index_file = File.join(dir, "index.html")
91
+ assets_dir = File.join(dir, "assets/")
92
+ "Share the file: '#{index_file}' and the directory: '#{assets_dir}' as needed."
93
+ end
94
+ end
90
95
  end
91
96
  end
92
97
  end