vagrant-gitcredentials 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,25 @@
1
+ require 'shellwords'
1
2
  module VagrantPlugins
2
3
  module GitCredentials
3
4
  module Util
4
5
  # generates new ssh key and calls github v3 api to add key to user account
5
6
  def createKey
6
- srcPath= "scripts/github.sh"
7
- destPath = "/root/.ssh/github.sh"
7
+ script = ["GITHUB_USERNAME=$1", "GITHUB_PASSWORD=$2"]
8
+ script.concat(["ssh-keygen -N '' -f ~/.ssh/github_rsa", "ssh-add ~/.ssh/github_rsa"])
9
+ script.concat(["set -- $(<~/.ssh/github_rsa.pub)", 'JSON=\'{"title":"vagrant provision key", "key": "ssh-rsa \'$2\'"}\''])
10
+ script.concat(['curl -u "$GITHUB_USERNAME:$GITHUB_PASSWORD" -d "$JSON" https://api.github.com/user/keys'])
8
11
  # create script
9
- @machine.communicate.upload(srcPath, destPath)
12
+ script.each {
13
+ |l|
14
+ e = Shellwords.escape(l);
15
+ @machine.communicate.execute("echo #{e} >> ~/.ssh/github.sh")
16
+ }
10
17
  # set permissions for execution
11
- @machine.communicate.execute("chmod 755 /root/.ssh/github.sh")
18
+ @machine.communicate.execute("chmod 755 ~/.ssh/github.sh")
19
+ @machine.communicate.execute("cat ~/.ssh/github.sh")
12
20
  # execute script w/ permissions
13
21
  promptCredentials()
14
- @machine.communicate.execute("sh /root/.ssh/github.sh #{gitUsername} #{gitPassword}")
22
+ @machine.communicate.execute("sh ~/.ssh/github.sh #{gitUsername} #{gitPassword}")
15
23
 
16
24
  @ui.info("created ssh key")
17
25
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module GitCredentials
3
- VERSION = "0.0.15"
3
+ VERSION = "0.0.16"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 15
9
- version: 0.0.15
8
+ - 16
9
+ version: 0.0.16
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jeremy Giberson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2013-10-10 00:00:00 -07:00
17
+ date: 2013-10-11 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency