Top Level Namespace
Defined Under Namespace
Modules: Conjur
Instance Method Summary collapse
- #install_plugin(name, version) ⇒ Object
- #modify_plugin_list(op, plugin_name) ⇒ Object
- #uninstall_plugin(name) ⇒ Object
Instance Method Details
#install_plugin(name, version) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/conjur/command/plugin.rb', line 92 def install_plugin(name, version) uninstall_plugin(name) rescue Exception gem_name = name.start_with?('conjur-asset-') ? name : "conjur-asset-#{name}" cmd = Gem::Commands::InstallCommand.new cmd. ['--no-ri', '--no-rdoc', gem_name, '--version', "#{version}"] begin cmd.execute rescue Gem::SystemExitException => e if e.exit_code != 0 raise e end end modify_plugin_list('add', name) end |
#modify_plugin_list(op, plugin_name) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/conjur/command/plugin.rb', line 123 def modify_plugin_list(op, plugin_name) config_exists = false Conjur::Config.plugin_config_files.each do |f| if !File.file?(f) FileUtils.touch(f) end config = YAML.load(IO.read(f)).stringify_keys rescue {} config['plugins'] ||= [] config['plugins'] += [plugin_name] if op == 'add' config['plugins'] -= [plugin_name] if op == 'remove' config['plugins'].uniq! File.write(f, YAML.dump(config)) end end |
#uninstall_plugin(name) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/conjur/command/plugin.rb', line 111 def uninstall_plugin(name) if Conjur::Config.plugins.include?(name) gem_name = name.start_with?('conjur-asset-') ? name : "conjur-asset-#{name}" cmd = Gem::Commands::UninstallCommand.new cmd. ['-x', '-I', '-a', gem_name] cmd.execute modify_plugin_list('remove', name) end end |