lib/rudy/cli/config.rb in rudy-0.8.5 vs lib/rudy/cli/config.rb in rudy-0.9.0
- old
+ new
@@ -19,22 +19,25 @@
# to check various configuration values. (This is mostly useful for
# debugging and checking configuration on an instance itself).
#
# It will return the most specific configuration available. If the
# attribute isn'e found it will check each parent for the same attribute.
- # i.e. if [prod][app][ami] is not available, it will check [prod][ami]
+ # e.g. if [prod][app][ami] is not available, it will check [prod][ami]
# and then [ami].
#
- # # Display the value for a specific machine.
- # $ rudy -e prod -r db config param-name
- #
# # Display all configuration
# $ rudy config --all
#
+ # # Display just machines
+ # $ rudy config --defaults
+ #
def config
- # if Rudy.in_situ? # TODO: do something intelligent when running on EC2
+ # TODO: Re-enable:
+ # # Display the value for a specific machine.
+ # $ rudy -e prod -r db config param-name
+
if @@config.nil? || @@config.empty?
return if @@global.quiet
raise Rudy::NoConfig
end
@@ -56,11 +59,15 @@
else
#puts "# ACCOUNTS: [not displayed]" if types.delete(:accounts)
types.each do |conftype|
puts "# #{conftype.to_s.upcase}"
next unless @@config[conftype] # Nothing to output
- @@config[conftype][:aws][:secretkey] = '[hidden]' if conftype == :accounts
+ if conftype == :accounts
+ skey = @@config[conftype][:aws][:secretkey]
+ @@config[conftype][:aws][:secretkey] = hide_secret_key(skey)
+ end
+
puts @@config[conftype].to_hash.send(outform)
end
end
end
@@ -71,11 +78,17 @@
if @@global.nil?
raise Rudy::NoGlobal
end
gtmp = @@global.clone
gtmp.format = "yaml" if gtmp.format == :s || gtmp.format == :string
- gtmp.accesskey = gtmp.secretkey = "[not displayed]"
+ gtmp.secretkey = hide_secret_key(gtmp.secretkey)
puts gtmp.dump(gtmp.format)
+ end
+
+ private
+ def hide_secret_key(skey)
+ skey = skey.to_s
+ "%s%s%s" % [skey[0], '.'*18, skey[-1]]
end
end
end
end