-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor: move workspace logic from repository to saved objects client wrapper #248
Refactor: move workspace logic from repository to saved objects client wrapper #248
Conversation
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
...plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
Show resolved
Hide resolved
...plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
Show resolved
Hide resolved
...plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
Outdated
Show resolved
Hide resolved
...plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
Show resolved
Hide resolved
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
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.
Left a comment, nice refactor!
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.
Can we encapsulate this wrapper with the existing WorkspaceSavedObjectsClientWrapper
? This may save some API calls to wrapperOptions.client.get
and wrapperOptions.client.bulkGet
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.
Yeah, sounds reasonable. Will take a look then.
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.
Did some research and it seems that these two wrappers are controlled by different flags: workspace.enabled
and workspace.permission.enabled
. I am afraid combining these two wrappers as one may lead to complex if/else. And as we will merge the conflict wrapper before permission check wrapper, I'd like to raise a following issue to optimize the code if we have more bandwidth on 2.13.
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.
if they are for different purpose and can be used independently, better to have separate wrappers
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## workspace #248 +/- ##
=============================================
+ Coverage 66.24% 66.75% +0.51%
=============================================
Files 3438 3337 -101
Lines 66264 64801 -1463
Branches 10694 10453 -241
=============================================
- Hits 43899 43261 -638
+ Misses 19757 18952 -805
+ Partials 2608 2588 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@@ -81,7 +81,7 @@ export class SavedObjectsUtils { | |||
saved_objects: [], | |||
}); | |||
|
|||
public static filterWorkspacesAccordingToBaseWorkspaces( | |||
public static filterWorkspacesAccordingToSourceWorkspaces( |
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.
Seems this function is only used by src/plugins/workspace/server/saved_objects/saved_objects_wrapper_for_check_workspace_conflict.ts
, I think we can move it there so we don't need to bother this util class in core
/** | ||
* workspaces the objects belong to, will only be used when overwrite is enabled. | ||
*/ | ||
workspaces?: string[]; |
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.
Isn't workspaces
already specified in the options? SavedObjectsBaseOptions
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.
The SavedObjectsBulkCreateObject
doesn't extends SavedObjectsBaseOptions
.
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-workspace-pr-integr workspace-pr-integr
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-workspace-pr-integr
# Create a new branch
git switch --create backport/backport-248-to-workspace-pr-integr
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 415605f437ed138d4d8f5c08fa67a2b905ece4ff
# Push it to GitHub
git push --set-upstream origin backport/backport-248-to-workspace-pr-integr
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-workspace-pr-integr Then, create a pull request where the |
Description
Move workspace check conflict related logic to a saved objects client wrapper so that the logic can be turned off once workspace plugin is disabled, introducing as less as possible effect on OSD core.
Issues Resolved
Screenshot
Testing the changes
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr