Class: Conjur::CLI
Defined Under Namespace
Classes: Complete
Class Method Summary collapse
- .appliance_version ⇒ Object
- .apply_config ⇒ Object
- .command_version_compatible?(command) ⇒ Boolean
-
.init! ⇒ Object
This makes our generate-commands script a little bit cleaner.
- .load_config ⇒ Object
- .load_plugins ⇒ Object
-
.run(args) ⇒ Object
Horible hack! We want to support legacy commands like host:list, but we don’t want to do too much effort, and GLIs support for aliasing doesn’t work out so well with subcommands.
Class Method Details
.appliance_version ⇒ Object
99 100 101 102 103 |
# File 'lib/conjur/cli.rb', line 99 def appliance_version Conjur::API.service_version 'appliance' rescue nil end |
.apply_config ⇒ Object
58 59 60 |
# File 'lib/conjur/cli.rb', line 58 def apply_config Conjur::Config.apply end |
.command_version_compatible?(command) ⇒ Boolean
105 106 107 108 109 110 |
# File 'lib/conjur/cli.rb', line 105 def command_version_compatible? command !command.instance_variable_defined?(:@conjur_min_version) || (appliance_version && command.instance_variable_get(:@conjur_min_version) <= appliance_version ) end |
.init! ⇒ Object
This makes our generate-commands script a little bit cleaner. We can call this from that script to ensure that commands for all plugins are loaded.
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/conjur/cli.rb', line 88 def init! subcommand_option_handling :normal load_config apply_config load_plugins commands_from 'conjur/command' rescue => ex stderr.puts "error: #{ex.}" raise if ENV['GLI_DEBUG'] == 'true' end |
.load_config ⇒ Object
54 55 56 |
# File 'lib/conjur/cli.rb', line 54 def load_config Conjur::Config.load end |
.load_plugins ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/conjur/cli.rb', line 71 def load_plugins # These used to be plugins but now they are in the core CLI plugins = Conjur::Config.plugins - %w(audit-send host-factory layer pubkeys) plugins.each do |plugin| begin filename = "conjur-asset-#{plugin}" require filename rescue LoadError => err warn "WARNING: #{err.}\n" \ "Could not load plugin '#{plugin}' specified in your config file.\n"\ "Make sure you have the #{filename} gem installed." end end end |
.run(args) ⇒ Object
Horible hack! We want to support legacy commands like host:list, but we don’t want to do too much effort, and GLIs support for aliasing doesn’t work out so well with subcommands.
66 67 68 69 |
# File 'lib/conjur/cli.rb', line 66 def run args args = args.shift.split(':') + args unless args.empty? super args end |