Skip to content

Commit d543a66

Browse files
authored
add 'current_droplet' to app's relationships (#3863)
1 parent 1210a36 commit d543a66

File tree

6 files changed

+102
-5
lines changed

6 files changed

+102
-5
lines changed

app/presenters/v3/app_presenter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def to_hash
3131
data: {
3232
guid: app.space_guid
3333
}
34+
},
35+
current_droplet: {
36+
data: {
37+
guid: app.droplet_guid
38+
}
3439
}
3540
},
3641
metadata: {

docs/v3/source/includes/api_resources/_apps.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
"data": {
3434
"guid": "2f35885d-0c9d-4423-83ad-fd05066f8576"
3535
}
36+
},
37+
"current_droplet": {
38+
"data": {
39+
"guid": "585bc3c1-3743-497d-88b0-403ad6b56d16"
40+
}
3641
}
3742
},
3843
"links": {
@@ -101,6 +106,11 @@
101106
"data": {
102107
"guid": "2f35885d-0c9d-4423-83ad-fd05066f8576"
103108
}
109+
},
110+
"droplet": {
111+
"data": {
112+
"guid": "585bc3c1-3743-497d-88b0-403ad6b56d16"
113+
}
104114
}
105115
},
106116
"links": {
@@ -174,6 +184,11 @@
174184
"data": {
175185
"guid": "2f35885d-0c9d-4423-83ad-fd05066f8576"
176186
}
187+
},
188+
"current_droplet": {
189+
"data": {
190+
"guid": "585bc3c1-3743-497d-88b0-403ad6b56d16"
191+
}
177192
}
178193
},
179194
"links": {
@@ -245,6 +260,11 @@
245260
"data": {
246261
"guid": "2f35885d-0c9d-4423-83ad-fd05066f8576"
247262
}
263+
},
264+
"current_droplet": {
265+
"data": {
266+
"guid": "585bc3c1-3743-497d-88b0-403ad6b56d16"
267+
}
248268
}
249269
},
250270
"links": {

docs/v3/source/includes/resources/apps/_object.md.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Name | Type | Description
1616
**state** | _string_ | Current desired state of the app; valid values are `STOPPED` or `STARTED`
1717
**lifecycle** | [_lifecycle object_](#the-lifecycle-object) | Provides the default lifecycle object for the application. This lifecycle will be used when staging and running the application. The staging lifecycle can be overridden on [builds](#builds)
1818
**relationships.space** | [_to-one relationship_](#to-one-relationships) | The space the app is contained in
19+
**relationships.current_droplet** | [_to-one relationship_](#to-one-relationships) | The current droplet used by the application
1920
**metadata.labels** | [_label object_](#labels) | Labels applied to the app
2021
**metadata.annotations** | [_annotation object_](#annotations) | Annotations added to the app
2122
**links** | [_links object_](#links) | Links to related resources

spec/request/apps_spec.rb

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
data: { buildpacks: [buildpack.name], stack: stack.name }
6060
},
6161
relationships: {
62-
space: { data: { guid: space.guid } }
62+
space: { data: { guid: space.guid } },
63+
current_droplet: { data: { guid: nil } }
6364
},
6465
metadata: {
6566
labels: {
@@ -158,6 +159,11 @@
158159
'data' => {
159160
'guid' => space.guid
160161
}
162+
},
163+
'current_droplet' => {
164+
'data' => {
165+
'guid' => nil
166+
}
161167
}
162168
},
163169
'created_at' => iso8601,
@@ -280,6 +286,11 @@
280286
'data' => {
281287
'guid' => space.guid
282288
}
289+
},
290+
'current_droplet' => {
291+
'data' => {
292+
'guid' => nil
293+
}
283294
}
284295
},
285296
'created_at' => iso8601,
@@ -377,7 +388,8 @@
377388
data: { buildpacks: [], stack: app_model1.lifecycle_data.stack }
378389
},
379390
relationships: {
380-
space: { data: { guid: space.guid } }
391+
space: { data: { guid: space.guid } },
392+
current_droplet: { data: { guid: nil } }
381393
},
382394
metadata: {
383395
labels: {},
@@ -414,7 +426,8 @@
414426
data: { buildpacks: [], stack: app_model2.lifecycle_data.stack }
415427
},
416428
relationships: {
417-
space: { data: { guid: space2.guid } }
429+
space: { data: { guid: space2.guid } },
430+
current_droplet: { data: { guid: nil } }
418431
},
419432
metadata: {
420433
labels: {},
@@ -570,6 +583,11 @@
570583
'data' => {
571584
'guid' => space.guid
572585
}
586+
},
587+
'current_droplet' => {
588+
'data' => {
589+
'guid' => nil
590+
}
573591
}
574592
},
575593
'created_at' => iso8601,
@@ -605,6 +623,11 @@
605623
'data' => {
606624
'guid' => space.guid
607625
}
626+
},
627+
'current_droplet' => {
628+
'data' => {
629+
'guid' => nil
630+
}
608631
}
609632
},
610633
'created_at' => iso8601,
@@ -1310,7 +1333,8 @@
13101333
data: { buildpacks: [buildpack.name], stack: app_model.lifecycle_data.stack }
13111334
},
13121335
relationships: {
1313-
space: { data: { guid: space.guid } }
1336+
space: { data: { guid: space.guid } },
1337+
current_droplet: { data: { guid: app_model.droplet_guid } }
13141338
},
13151339
metadata: {
13161340
labels: {},
@@ -1376,6 +1400,11 @@
13761400
'data' => {
13771401
'guid' => space.guid
13781402
}
1403+
},
1404+
'current_droplet' => {
1405+
'data' => {
1406+
'guid' => app_model.droplet_guid
1407+
}
13791408
}
13801409
},
13811410
'links' => {
@@ -1423,6 +1452,11 @@
14231452
'data' => {
14241453
'guid' => space.guid
14251454
}
1455+
},
1456+
'current_droplet' => {
1457+
'data' => {
1458+
'guid' => app_model.droplet_guid
1459+
}
14261460
}
14271461
},
14281462
'links' => {
@@ -2069,6 +2103,11 @@
20692103
'data' => {
20702104
'guid' => space.guid
20712105
}
2106+
},
2107+
'current_droplet' => {
2108+
'data' => {
2109+
'guid' => nil
2110+
}
20722111
}
20732112
},
20742113
'created_at' => iso8601,
@@ -2294,6 +2333,11 @@
22942333
'data' => {
22952334
'guid' => space.guid
22962335
}
2336+
},
2337+
'current_droplet' => {
2338+
'data' => {
2339+
'guid' => droplet.guid
2340+
}
22972341
}
22982342
},
22992343
'links' => {
@@ -2629,6 +2673,11 @@
26292673
'data' => {
26302674
'guid' => space.guid
26312675
}
2676+
},
2677+
'current_droplet' => {
2678+
'data' => {
2679+
'guid' => droplet.guid
2680+
}
26322681
}
26332682
},
26342683
'links' => {
@@ -2793,6 +2842,11 @@
27932842
'data' => {
27942843
'guid' => space.guid
27952844
}
2845+
},
2846+
'current_droplet' => {
2847+
'data' => {
2848+
'guid' => droplet.guid
2849+
}
27962850
}
27972851
},
27982852
'links' => {

spec/request/stacks_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@
399399
'data' => {
400400
'guid' => space.guid
401401
}
402+
},
403+
'current_droplet' => {
404+
'data' => {
405+
'guid' => nil
406+
}
402407
}
403408
},
404409
'created_at' => iso8601,
@@ -463,6 +468,11 @@
463468
'data' => {
464469
'guid' => space.guid
465470
}
471+
},
472+
'current_droplet' => {
473+
'data' => {
474+
'guid' => nil
475+
}
466476
}
467477
},
468478
'created_at' => iso8601,
@@ -501,6 +511,11 @@
501511
'data' => {
502512
'guid' => space2.guid
503513
}
514+
},
515+
'current_droplet' => {
516+
'data' => {
517+
'guid' => nil
518+
}
504519
}
505520
},
506521
'created_at' => iso8601,

spec/unit/presenters/v3/app_presenter_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module VCAP::CloudController::Presenters::V3
77
VCAP::CloudController::AppModel.make(
88
name: 'Davis',
99
environment_variables: { 'some' => 'stuff' },
10-
desired_state: 'STOPPED'
10+
desired_state: 'STOPPED',
11+
droplet: VCAP::CloudController::DropletModel.make
1112
)
1213
end
1314

@@ -53,6 +54,7 @@ module VCAP::CloudController::Presenters::V3
5354
expect(result[:lifecycle][:data][:stack]).to eq('the-happiest-stack')
5455
expect(result[:lifecycle][:data][:buildpacks]).to eq(['git://***:***@github.com/repo', 'limabean'])
5556
expect(result[:relationships][:space][:data][:guid]).to eq(app.space.guid)
57+
expect(result[:relationships][:current_droplet][:data][:guid]).to eq(app.droplet.guid)
5658
expect(result[:metadata][:labels]).to eq({})
5759
expect(result[:metadata][:annotations]).to eq({})
5860
end

0 commit comments

Comments
 (0)