-
Notifications
You must be signed in to change notification settings - Fork 371
Allow unsharing from a space without org visibilty #1024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
34362de
28d141f
afa2108
87dbe9f
3eb6414
f219ad5
b4010d6
dd18177
3d447ba
e98c34c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,7 @@ def update(guid) | |
| validate_access(:read_for_update, service_instance) | ||
| validate_access(:update, projected_service_instance(service_instance)) | ||
|
|
||
| validate_name_update(service_instance) | ||
| validate_space_update(related_objects[:space]) | ||
| validate_plan_update(related_objects[:plan], related_objects[:service], service_instance) | ||
|
|
||
|
|
@@ -360,6 +361,12 @@ def unbind_route(route_guid, instance_guid) | |
|
|
||
| private | ||
|
|
||
| class ServiceInstanceSharedToEagerLoader | ||
| def eager_load_dataset(spaces, _, _, _, _) | ||
| spaces.eager(:organization) | ||
| end | ||
| end | ||
|
|
||
| class ServiceInstanceSharedToSerializer | ||
| def initialize(service_instance) | ||
| @service_instance = service_instance | ||
|
|
@@ -373,7 +380,7 @@ def serialize(controller, space, opts, orphans=nil) | |
|
|
||
| def create_paginated_collection_renderer(service_instance) | ||
| VCAP::CloudController::RestController::PaginatedCollectionRenderer.new( | ||
| VCAP::CloudController::RestController::SecureEagerLoader.new, | ||
| ServiceInstanceSharedToEagerLoader.new, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like a pretty fundamental change to service instances controller. Subverting the framework and how it expects to load associations could lead to confusing behavior later. I'm surprised this didn't break any existing tests. Is there another way we could configure the framework to eager load organizations in addition to it's usual machinations?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The These changes are confined to the |
||
| ServiceInstanceSharedToSerializer.new(service_instance), | ||
| { | ||
| max_results_per_page: config.get(:renderer, :max_results_per_page), | ||
|
|
@@ -432,6 +439,14 @@ def validate_space_update(space) | |
| space_change_not_allowed! if space_change_requested?(request_attrs['space_guid'], space) | ||
| end | ||
|
|
||
| def validate_name_update(service_instance) | ||
| return unless request_attrs['name'] && service_instance.shared? | ||
|
|
||
| if request_attrs['name'] != service_instance.name | ||
| raise CloudController::Errors::ApiError.new_from_details('SharedServiceInstanceCannotBeRenamed') | ||
| end | ||
| end | ||
|
|
||
| def invalid_service_instance!(service_instance) | ||
| raise Sequel::ValidationFailed.new(service_instance) | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| module VCAP::CloudController | ||
| class ManagedServiceInstanceListFetcher | ||
| def fetch(message:, readable_space_guids:) | ||
| source_space_instance_dataset = ManagedServiceInstance.select_all(ServiceInstance.table_name). | ||
| join(Space.table_name, id: :space_id, guid: readable_space_guids) | ||
|
|
||
| shared_instance_dataset = ManagedServiceInstance.select_all(ServiceInstance.table_name). | ||
| join(:service_instance_shares, service_instance_guid: :guid, target_space_guid: readable_space_guids) | ||
|
|
||
| dataset = source_space_instance_dataset.union(shared_instance_dataset, alias: :service_instances) | ||
|
|
||
| filter(dataset, message) | ||
| end | ||
|
|
||
| def fetch_all(message:) | ||
| dataset = ManagedServiceInstance.dataset | ||
| filter(dataset, message) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def filter(dataset, message) | ||
| if message.requested?(:names) | ||
| dataset = dataset.where(service_instances__name: message.names) | ||
| end | ||
|
|
||
| if message.requested?(:space_guids) | ||
| dataset = dataset.select_all(ServiceInstance.table_name). | ||
| join_table(:inner, Space.table_name, { id: Sequel.qualify(:service_instances, :space_id), guid: message.space_guids }) | ||
| end | ||
|
|
||
| dataset | ||
| end | ||
| end | ||
| end |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ### The service_instance object | ||
|
|
||
| Name | Type | Description | ||
| ---- | ---- | ----------- | ||
| **name** | _string_ | Name of the service instance. | ||
| **guid** | _uuid_ | Unique identifier for the service instance. | ||
| **created_at** | _datetime_ | The time with zone when the object was created. | ||
| **updated_at** | _datetime_ | The time with zone when the object was last updated. | ||
| **space** | [_to-one relationship_](#to-one-relationships) | The space the service instance is contained in. | ||
| **links** | [_links object_](#links) | Links to related resources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class will not be private unless you do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, we've made this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes for this included in #1033 and can be viewed here: cloudfoundry-incubator@ff8276e#diff-9b86a08059c9bdc2b6875a70abf9ee29R366