Class Rudy::CLI::Config

  1. lib/rudy/cli/config.rb

Methods

public instance

  1. config
  2. print_global
  3. print_header

Public instance methods

config ()

Display configuration from the local user data file (~/.rudy/config). This config contains user data which is sent to each EC2 when it’s created.

The primary purpose of this command is to give other apps a way 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. e.g. if [prod][app][ami] is not available, it will check [prod][ami] and then [ami].

# Display all configuration
$ rudy config --all

# Display just machines
$ rudy config --defaults
[show source]
    # File lib/rudy/cli/config.rb, line 33
33:       def config
34:         
35:         # TODO: Re-enable:
36:         #     # Display the value for a specific machine.
37:         #     $ rudy -e prod -r db config param-name
38:         
39:         if @@config.nil? || @@config.empty?
40:           return if @@global.quiet
41:           raise Rudy::NoConfig
42:         end
43: 
44:         outform = @@global.format == :json ? :to_json : :to_yaml
45:         
46:         types = @option.marshal_dump.keys & @@config.keys # Intersections only
47:         types = @@config.keys if @option.all
48:         types = [:machines] if types.empty?
49:           
50:         if @option.project
51:           rf = File.join(RUDY_HOME, 'Rudyfile')
52:           raise "Cannot find: #{rf}" unless File.exists?(rf)
53:           li File.read(rf)
54:           
55:         elsif @option.script
56:           conf = fetch_script_config
57:           li conf.to_hash.send(outform) if conf
58:           
59:         else
60:           #li "# ACCOUNTS: [not displayed]" if types.delete(:accounts)
61:           types.each do |conftype|
62:             li "# #{conftype.to_s.upcase}"
63:             next unless @@config[conftype]  # Nothing to output
64:             if conftype == :accounts
65:               skey = @@config[conftype][:aws][:secretkey]
66:               @@config[conftype][:aws][:secretkey] = hide_secret_key(skey)
67:             end
68:             
69:             li @@config[conftype].to_hash.send(outform)
70:           end
71:         end
72:         
73:       end
print_global ()
[show source]
    # File lib/rudy/cli/config.rb, line 75
75:       def print_global
76:         # NOTE: This method cannot be called just "global" b/c that conflicts 
77:         # with the global accessor for Drydock::Command classes. 
78:         if @@global.nil?
79:           raise Rudy::NoGlobal
80:         end
81:         gtmp = @@global.clone
82:         gtmp.format = "yaml" if gtmp.format == :s || gtmp.format == :string
83:         gtmp.secretkey = hide_secret_key(gtmp.secretkey)
84:         li gtmp.dump(gtmp.format)
85:       end
print_header ()

We force the CLI::Base#print_header to be quiet

[show source]
    # File lib/rudy/cli/config.rb, line 8
 8:       def print_header
 9:         #@@global.quiet = true
10:         #super
11:       end