Skip to content

Commit fd33246

Browse files
authored
feat/env-repo-level-ip (#99)
* ensure flat keys * assign ip along host
1 parent 473478f commit fd33246

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

config/attributes/default.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default['id'] = ENV['ID']
2-
default['host'] = ENV['IP'].to_s.presence || "127.0.0.1"
2+
default['host'] = (default['ip'] = ENV['IP'].to_s.presence || "127.0.0.1")
33
default['key'] = ENV['KEY'].to_s.presence || "/share/.ssh/#{node['id']}"
44

55
default['app']['user'] = Default.user(node, default: true)

config/libraries/env.rb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,18 @@ def self.dump(ctx, *keys, repo: nil, owner: nil)
6161
Env.set_variable(node, key, val, repo: repo, owner: owner) unless val.blank?
6262
in Array => a
6363
a.each { |x| f.(x) }
64-
else
65-
val = node[keys]; return if val.blank?
66-
if val.is_a?(Hash)
67-
val.each { |subkey, subvalue| Env.set_variable(node, "#{keys}_#{subkey}", subvalue, repo: repo, owner: owner) unless subvalue.blank? }
68-
elsif val.is_a?(Array)
69-
val.each_with_index { |x, i| Env.set_variable(node, "#{keys}_#{i}", x, repo: repo, owner: owner) unless x.blank? }
7064
else
71-
Env.set_variable(node, keys, val, repo: repo, owner: owner)
72-
end
65+
val = node[keys]; return if val.blank?
66+
if val.is_a?(Hash)
67+
val.each { |subkey, subvalue| Env.set_variable(node, "#{keys}_#{subkey}", subvalue, repo: repo, owner: owner) unless subvalue.blank? }
68+
elsif val.is_a?(Array)
69+
val.each_with_index { |x, i| Env.set_variable(node, "#{keys}_#{i}", x, repo: repo, owner: owner) unless x.blank? }
70+
else
71+
Env.set_variable(node, keys, val, repo: repo, owner: owner)
72+
end
7373
end end
7474
keys.each { |key| f.(key) }
7575
true
76-
end
77-
78-
end
79-
76+
end end
77+
8078
end

0 commit comments

Comments
 (0)