continuum-stager-api 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 420af5409400c5903880516ca6f9aa8d3eb14f9f
4
- data.tar.gz: f6e06621f8be8fcaeb296de08459bfdc39dce3a8
3
+ metadata.gz: 69b8178c6c6ee4e833c557f4c14e71a259a2c3c6
4
+ data.tar.gz: f55ca0ef16ccb7be730779eea921131fb2225fee
5
5
  SHA512:
6
- metadata.gz: 7cb2832e2d7d6faace8f7f6b5548cd197b2d9cfddec5395e34e05851ffdf4fc5678f640ab800dcdb833fafadcc0f81ea1c5d572eb4a581d40b081bf5be732ce8
7
- data.tar.gz: 849c2753e5746117d6c44c6fbbf1ff5dccb4d0f54ee57c34d32204314ee3789daf11ca70269b2f2a6b7334e4eb1ae78832a6b62ea45c27970b8d6d79047432a0
6
+ metadata.gz: 4a5faaf7ce1bcf70eb5527695634867f175e03f994e64eda7cf948e760e14cf6709902c5085d346ac384662b4d85e66d1d8e53d9593121285eeff5245659948b
7
+ data.tar.gz: 7fb89de64c02a0dd243739ae72e4a7d8b901d6d1fe3895740ee99e901e72e631cbaf37fdc668e0399e0ac3025b0c5f31b2edd62ee43945bc5c22bdd43b9cd1f3
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = `git ls-files -- {spec}/*`.split("\n")
16
16
  gem.name = "continuum-stager-api"
17
17
  gem.require_paths = ["lib"]
18
- gem.version = "0.1.5"
18
+ gem.version = "0.1.6"
19
19
 
20
20
  gem.add_development_dependency 'rspec', '~> 2.6.0'
21
21
  gem.add_development_dependency 'rake'
@@ -67,7 +67,7 @@ module Apcera
67
67
 
68
68
  # Upload the new package to the staging coordinator
69
69
  def upload
70
- app_dir = File.join(".", @app_path.sub(@root_path, ""))
70
+ app_dir = Pathname.new(@app_path).relative_path_from(Pathname.new(@root_path)).to_s
71
71
  execute_app("cd #{app_path}/.. && tar czf #{@updated_pkg_path} #{app_dir}")
72
72
 
73
73
  sha1 = Digest::SHA1.file(@updated_pkg_path)
@@ -135,24 +135,34 @@ module Apcera
135
135
 
136
136
  # Add dependencies to package.
137
137
  def dependencies_add(type, name)
138
+ exists = self.meta["dependencies"].detect { |dep| dep["type"] == type && dep["name"] == name }
139
+ return false if exists
140
+
138
141
  response = RestClient.post(@stager_url+"/meta", {
139
142
  :resource => "dependencies",
140
143
  :action => "add",
141
144
  :type => type,
142
145
  :name => name
143
146
  })
147
+
148
+ true
144
149
  rescue => e
145
150
  fail e
146
151
  end
147
152
 
148
153
  # Delete dependencies from package.
149
154
  def dependencies_remove(type, name)
155
+ exists = self.meta["dependencies"].detect { |dep| dep["type"] == type && dep["name"] == name}
156
+ return false if !exists
157
+
150
158
  response = RestClient.post(@stager_url+"/meta", {
151
159
  :resource => "dependencies",
152
160
  :action => "remove",
153
161
  :type => type,
154
162
  :name => name
155
163
  })
164
+
165
+ true
156
166
  rescue => e
157
167
  fail e
158
168
  end
@@ -165,7 +165,7 @@ describe Apcera::Stager do
165
165
  end
166
166
 
167
167
  it "should compress using tar czf" do
168
- @stager.should_receive(:execute_app).with("cd #{@stager.app_path}/.. && tar czf #{@stager.updated_pkg_path} ./#{@appdir}").and_return
168
+ @stager.should_receive(:execute_app).with("cd #{@stager.app_path}/.. && tar czf #{@stager.updated_pkg_path} #{@appdir}").and_return
169
169
 
170
170
  @stager.upload
171
171
  end
@@ -389,7 +389,13 @@ describe Apcera::Stager do
389
389
  context "dependencies_add" do
390
390
  it "should add to its list of dependencies" do
391
391
  VCR.use_cassette('dependencies_add') do
392
- @stager.dependencies_add("os", "linux")
392
+ @stager.dependencies_add("os", "someos").should == true
393
+ end
394
+ end
395
+
396
+ it "should return false if the dependency is already there" do
397
+ VCR.use_cassette('dependencies_add') do
398
+ @stager.dependencies_add("os", "linux").should == false
393
399
  end
