machinery-tool 1.14.2 → 1.15.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 +14 -0
- data/html/assets/compare/machinery.js +20 -13
- data/html/assets/file_loader.gif +0 -0
- data/html/assets/machinery-base.css +21 -12
- data/html/assets/machinery-base.js +19 -0
- data/html/assets/machinery.css +35 -11
- data/html/assets/show/machinery.js +24 -7
- data/html/comparison.html.haml +13 -36
- data/html/index.html.haml +32 -47
- data/html/partials/changed_managed_files.html.haml +5 -5
- data/html/partials/compare/changed_managed_file_list.html.haml +1 -1
- data/html/partials/compare/changed_managed_files.html.haml +41 -47
- data/html/partials/compare/changes.html.haml +8 -0
- data/html/partials/compare/config_file_list.html.haml +5 -5
- data/html/partials/compare/config_files.html.haml +38 -44
- data/html/partials/compare/group_list.html.haml +3 -3
- data/html/partials/compare/groups.html.haml +34 -42
- data/html/partials/compare/os.html.haml +21 -23
- data/html/partials/compare/package_list.html.haml +2 -2
- data/html/partials/compare/packages.html.haml +40 -56
- data/html/partials/compare/pattern_list.html.haml +2 -2
- data/html/partials/compare/patterns.html.haml +40 -42
- data/html/partials/compare/repositories.html.haml +40 -41
- data/html/partials/compare/service_list.html.haml +1 -1
- data/html/partials/compare/services.html.haml +44 -36
- data/html/partials/compare/summary.html.haml +17 -0
- data/html/partials/compare/unmanaged_file_list.html.haml +4 -3
- data/html/partials/compare/unmanaged_files.html.haml +44 -38
- data/html/partials/compare/user_list.html.haml +2 -2
- data/html/partials/compare/users.html.haml +40 -43
- data/html/partials/config_files.html.haml +8 -8
- data/html/partials/os.html.haml +8 -5
- data/html/partials/packages.html.haml +4 -4
- data/html/partials/patterns.html.haml +2 -2
- data/html/partials/repositories.html.haml +5 -5
- data/html/partials/scope_header.html.haml +4 -6
- data/html/partials/services.html.haml +1 -1
- data/html/partials/unmanaged_files.html.haml +1 -1
- data/html/partials/users.html.haml +4 -4
- data/lib/array.rb +4 -0
- data/lib/cli.rb +12 -4
- data/lib/file_scope.rb +9 -3
- data/lib/html.rb +1 -0
- data/lib/machinery.rb +1 -0
- data/lib/scope.rb +16 -0
- data/lib/server.rb +61 -23
- data/lib/system_description.rb +0 -8
- data/lib/try.rb +28 -0
- data/lib/version.rb +1 -1
- data/machinery-helper/version.go +1 -1
- data/man/generated/machinery.1.gz +0 -0
- data/man/generated/machinery.1.html +54 -22
- data/plugins/changed_managed_files/{changed_managed_files.md → changed_managed_files.yml} +4 -0
- data/plugins/changed_managed_files/changed_managed_files_model.rb +14 -0
- data/plugins/changed_managed_files/changed_managed_files_renderer.rb +17 -0
- data/plugins/config_files/{config_files.md → config_files.yml} +4 -0
- data/plugins/config_files/config_files_model.rb +14 -0
- data/plugins/config_files/config_files_renderer.rb +17 -0
- data/plugins/groups/{groups.md → groups.yml} +4 -0
- data/plugins/groups/groups_model.rb +14 -0
- data/plugins/groups/groups_renderer.rb +17 -0
- data/plugins/os/{os.md → os.yml} +4 -0
- data/plugins/packages/{packages.md → packages.yml} +4 -0
- data/plugins/packages/packages_model.rb +1 -12
- data/plugins/patterns/{patterns.md → patterns.yml} +4 -0
- data/plugins/patterns/patterns_model.rb +14 -0
- data/plugins/patterns/patterns_renderer.rb +21 -0
- data/plugins/repositories/{repositories.md → repositories.yml} +4 -0
- data/plugins/repositories/repositories_model.rb +14 -0
- data/plugins/repositories/repositories_renderer.rb +17 -0
- data/plugins/services/{services.md → services.yml} +4 -0
- data/plugins/services/services_model.rb +21 -11
- data/plugins/services/services_renderer.rb +17 -0
- data/plugins/unmanaged_files/{unmanaged_files.md → unmanaged_files.yml} +4 -0
- data/plugins/unmanaged_files/unmanaged_files_model.rb +2 -1
- data/plugins/unmanaged_files/unmanaged_files_renderer.rb +17 -0
- data/plugins/users/{users.md → users.yml} +4 -0
- data/plugins/users/users_model.rb +38 -0
- data/plugins/users/users_renderer.rb +17 -0
- metadata +17 -32
- data/html/assets/logo-changed-managed-files-small.png +0 -0
- data/html/assets/logo-changed-managed-files.png +0 -0
- data/html/assets/logo-config-files-small.png +0 -0
- data/html/assets/logo-config-files.png +0 -0
- data/html/assets/logo-groups-small.png +0 -0
- data/html/assets/logo-groups.png +0 -0
- data/html/assets/logo-os-small.png +0 -0
- data/html/assets/logo-os.png +0 -0
- data/html/assets/logo-packages-small.png +0 -0
- data/html/assets/logo-packages.png +0 -0
- data/html/assets/logo-patterns-small.png +0 -0
- data/html/assets/logo-patterns.png +0 -0
- data/html/assets/logo-repositories-small.png +0 -0
- data/html/assets/logo-repositories.png +0 -0
- data/html/assets/logo-services-small.png +0 -0
- data/html/assets/logo-services.png +0 -0
- data/html/assets/logo-unmanaged-files-small.png +0 -0
- data/html/assets/logo-unmanaged-files.png +0 -0
- data/html/assets/logo-users-small.png +0 -0
- data/html/assets/logo-users.png +0 -0
@@ -1,52 +1,49 @@
|
|
1
|
-
- if @diff["
|
2
|
-
|
1
|
+
- if @diff["users"]
|
2
|
+
- scope = "users"
|
3
|
+
%a.scope_anchor{ id: scope }
|
3
4
|
.scope#users_container
|
4
5
|
.row
|
5
6
|
.col-xs-1
|
6
|
-
%a{ href
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"data-content" => "#{scope_help("users")}" }
|
7
|
+
%a.btn.btn-default.btn-lg.scope_logo_big{ :href => "##{scope}",
|
8
|
+
:title => scope_title(scope), "data-toggle"=>"popover",
|
9
|
+
"data-content" => scope_help(scope) }
|
10
|
+
%span= scope_initials(scope)
|
11
11
|
%span.toggle{ title: "Collapse/Expand" }
|
12
12
|
.col-xs-11
|
13
13
|
%h2
|
14
14
|
Users
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
- if @diff["users"].only_in2
|
20
|
-
%span.summary-part
|
21
|
-
#{@description_b.name}: #{@diff["users"].only_in2.length} users
|
22
|
-
- if @diff["users"].common
|
23
|
-
%span.summary-part
|
24
|
-
%a.show-common-elements{ href: "#users_both" }<
|
25
|
-
both
|
26
|
-
= ": #{@diff["users"].common.length} users"
|
15
|
+
= render_partial "compare/summary",
|
16
|
+
scope: "users",
|
17
|
+
singular: "user",
|
18
|
+
plural: "users"
|
27
19
|
.row.scope_content.collapse.in
|
28
|
-
.
|
29
|
-
.col-xs-1
|
30
|
-
.col-xs-5.table_container
|
31
|
-
- if @diff["users"].only_in1
|
32
|
-
= only_in_a
|
33
|
-
= render_partial "compare/user_list", list: @diff["users"].only_in1
|
34
|
-
.col-xs-1
|
35
|
-
.col-xs-5.table_container
|
36
|
-
- if @diff["users"].only_in2
|
37
|
-
= only_in_b
|
38
|
-
= render_partial "compare/user_list", list: @diff["users"].only_in2
|
39
|
-
- if @diff["users"].common
|
40
|
-
%a.both_anchor{ id: "users_both" }
|
20
|
+
.col-md-12
|
41
21
|
.row
|
42
|
-
.col-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
22
|
+
.col-md-6.table_container
|
23
|
+
- if @diff["users"].only_in1
|
24
|
+
= only_in_a
|
25
|
+
= render_partial "compare/user_list", list: @diff["users"].only_in1
|
26
|
+
.col-md-6.table_container
|
27
|
+
- if @diff["users"].only_in2
|
28
|
+
= only_in_b
|
29
|
+
= render_partial "compare/user_list", list: @diff["users"].only_in2
|
30
|
+
- if @diff["users"].changed
|
31
|
+
%a.both_anchor{ id: "users_changed" }
|
32
|
+
.row
|
33
|
+
.col-md-12.table_container
|
34
|
+
= changed
|
35
|
+
= render_partial "compare/changes", changes: changed_elements("users",
|
36
|
+
key: "name",
|
37
|
+
attributes: ["uid", "gid", "comment", "shell", "home"])
|
38
|
+
- if @diff["users"].common
|
39
|
+
%a.both_anchor{ id: "users_both" }
|
40
|
+
.row
|
41
|
+
.col-md-12
|
42
|
+
%a.show-common-elements{ href: "#users_both" }
|
43
|
+
Show common elements in users
|
44
|
+
%a.hide-common-elements{ href: "#", style: "display: none" }
|
45
|
+
Hide common elements in users
|
46
|
+
.row.scope_common_content.collapse
|
47
|
+
.col-md-12.table_container
|
48
|
+
= in_both
|
49
|
+
= render_partial "compare/user_list", list: @diff["users"].common
|
@@ -20,18 +20,18 @@
|
|
20
20
|
%td.linenumber= line.new_line_number
|
21
21
|
%td
|
22
22
|
= line.content
|
23
|
-
.col-
|
24
|
-
.col-
|
23
|
+
.col-md-1
|
24
|
+
.col-md-11
|
25
25
|
%table.table.table-striped.table-hover.table-condensed.files-table.filterable
|
26
26
|
%thead
|
27
27
|
%tr
|
28
28
|
%th Name
|
29
|
-
%th Package Name
|
30
|
-
%th Package Version
|
31
|
-
%th Changes
|
32
|
-
%th Mode
|
33
|
-
%th User
|
34
|
-
%th Group
|
29
|
+
%th.medium Package Name
|
30
|
+
%th.medium Package Version
|
31
|
+
%th.medium Changes
|
32
|
+
%th.small Mode
|
33
|
+
%th.small User
|
34
|
+
%th.small Group
|
35
35
|
%tbody
|
36
36
|
- config_files.files.each do |file|
|
37
37
|
%tr
|
data/html/partials/os.html.haml
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
- if os
|
2
|
+
- scope = "os"
|
2
3
|
%div
|
3
|
-
%a.scope_anchor{ :id =>
|
4
|
+
%a.scope_anchor{ :id => scope }
|
4
5
|
.scope#os_container
|
5
6
|
.row
|
6
7
|
.col-xs-1
|
7
|
-
%
|
8
|
-
|
8
|
+
%a.btn.btn-default.btn-lg.scope_logo_big{ :href => "##{scope}",
|
9
|
+
:title => scope_title(scope), "data-toggle"=>"popover",
|
10
|
+
"data-content" => scope_help(scope) }
|
11
|
+
%span= scope_initials(scope)
|
9
12
|
%span.toggle{ title: "Collapse/Expand" }
|
10
13
|
.col-xs-11
|
11
14
|
%h2
|
12
15
|
Operating System
|
13
16
|
.scope-summary
|
14
|
-
= scope_meta_info(
|
17
|
+
= scope_meta_info(scope)
|
15
18
|
.col-xs-1
|
16
|
-
.col-xs-
|
19
|
+
.col-xs-11.scope_content.collapse.in
|
17
20
|
%table.table.table-striped.table-condensed
|
18
21
|
%tr
|
19
22
|
%th Name
|
@@ -15,12 +15,12 @@
|
|
15
15
|
%tr
|
16
16
|
%th Name
|
17
17
|
%th Alias
|
18
|
-
%th Type
|
18
|
+
%th.small Type
|
19
19
|
%th URL
|
20
|
-
%th Enabled
|
21
|
-
%th Autorefresh
|
22
|
-
%th GPG Check
|
23
|
-
%th Priority
|
20
|
+
%th.small Enabled
|
21
|
+
%th.small Autorefresh
|
22
|
+
%th.small GPG Check
|
23
|
+
%th.small Priority
|
24
24
|
%tbody
|
25
25
|
- repositories.each do |repo|
|
26
26
|
%tr
|
@@ -1,12 +1,10 @@
|
|
1
1
|
- meta = @description[scope].meta
|
2
2
|
.row
|
3
3
|
.col-xs-1
|
4
|
-
%
|
5
|
-
"data-toggle"
|
6
|
-
"
|
7
|
-
|
8
|
-
"data-original-title" => title,
|
9
|
-
"style" => "top: 125px;" }
|
4
|
+
%a.btn.btn-default.btn-lg.over.scope_logo_big{ :href => "##{scope}",
|
5
|
+
:title => scope_title(scope), "data-toggle"=>"popover",
|
6
|
+
"data-content" => scope_help(scope) }
|
7
|
+
%span= scope_initials(scope)
|
10
8
|
%span.toggle{ "title" => "Collapse/Expand" }
|
11
9
|
.col-xs-11
|
12
10
|
%h2
|
data/lib/array.rb
CHANGED
data/lib/cli.rb
CHANGED
@@ -774,15 +774,23 @@ class Cli
|
|
774
774
|
inspected_filters = description.filter_definitions("inspect")
|
775
775
|
|
776
776
|
if options[:verbose]
|
777
|
+
details = ""
|
778
|
+
|
779
|
+
if description[:environment].system_type == "docker"
|
780
|
+
details += "\n Type of inspected container: #{description[:environment].system_type}\n"
|
781
|
+
end
|
782
|
+
|
777
783
|
if !inspected_filters.empty?
|
778
|
-
|
779
|
-
|
784
|
+
details += "\n The following filters were applied during inspection:"
|
785
|
+
details += "\n * " + inspected_filters.join("\n * ") + "\n\n"
|
780
786
|
end
|
781
787
|
|
782
788
|
if !filter.empty?
|
783
|
-
|
784
|
-
|
789
|
+
details += "\n The following filters were applied before showing the description:"
|
790
|
+
details += "\n * " + filter.to_array.join("\n * ") + "\n\n"
|
785
791
|
end
|
792
|
+
|
793
|
+
Machinery::Ui.puts "# Inspection details\n" + details unless details.empty?
|
786
794
|
end
|
787
795
|
|
788
796
|
task = ShowTask.new
|
data/lib/file_scope.rb
CHANGED
@@ -24,12 +24,16 @@ class FileScope < Machinery::Object
|
|
24
24
|
shared = self.class.new
|
25
25
|
|
26
26
|
compare_extracted(other, only_self, only_other, shared)
|
27
|
-
compare_files(other, only_self, only_other, shared)
|
27
|
+
changed = compare_files(other, only_self, only_other, shared)
|
28
28
|
|
29
29
|
only_self = nil if only_self.empty?
|
30
30
|
only_other = nil if only_other.empty?
|
31
31
|
shared = nil if shared.empty?
|
32
|
-
[only_self, only_other,
|
32
|
+
[only_self, only_other, changed, shared]
|
33
|
+
end
|
34
|
+
|
35
|
+
def length
|
36
|
+
files.try(:length) || 0
|
33
37
|
end
|
34
38
|
|
35
39
|
private
|
@@ -57,10 +61,12 @@ class FileScope < Machinery::Object
|
|
57
61
|
end
|
58
62
|
|
59
63
|
def compare_files(other, only_self, only_other, shared)
|
60
|
-
own_files, other_files,
|
64
|
+
own_files, other_files, changed, shared_files = files.compare_with(other.files)
|
61
65
|
|
62
66
|
only_self.files = own_files if own_files
|
63
67
|
only_other.files = other_files if other_files
|
64
68
|
shared.files = shared_files if shared_files
|
69
|
+
|
70
|
+
changed
|
65
71
|
end
|
66
72
|
end
|
data/lib/html.rb
CHANGED
@@ -24,6 +24,7 @@ class Html
|
|
24
24
|
Server.set :port, opts[:port] || Machinery::Config.new.http_server_port
|
25
25
|
Server.set :bind, opts[:ip] || "localhost"
|
26
26
|
Server.set :public_folder, File.join(Machinery::ROOT, "html")
|
27
|
+
Server.set :static_cache_control, "no-cache"
|
27
28
|
|
28
29
|
if opts[:ip] != "localhost" && opts[:ip] != "127.0.0.1"
|
29
30
|
if opts[:ip] == "0.0.0.0"
|
data/lib/machinery.rb
CHANGED
data/lib/scope.rb
CHANGED
@@ -46,6 +46,22 @@ module Machinery
|
|
46
46
|
nil
|
47
47
|
end
|
48
48
|
|
49
|
+
def self.extract_changed_elements(a, b, primary_key)
|
50
|
+
changed_keys = a.map(&primary_key) & b.map(&primary_key)
|
51
|
+
changed = []
|
52
|
+
|
53
|
+
changed_keys.each do |key|
|
54
|
+
changed << [
|
55
|
+
a.find { |e| e.send(primary_key) == key },
|
56
|
+
b.find { |e| e.send(primary_key) == key },
|
57
|
+
]
|
58
|
+
a.reject! { |e| e.send(primary_key) == key }
|
59
|
+
b.reject! { |e| e.send(primary_key) == key }
|
60
|
+
end
|
61
|
+
|
62
|
+
changed
|
63
|
+
end
|
64
|
+
|
49
65
|
module ClassMethods
|
50
66
|
def hidden?
|
51
67
|
@hidden || false
|
data/lib/server.rb
CHANGED
@@ -35,12 +35,32 @@ class Server < Sinatra::Base
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def scope_help(scope)
|
38
|
-
text =
|
38
|
+
text = scope_info(scope)[:description]
|
39
39
|
Kramdown::Document.new(text).to_html
|
40
40
|
end
|
41
41
|
|
42
|
+
def scope_info(scope)
|
43
|
+
YAML.load(File.read(File.join(Machinery::ROOT, "plugins", "#{scope}/#{scope}.yml")))
|
44
|
+
end
|
45
|
+
|
46
|
+
def scope_title(scope)
|
47
|
+
scope_info(scope)[:name]
|
48
|
+
end
|
49
|
+
|
50
|
+
def scope_initials(scope)
|
51
|
+
scope_info(scope)[:initials].upcase
|
52
|
+
end
|
53
|
+
|
54
|
+
def nav_class(scope)
|
55
|
+
if @description
|
56
|
+
return @description[scope] ? "" : "disabled"
|
57
|
+
elsif @description_a && @description_b
|
58
|
+
return @description_a[scope] && @description_b[scope] ? "" : "disabled"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
42
62
|
def safe_length(object, attribute)
|
43
|
-
if
|
63
|
+
if collection = object.try(attribute)
|
44
64
|
collection.length
|
45
65
|
else
|
46
66
|
0
|
@@ -63,40 +83,58 @@ class Server < Sinatra::Base
|
|
63
83
|
"<h3>In both with different attributes:</h3>"
|
64
84
|
end
|
65
85
|
|
66
|
-
def
|
86
|
+
def pluralize_scope(object, singular, plural)
|
87
|
+
object.length.to_s + " " + Machinery.pluralize(object.length, singular, plural)
|
88
|
+
end
|
89
|
+
|
90
|
+
def changed_elements(scope, opts)
|
91
|
+
optional_attributes = opts[:optional_attributes] || []
|
92
|
+
|
67
93
|
changed = []
|
68
|
-
@diff[
|
94
|
+
@diff[scope].changed.each do |change|
|
69
95
|
changes = []
|
70
|
-
relevant_attributes = [
|
96
|
+
relevant_attributes = if opts[:attributes]
|
97
|
+
opts[:attributes].dup
|
98
|
+
else
|
99
|
+
change[0].attributes.keys & change[1].attributes.keys
|
100
|
+
end
|
71
101
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
relevant_attributes.push(
|
102
|
+
(1..optional_attributes.length).each do |i|
|
103
|
+
if change[0][optional_attributes[i - 1]] ==
|
104
|
+
change[1][optional_attributes[i - 1]]
|
105
|
+
relevant_attributes.push(optional_attributes[i])
|
106
|
+
else
|
107
|
+
break
|
76
108
|
end
|
77
109
|
end
|
78
|
-
|
79
110
|
relevant_attributes.each do |attribute|
|
80
111
|
if change[0][attribute] != change[1][attribute]
|
81
|
-
changes.push(
|
112
|
+
changes.push(
|
113
|
+
attribute + ": " + human_readable_attribute(change[0], attribute) + " ↔ " +
|
114
|
+
human_readable_attribute(change[1], attribute)
|
115
|
+
)
|
82
116
|
end
|
83
117
|
end
|
84
118
|
|
85
|
-
changed.push(
|
119
|
+
changed.push(
|
120
|
+
id: change[0][opts[:key]],
|
121
|
+
change: "(" + changes.join(", ") + ")",
|
122
|
+
diffable: change[0].is_a?(UnmanagedFile) && change[0].is_a?(UnmanagedFile) &&
|
123
|
+
change[0].file? && change[1].file?
|
124
|
+
)
|
86
125
|
end
|
87
126
|
changed
|
88
127
|
end
|
89
128
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
return [] if !@diff["unmanaged_files"] || !@diff["unmanaged_files"].only_in1 ||
|
94
|
-
!@diff["unmanaged_files"].only_in2
|
129
|
+
def human_readable_attribute(object, attribute)
|
130
|
+
value = object[attribute]
|
95
131
|
|
96
|
-
|
97
|
-
|
132
|
+
case object
|
133
|
+
when Machinery::SystemFile
|
134
|
+
value = number_to_human_size(value) if attribute == "size"
|
135
|
+
end
|
98
136
|
|
99
|
-
|
137
|
+
value.to_s
|
100
138
|
end
|
101
139
|
|
102
140
|
def diff_to_object(diff)
|
@@ -186,14 +224,14 @@ class Server < Sinatra::Base
|
|
186
224
|
Inspector.all_scopes.each do |scope|
|
187
225
|
if @description_a[scope] && @description_b[scope]
|
188
226
|
@diff[scope] = Comparison.compare_scope(@description_a, @description_b, scope)
|
189
|
-
|
227
|
+
elsif @description_a[scope] || @description_b[scope]
|
190
228
|
@meta[:uninspected] ||= Hash.new
|
191
229
|
|
192
|
-
if !@description_a[scope]
|
230
|
+
if !@description_a[scope]
|
193
231
|
@meta[:uninspected][@description_a.name] ||= Array.new
|
194
232
|
@meta[:uninspected][@description_a.name] << scope
|
195
233
|
end
|
196
|
-
if !@description_b[scope]
|
234
|
+
if !@description_b[scope]
|
197
235
|
@meta[:uninspected][@description_b.name] ||= Array.new
|
198
236
|
@meta[:uninspected][@description_b.name] << scope
|
199
237
|
end
|