Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 90e01de

Browse files
Handle v2 manifest diffs
- Accomplish this by merging the "web" process into the top level hash on the left side of the diff. If the user passed manifest (the right side of the diff) specifies these keys, then a diff may be shown. If they do not, the keys will be omitted from the diff. [#173802711](https://www.pivotaltracker.com/story/show/173802711) Co-authored-by: Mona Mohebbi <mmohebbi@pivotal.io> Co-authored-by: Nick Webb <nwebb@pivotal.io>
1 parent 7220f9c commit 90e01de

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

app/actions/space_diff_manifest.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ def self.generate_diff(app_manifests, space)
1818
existing_app.routes,
1919
)
2020
existing_app_hash = manifest_presenter.to_hash.deep_stringify_keys['applications'][0]
21+
web_process_hash = existing_app_hash['processes'].find { |p| p['type'] == 'web' }
22+
existing_app_hash = existing_app_hash.merge(web_process_hash) if web_process_hash
2123
end
2224

2325
manifest_app_hash.each do |key, value|
@@ -28,7 +30,6 @@ def self.generate_diff(app_manifests, space)
2830
value,
2931
include_was: true,
3032
)
31-
3233
key_diffs.each do |diff|
3334
diff['path'] = "/applications/#{index}/#{key}" + diff['path']
3435

spec/request/space_manifests_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,29 @@
511511
h.freeze
512512
end
513513

514+
context 'when a v2 manifest has a change to the web process' do
515+
let(:diff_json) do
516+
{
517+
diff: a_collection_containing_exactly(
518+
{ op: 'replace', path: '/applications/0/memory', was: '1024M', value: '256M' },
519+
)
520+
}
521+
end
522+
523+
let(:yml_manifest) do
524+
{
525+
'applications' => [
526+
{
527+
'name' => app1_model.name,
528+
'memory' => '256M'
529+
}
530+
]
531+
}.to_yaml
532+
end
533+
534+
it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS
535+
end
536+
514537
context 'when there are changes in the manifest' do
515538
let(:diff_json) do
516539
{

spec/unit/actions/space_diff_manifest_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,25 @@ module VCAP::CloudController
114114
])
115115
end
116116
end
117+
118+
context 'when the user passes in a v2 manifest' do
119+
let(:default_manifest) {
120+
{
121+
'applications' => [
122+
{
123+
'name' => app1_model.name,
124+
'memory' => '256M'
125+
}
126+
]
127+
}
128+
}
129+
130+
it 'returns the correct diff' do
131+
expect(subject).to match_array([
132+
{ 'op' => 'replace', 'path' => '/applications/0/memory', 'was' => "#{process1.memory}M", 'value' => '256M' },
133+
])
134+
end
135+
end
117136
end
118137
end
119138
end

0 commit comments

Comments
 (0)