rancher-management_api 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a24ea79731fd57cff0e36d504652a7e4568ebee6
4
- data.tar.gz: 7d8010517a332885d784204d1e9dabe14ddd965c
3
+ metadata.gz: b1aa4eb5b1e54e45ed295d11c777b6b8947142a4
4
+ data.tar.gz: 63a57667995bd7ede029a24331d995265342a3bf
5
5
  SHA512:
6
- metadata.gz: b04d51b8c2117a2a2923ae11ed22abfe2f3351749424c6673dd7bcb79088a9dd13f33e2dec2180c90f3832b2c653739c5828db448951ffc4868684e02910de6c
7
- data.tar.gz: f27e2b3deb6587e7969101f5e105db39de9b74700efd1d2594c590c95b7a2190404492640f9e9cb8885cd4ac7964f6c94f7257f03b574424baa53799bc3c3b57
6
+ metadata.gz: 02a80b5dc24fc263af1e819080756afe6a84baa58ba7f36e1f0db904d18cc8aca28fd8d5eb05d5315456ff6351632403ed59423cc46dfe27a9f031914aac7ff8
7
+ data.tar.gz: 479aae3925cb26127b7702c2f3c071ce44543a255c1f8727bf29190dbab4ee199b97e3556df8c752a323f4e93b099d4f299d09a42012b84d333c5b9c78768dab
data/.dockerignore ADDED
@@ -0,0 +1,2 @@
1
+ .git
2
+ .bundle
data/Dockerfile ADDED
@@ -0,0 +1,13 @@
1
+ FROM avvo/ruby
2
+ MAINTAINER Jeff Ching <ching.jeff@gmail.com>
3
+
4
+ RUN apk update && \
5
+ apk upgrade && \
6
+ apk add ruby-json && \
7
+ rm -rf /var/cache/apk/*
8
+
9
+ # bust cache when the version changes
10
+ ADD lib/rancher/management_api/version.rb /tmp/
11
+ RUN gem install -N rancher-management_api
12
+
13
+ ENTRYPOINT ["rancher-management"]
@@ -15,6 +15,10 @@ require 'optparse'
15
15
  valid_output_formats = %w(json yml yaml)
16
16
 
17
17
  optparse = OptionParser.new do |opts|
18
+ opts.on_tail("--help", "Get usage info") do
19
+ puts opts
20
+ exit(1)
21
+ end
18
22
  opts.on("-h", "--host RANCHER_URI", "URI to reach the rancher API", "Example: http://rancher.foo.com/") do |arg|
19
23
  @options[:uri] = arg.chomp
20
24
  end
@@ -68,10 +72,13 @@ else
68
72
  end
69
73
  project = manager.create_project(@options[:environment_name])
70
74
  api_key = project.create_api_key(@options[:key_name])
75
+ registration_token = project.create_registration_token
71
76
 
72
77
  output = {
73
78
  access_key: api_key.publicValue,
74
- secret_key: api_key.secretValue
79
+ secret_key: api_key.secretValue,
80
+ registration_token: registration_token.token,
81
+ registration_command: registration_token.command
75
82
  }
76
83
  case @options[:output_format]
77
84
  when "json"
@@ -13,6 +13,17 @@ module Rancher
13
13
 
14
14
  data = JSON.parse(env_response.body)
15
15
 
16
+ # reload until the project is ready
17
+ while data["state"] == "registering"
18
+ sleep 0.5
19
+ url = data["links"]["self"]
20
+ response = conn.get do |req|
21
+ req.url url
22
+ end
23
+
24
+ data = JSON.parse(response.body)
25
+ end
26
+
16
27
  new(conn, data)
17
28
  end
18
29
 
@@ -26,6 +37,10 @@ module Rancher
26
37
  def create_api_key(name)
27
38
  ApiKey.create(self, name)
28
39
  end
40
+
41
+ def create_registration_token
42
+ RegistrationToken.create(self)
43
+ end
29
44
  end
30
45
  end
31
46
  end
@@ -0,0 +1,29 @@
1
+ require "ostruct"
2
+ require "json"
3
+
4
+ module Rancher
5
+ module ManagementApi
6
+ class RegistrationToken < OpenStruct
7
+ def self.create(project)
8
+ response = project.conn.post do |req|
9
+ req.url "/v1/registrationtokens?projectId=#{project.id}"
10
+ end
11
+
12
+ data = JSON.parse(response.body)
13
+
14
+ # reload until the project is ready
15
+ while data["state"] == "registering"
16
+ sleep 0.5
17
+ url = data["links"]["self"]
18
+ response = project.conn.get do |req|
19
+ req.url url
20
+ end
21
+
22
+ data = JSON.parse(response.body)
23
+ end
24
+ new(data)
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  module Rancher
2
2
  module ManagementApi
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -18,3 +18,4 @@ require "rancher/management_api/manager"
18
18
  require "rancher/management_api/api_key"
19
19
  require "rancher/management_api/project"
20
20
  require "rancher/management_api/token"
21
+ require "rancher/management_api/registration_token"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rancher-management_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donald Plummer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-01 00:00:00.000000000 Z
12
+ date: 2016-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -105,9 +105,11 @@ executables:
105
105
  extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
+ - ".dockerignore"
108
109
  - ".gitignore"
109
110
  - ".rspec"
110
111
  - ".travis.yml"
112
+ - Dockerfile
111
113
  - Gemfile
112
114
  - LICENSE.txt
113
115
  - README.md
@@ -120,6 +122,7 @@ files:
120
122
  - lib/rancher/management_api/api_key.rb
121
123
  - lib/rancher/management_api/manager.rb
122
124
  - lib/rancher/management_api/project.rb
125
+ - lib/rancher/management_api/registration_token.rb
123
126
  - lib/rancher/management_api/token.rb
124
127
  - lib/rancher/management_api/version.rb
125
128
  - rancher-management_api.gemspec