Top Level Namespace
Defined Under Namespace
Modules: CommandHelpFormatPatch, Conjur, HelpCompletionFormatPatch
Instance Method Summary
collapse
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.handle_options ['--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
139
|
# File 'lib/conjur/command/plugin.rb', line 123
def modify_plugin_list(op, plugin_name)
config_found = false
(Conjur::Config.plugin_config_files + Conjur::Config.default_config_files).uniq!.each do |f|
if File.exists?(f) and not config_found config_found = true
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
exit_now! 'No Conjur config file found for plugin installation' unless config_found
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.handle_options ['-x', '-I', '-a', gem_name]
cmd.execute
modify_plugin_list('remove', name)
end
end
|