Skip to content

Commit 1ee2ea6

Browse files
authored
Add "created_at" and "updated_at" to route mappings (#4463)
* Add "created_at" and "updated_at" to route mappings * Fix request specs (add created_at and updated_at to destinations) * Fix route_presenter_spec (add created_at and updated_at to destinations)
1 parent 1481ea1 commit 1ee2ea6

File tree

7 files changed

+64
-21
lines changed

7 files changed

+64
-21
lines changed

app/presenters/v3/route_destination_presenter.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def destination_hash
2727
},
2828
weight: destination.weight,
2929
port: destination.presented_port,
30-
protocol: destination.protocol
30+
protocol: destination.protocol,
31+
created_at: destination.created_at,
32+
updated_at: destination.updated_at
3133
}
3234
end
3335

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

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
},
2020
"weight": null,
2121
"port": 8080,
22-
"protocol": "tcp"
22+
"protocol": "tcp",
23+
"created_at": "2019-05-10T17:17:48Z",
24+
"updated_at": "2019-05-10T17:17:48Z"
2325
},
2426
{
2527
"guid": "27e96a3b-5bcf-49ed-8048-351e0be23e6f",
@@ -31,7 +33,9 @@
3133
},
3234
"weight": null,
3335
"port": 8080,
34-
"protocol": "tcp"
36+
"protocol": "tcp",
37+
"created_at": "2019-05-10T17:17:48Z",
38+
"updated_at": "2019-05-10T17:17:48Z"
3539
}
3640
],
3741
"options": {
@@ -112,7 +116,9 @@
112116
},
113117
"weight": null,
114118
"port": 8080,
115-
"protocol": "http1"
119+
"protocol": "http1",
120+
"created_at": "2019-05-10T17:17:48Z",
121+
"updated_at": "2019-05-10T17:17:48Z"
116122
},
117123
{
118124
"guid": "27e96a3b-5bcf-49ed-8048-351e0be23e6f",
@@ -124,7 +130,9 @@
124130
},
125131
"weight": null,
126132
"port": 8080,
127-
"protocol": "http1"
133+
"protocol": "http1",
134+
"created_at": "2019-05-10T17:17:48Z",
135+
"updated_at": "2019-05-10T17:17:48Z"
128136
}
129137
],
130138
"options": {
@@ -178,7 +186,9 @@
178186
},
179187
"weight": null,
180188
"port": 8080,
181-
"protocol": "http2"
189+
"protocol": "http2",
190+
"created_at": "2019-05-10T17:17:48Z",
191+
"updated_at": "2019-05-10T17:17:48Z"
182192
},
183193
{
184194
"guid": "fbef10a2-8ee7-11e9-aa2d-abeeaf7b83c5",
@@ -190,7 +200,9 @@
190200
},
191201
"weight": null,
192202
"port": 9000,
193-
"protocol": "http1"
203+
"protocol": "http1",
204+
"created_at": "2019-05-10T17:17:48Z",
205+
"updated_at": "2019-05-10T17:17:48Z"
194206
}
195207
],
196208
"links": {
@@ -215,7 +227,9 @@
215227
},
216228
"weight": null,
217229
"port": 8080,
218-
"protocol": "http2"
230+
"protocol": "http2",
231+
"created_at": "2019-05-10T17:17:48Z",
232+
"updated_at": "2019-05-10T17:17:48Z"
219233
}
220234
<% end %>
221235

