Class: Rudy::CLI::Config
- Inherits:
-
CommandBase
- Object
- Drydock::Command
- CommandBase
- Rudy::CLI::Config
- Defined in:
- lib/rudy/cli/config.rb
Instance Method Summary collapse
-
#config ⇒ Object
Display configuration from the local user data file (~/.rudy/config).
- #print_global ⇒ Object
-
#print_header ⇒ Object
We force the CLI::Base#print_header to be quiet.
Methods included from Huxtable
change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Instance Method Details
#config ⇒ Object
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. i.e. if [prod][ami] is not available, it will check [prod] and then [ami].
# Display the value for a specific machine.
$ rudy -e prod -r db config param-name
# Display all configuration
$ rudy config --all
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rudy/cli/config.rb', line 33 def config # if Rudy.in_situ? # TODO: do something intelligent when running on EC2 if @@config.nil? || @@config.empty? return if @@global.quiet raise Rudy::NoConfig end outform = @@global.format == :json ? :to_json : :to_yaml types = @option.marshal_dump.keys & @@config.keys # Intersections only types = @@config.keys if @option.all types = [:machines] if types.empty? if @option.project rf = File.join(RUDY_HOME, 'Rudyfile') raise "Cannot find: #{rf}" unless File.exists?(rf) puts File.read(rf) elsif @option.script conf = fetch_script_config puts conf.to_hash.send(outform) if conf 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 puts @@config[conftype].to_hash.send(outform) end end end |
#print_global ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rudy/cli/config.rb', line 67 def print_global # NOTE: This method cannot be called just "global" b/c that conflicts # with the global accessor for Drydock::Command classes. 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]" puts gtmp.dump(gtmp.format) end |
#print_header ⇒ Object
We force the CLI::Base#print_header to be quiet
8 9 10 11 |
# File 'lib/rudy/cli/config.rb', line 8 def print_header #@@global.quiet = true #super end |