motdotla / digitalocean

The easiest and most complete rubygem for DigitalOcean.
http://rubygems.org/gems/digitalocean
MIT License
153 stars 42 forks source link

cgi escape ssh key create #39

Closed kfatehi closed 10 years ago

kfatehi commented 10 years ago

I had to override this one as well... the issue was that your implementation does not CGI.escape the public key, so the + signs are being converted to spaces when they get to DigitalOcean. Here's my override:

Digitalocean::SshKey.singleton_class.send(:define_method, :create, -> (name, pub_key) {
  url = "https://api.digitalocean.com/v1/ssh_keys/new/?name=#{name}&ssh_pub_key=#{CGI.escape(pub_key)}&client_id=#{Digitalocean.client_id}&api_key=#{Digitalocean.api_key}"
  res = Net::HTTP.get(URI(url))
  RecursiveOpenStruct.new(JSON.parse(res))
})
kfatehi commented 10 years ago

didn't notice -- this is a dupe of #27