394
400
  end
395
401
 
@@ -409,6 +415,12 @@ describe Apcera::Stager do
409
415
  end
410
416
  end
411
417
 
418
+ it "should return false if the dependency doesn't exist" do
419
+ VCR.use_cassette('dependencies_remove') do
420
+ @stager.dependencies_remove("os", "someos").should == false
421
+ end
422
+ end
423
+
412
424
  it "should bubble errors to fail" do
413
425
  @stager.should_receive(:exit0r).with(1) { raise }
414
426
 
@@ -1,18 +1,66 @@
1
1
  ---
2
2
  http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://example.com/meta
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Wed, 14 Aug 2013 08:52:04 GMT
17
+ Transfer-Encoding:
18
+ - chunked
19
+ Content-Type:
20
+ - application/json;charset=UTF-8
21
+ body:
22
+ encoding: UTF-8
23
+ string: |-
24
+ {
25
+ "dependencies": [
26
+ {"type": "os", "name": "linux"},
27
+ {"type": "package", "name": "build-essential"}
28
+ ],
29
+ "provides": [
30
+ {"type": "runtime", "name": "ruby"},
31
+ {"type": "runtime", "name": "ruby-1.9"}
32
+ ],
33
+ "environment": {
34
+ "PATH": "/opt/apcera/ruby-1.9.3/bin:$PATH",
35
+ "START_COMMAND": "./startme",
36
+ "START_PATH": "/app"
37
+ },
38
+ "templates": [
39
+ {
40
+ "path": "foo",
41
+ "left_delimiter": "<<",
42
+ "right_delimiter": ">>"
43
+ },
44
+ {
45
+ "path": "bar"
46
+ }
47
+ ]
48
+ }
49
+ http_version:
50
+ recorded_at: Wed, 14 Aug 2013 08:52:04 GMT
3
51
  - request:
4
52
  method: post
5
53
  uri: http://example.com/meta
6
54
  body:
7
55
  encoding: US-ASCII
8
- string: resource=dependencies&action=add&type=os&name=linux
56
+ string: resource=dependencies&action=add&type=os&name=someos
9
57
  headers:
10
58
  Content-Type:
11
59
  - application/x-www-form-urlencoded
12
60
  response:
13
61
  status:
14
62
  code: 200
15
- message:
63
+ message:
16
64
  headers:
17
65
  Content-Type:
18
66
  - text/html
@@ -22,7 +70,7 @@ http_interactions:
22
70
  - '4'
23
71
  body:
24
72
  encoding: US-ASCII
25
- string: ! "OK"
73
+ string: OK
26
74
  http_version:
27
75
  recorded_at: Mon, 25 Aug 2014 22:37:33 GMT
28
76
  - request:
@@ -1,5 +1,53 @@
1
1
  ---
2
2
  http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://example.com/meta
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Wed, 14 Aug 2013 08:52:04 GMT
17
+ Transfer-Encoding:
18
+ - chunked
19
+ Content-Type:
20
+ - application/json;charset=UTF-8
21
+ body:
22
+ encoding: UTF-8
23
+ string: |-
24
+ {
25
+ "dependencies": [
26
+ {"type": "os", "name": "linux"},
27
+ {"type": "package", "name": "build-essential"}
28
+ ],
29
+ "provides": [
30
+ {"type": "runtime", "name": "ruby"},
31
+ {"type": "runtime", "name": "ruby-1.9"}
32
+ ],
33
+ "environment": {
34
+ "PATH": "/opt/apcera/ruby-1.9.3/bin:$PATH",
35
+ "START_COMMAND": "./startme",
36
+ "START_PATH": "/app"
37
+ },
38
+ "templates": [
39
+ {
40
+ "path": "foo",
41
+ "left_delimiter": "<<",
42
+ "right_delimiter": ">>"
43
+ },
44
+ {
45
+ "path": "bar"
46
+ }
47
+ ]
48
+ }
49
+ http_version:
50
+ recorded_at: Wed, 14 Aug 2013 08:52:04 GMT
3
51
  - request:
4
52
  method: post
5
53
  uri: http://example.com/meta
@@ -48,4 +48,4 @@ http_interactions:
48
48
  }
49
49
  http_version:
50
50
  recorded_at: Wed, 14 Aug 2013 08:52:04 GMT
51
- recorded_with: VCR 2.5.0
51
+ recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continuum-stager-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Ellithorpe