docs/v3/source/includes/resources/routes/_destination_object.md.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ If a destination does not specify a port, the default port depends on the app li
2626
| **port** | _integer_ | Port on the destination process to route traffic to
2727
| **weight** (*deprecated*) | _integer_ or `null` | Percentage of traffic which will be routed to this destination. _**DEPRECATED:** this feature was only available via the experimental Service Mesh routing plane. It is no longer supported._ |
2828
| **protocol** | _string_ or `null` | Protocol to use for this destination. Valid protocols are `http1` or `http2` if route protocol is `http`, `tcp` if route protocol is `tcp`. A `null` value will set it either `http1` or `tcp` based on the route protocol; _this feature is only available if you turn it on in routing release_ |
29+
| **created_at** | _[timestamp](#timestamps)_| The time with zone when the object was created |
30+
| **updated_at** | _[timestamp](#timestamps)_| The time with zone when the object was last updated |

spec/request/route_destinations_spec.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@
145145
},
146146
weight: nil,
147147
port: 8080,
148-
protocol: 'http1'
148+
protocol: 'http1',
149+
created_at: destination.created_at.iso8601,
150+
updated_at: destination.updated_at.iso8601
149151
}
150152
],
151153
links: {
@@ -268,7 +270,9 @@
268270
},
269271
weight: nil,
270272
port: 8080,
271-
protocol: 'http1'
273+
protocol: 'http1',
274+
created_at: existing_destination.created_at.iso8601,
275+
updated_at: existing_destination.updated_at.iso8601
272276
},
273277
{
274278
guid: UUID_REGEX,
@@ -280,7 +284,9 @@
280284
},
281285
weight: nil,
282286
port: 8080,
283-
protocol: 'http2'
287+
protocol: 'http2',
288+
created_at: iso8601,
289+
updated_at: iso8601
284290
}
285291
],
286292
links: {
@@ -791,7 +797,9 @@
791797
},
792798
weight: nil,
793799
port: 8080,
794-
protocol: 'http2'
800+
protocol: 'http2',
801+
created_at: iso8601,
802+
updated_at: iso8601
795803
}
796804
],
797805
links: {

spec/request/routes_spec.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
},
6565
weight: route_in_org_dest_web.weight,
6666
port: route_in_org_dest_web.presented_port,
67-
protocol: 'http1'
67+
protocol: 'http1',
68+
created_at: iso8601,
69+
updated_at: iso8601
6870
}, {
6971
guid: route_in_org_dest_worker.guid,
7072
app: {
@@ -75,7 +77,9 @@
7577
},
7678
weight: route_in_org_dest_worker.weight,
7779
port: route_in_org_dest_worker.presented_port,
78-
protocol: 'http1'
80+
protocol: 'http1',
81+
created_at: iso8601,
82+
updated_at: iso8601
7983
}),
8084
relationships: {
8185
space: {
@@ -3607,7 +3611,9 @@
36073611
},
36083612
weight: route_mapping1.weight,
36093613
port: route_mapping1.presented_port,
3610-
protocol: 'http1'
3614+
protocol: 'http1',
3615+
created_at: iso8601,
3616+
updated_at: iso8601
36113617
}),
36123618
relationships: {
36133619
space: {
@@ -3651,7 +3657,9 @@
36513657
},
36523658
weight: route_mapping2.weight,
36533659
port: route_mapping2.presented_port,
3654-
protocol: 'http1'
3660+
protocol: 'http1',
3661+
created_at: iso8601,
3662+
updated_at: iso8601
36553663
}),
36563664
relationships: {
36573665
space: {

spec/unit/presenters/v3/route_destination_presenter_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ module VCAP::CloudController::Presenters::V3
1313
app_port: 1234,
1414
route: route,
1515
process_type: 'web',
16-
weight: 55
16+
weight: 55,
17+
created_at: Time.at(1)
1718
)
1819
end
1920

@@ -37,7 +38,9 @@ module VCAP::CloudController::Presenters::V3
3738
route: {
3839
href: "http://api2.vcap.me/v3/routes/#{route.guid}"
3940
}
40-
}
41+
},
42+
created_at: Time.at(1),
43+
updated_at: route_mapping.updated_at
4144
)
4245
end
4346
end
@@ -54,7 +57,9 @@ module VCAP::CloudController::Presenters::V3
5457
},
5558
weight: route_mapping.weight,
5659
port: route_mapping.presented_port,
57-
protocol: route_mapping.protocol
60+
protocol: route_mapping.protocol,
61+
created_at: Time.at(1),
62+
updated_at: route_mapping.updated_at
5863
)
5964
end
6065
end

spec/unit/presenters/v3/route_presenter_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ module VCAP::CloudController::Presenters::V3
8686
},
8787
weight: destination.weight,
8888
port: destination.presented_port,
89-
protocol: destination.protocol
89+
protocol: destination.protocol,
90+
created_at: destination.created_at,
91+
updated_at: destination.updated_at
9092
},
9193
{
9294
guid: destination2.guid,
@@ -98,7 +100,9 @@ module VCAP::CloudController::Presenters::V3
98100
},
99101
weight: destination2.weight,
100102
port: destination2.presented_port,
101-
protocol: destination2.protocol
103+
protocol: destination2.protocol,
104+
created_at: destination.created_at,
105+
updated_at: destination.updated_at
102106
}
103107
]
104108
expect(subject[:destinations]).to match_array(expected_destinations)

0 commit comments

Comments
 (0)