itamae 1.0.0.beta4 → 1.0.0.beta5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/itamae/resource/base.rb +7 -1
- data/lib/itamae/resource/directory.rb +12 -3
- data/lib/itamae/resource/file.rb +44 -6
- data/lib/itamae/resource/remote_file.rb +1 -1
- data/lib/itamae/resource/template.rb +1 -1
- data/lib/itamae/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16430941743e871422f34e8a84999bfdd676261c
|
4
|
+
data.tar.gz: 8b937db3cfbd6baa310f0086576f46bffee03b6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e74644471245614750aff1fc8c11a9f7a5b8afff95bac06f053a2ddecbe269fb0b1b57c2d105956f62358df4530b5b0e6f0cc9a08db737ce4366b92572d3af80
|
7
|
+
data.tar.gz: 821c7cbcad69cfbb44f1d0d9d8d0c17d8241cf2332fc79693f76e48beb66e9ef2f95c0514bf5e49c1e5ab9e1f84423280e0c08447015263af673b5d5c7bd8faa
|
data/lib/itamae/resource/base.rb
CHANGED
@@ -54,6 +54,8 @@ module Itamae
|
|
54
54
|
return
|
55
55
|
end
|
56
56
|
|
57
|
+
pre_action
|
58
|
+
|
57
59
|
set_current_attributes
|
58
60
|
show_differences
|
59
61
|
|
@@ -113,6 +115,10 @@ module Itamae
|
|
113
115
|
super
|
114
116
|
end
|
115
117
|
|
118
|
+
def pre_action
|
119
|
+
# do nothing
|
120
|
+
end
|
121
|
+
|
116
122
|
def set_current_attributes
|
117
123
|
# do nothing
|
118
124
|
end
|
@@ -126,7 +132,7 @@ module Itamae
|
|
126
132
|
def show_differences
|
127
133
|
@current_attributes.each_pair do |key, current_value|
|
128
134
|
value = @attributes[key]
|
129
|
-
if current_value == value
|
135
|
+
if current_value == value || value.nil?
|
130
136
|
Logger.info " #{key} will not change (current value is '#{current_value}')"
|
131
137
|
else
|
132
138
|
Logger.info " #{key} will change from '#{current_value}' to '#{value}'"
|
@@ -10,17 +10,26 @@ module Itamae
|
|
10
10
|
define_attribute :group, type: String
|
11
11
|
|
12
12
|
def set_current_attributes
|
13
|
-
|
13
|
+
exist = run_specinfra(:check_file_is_directory, path)
|
14
|
+
@current_attributes[:exist?] = exist
|
15
|
+
|
16
|
+
if exist
|
14
17
|
@current_attributes[:mode] = run_specinfra(:get_file_mode, path).stdout.chomp
|
15
18
|
@current_attributes[:owner] = run_specinfra(:get_file_owner_user, path).stdout.chomp
|
16
19
|
@current_attributes[:group] = run_specinfra(:get_file_owner_group, path).stdout.chomp
|
17
20
|
else
|
18
|
-
|
21
|
+
@current_attributes[:mode] = nil
|
22
|
+
@current_attributes[:owner] = nil
|
23
|
+
@current_attributes[:group] = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
if action == :create
|
27
|
+
@attributes[:exist?] = true
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
22
31
|
def create_action
|
23
|
-
if !
|
32
|
+
if !run_specinfra(:check_file_is_directory, path)
|
24
33
|
run_specinfra(:create_file_as_directory, path)
|
25
34
|
end
|
26
35
|
if attributes[:mode]
|
data/lib/itamae/resource/file.rb
CHANGED
@@ -11,7 +11,7 @@ module Itamae
|
|
11
11
|
define_attribute :owner, type: String
|
12
12
|
define_attribute :group, type: String
|
13
13
|
|
14
|
-
def
|
14
|
+
def pre_action
|
15
15
|
src = if content_file
|
16
16
|
content_file
|
17
17
|
else
|
@@ -21,14 +21,52 @@ module Itamae
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
temppath = ::File.join(runner.tmpdir, Time.now.to_f.to_s)
|
25
|
-
copy_file(src, temppath)
|
24
|
+
@temppath = ::File.join(runner.tmpdir, Time.now.to_f.to_s)
|
25
|
+
copy_file(src, @temppath)
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_current_attributes
|
29
|
+
exist = run_specinfra(:check_file_is_file, path)
|
30
|
+
@current_attributes[:exist?] = exist
|
26
31
|
|
32
|
+
if exist
|
33
|
+
@current_attributes[:mode] = run_specinfra(:get_file_mode, path).stdout.chomp
|
34
|
+
@current_attributes[:owner] = run_specinfra(:get_file_owner_user, path).stdout.chomp
|
35
|
+
@current_attributes[:group] = run_specinfra(:get_file_owner_group, path).stdout.chomp
|
36
|
+
else
|
37
|
+
@current_attributes[:mode] = nil
|
38
|
+
@current_attributes[:owner] = nil
|
39
|
+
@current_attributes[:group] = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
if action == :create
|
43
|
+
@attributes[:exist?] = true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def show_differences
|
48
|
+
super
|
49
|
+
|
50
|
+
if @current_attributes[:exist?]
|
51
|
+
diff = run_command(["diff", "-u", path, @temppath], error: false)
|
52
|
+
if diff.exit_status == 0
|
53
|
+
# no change
|
54
|
+
Logger.info " file content will not change"
|
55
|
+
else
|
56
|
+
Logger.info " diff:"
|
57
|
+
diff.stdout.each_line do |line|
|
58
|
+
Logger.info " #{line.strip}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_action
|
27
65
|
if mode
|
28
|
-
run_specinfra(:change_file_mode, temppath, mode)
|
66
|
+
run_specinfra(:change_file_mode, @temppath, mode)
|
29
67
|
end
|
30
68
|
if owner || group
|
31
|
-
run_specinfra(:change_file_owner, temppath, owner, group)
|
69
|
+
run_specinfra(:change_file_owner, @temppath, owner, group)
|
32
70
|
end
|
33
71
|
|
34
72
|
if run_specinfra(:check_file_is_file, path)
|
@@ -37,7 +75,7 @@ module Itamae
|
|
37
75
|
end
|
38
76
|
|
39
77
|
# TODO: specinfra
|
40
|
-
run_command(["mv", temppath, path])
|
78
|
+
run_command(["mv", @temppath, path])
|
41
79
|
end
|
42
80
|
end
|
43
81
|
end
|
@@ -7,7 +7,7 @@ module Itamae
|
|
7
7
|
class Template < File
|
8
8
|
define_attribute :source, type: String, required: true
|
9
9
|
|
10
|
-
def
|
10
|
+
def pre_action
|
11
11
|
src = ::File.expand_path(source, ::File.dirname(@recipe.path))
|
12
12
|
content(ERB.new(::File.read(src), nil, '-').result(binding))
|
13
13
|
|
data/lib/itamae/version.rb
CHANGED