Skip to content
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

[Workspace] Add APIs to support plugin state in request #6303

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Apr 2, 2024

Description

Workspace need to store its workspace id throughout the whole request lifecycle but for now OpensearchDashboardsRequest only provides readonly interfaces. In order to add some states into the request without any impact on the response header or the connection between OSD and opensearch cluster, workspace will leverage the app interface in the raw request.

How will the functions be used in workspace:

Issues Resolved

partial resolve #6130

Screenshot

Testing the changes

This PR only introduces a function to mutate the request.app.requestWorkspaceId field and has already been covered by unit test. Will have a following PR to consume such function and we can test in that PR.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

…#312)

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.51%. Comparing base (b92387a) to head (cf21980).
Report is 549 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6303   +/-   ##
=======================================
  Coverage   67.50%   67.51%           
=======================================
  Files        3376     3377    +1     
  Lines       65830    65836    +6     
  Branches    10648    10648           
=======================================
+ Hits        44441    44449    +8     
+ Misses      18803    18802    -1     
+ Partials     2586     2585    -1     
Flag Coverage Δ
Linux_1 32.60% <33.33%> (+<0.01%) ⬆️
Linux_2 55.61% <100.00%> (+0.01%) ⬆️
Linux_3 44.89% <33.33%> (+0.01%) ⬆️
Linux_4 34.99% <33.33%> (-0.01%) ⬇️
Windows_1 32.62% <33.33%> (+<0.01%) ⬆️
Windows_2 55.58% <100.00%> (+0.01%) ⬆️
Windows_3 44.89% <33.33%> (-0.01%) ⬇️
Windows_4 34.99% <33.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@SuZhou-Joe SuZhou-Joe changed the title feat: add APIs to support plugin state in request [Workspace] Add APIs to support plugin state in request Apr 2, 2024
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
src/core/server/utils/workspace.ts Outdated Show resolved Hide resolved
src/core/server/utils/workspace.ts Show resolved Hide resolved
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@ruanyl
Copy link
Member

ruanyl commented Apr 3, 2024

@SuZhou-Joe would you mind to update the PR description a bit to include how will updateWorkspaceState and getWorkspaceState be used? Just for more context for the other reviewers, I believe the workspace saved object wrapper will use it as we discussed offline.

@SuZhou-Joe
Copy link
Member Author

update the PR description a bit to include how will updateWorkspaceState and getWorkspaceState be used

Sure, updated.

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
ruanyl
ruanyl previously approved these changes Apr 3, 2024
BionIT
BionIT previously approved these changes Apr 3, 2024
src/core/server/utils/workspace.ts Outdated Show resolved Hide resolved
*/
export const updateWorkspaceState = (
request: OpenSearchDashboardsRequest,
payload: Partial<WorkspaceState>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like workspacestate only has one field which is optional, is it necessary to specify partial?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes because actually the function just spread all the property into the request.app, which means user can pass in partial of the WorkspaceState to update the state.

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@SuZhou-Joe SuZhou-Joe dismissed stale reviews from BionIT and ruanyl via 9813351 April 4, 2024 15:22
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@ZilongX
Copy link
Collaborator

ZilongX commented Apr 4, 2024

LGTM, looking forward to the actual consumption of the updated API

@SuZhou-Joe SuZhou-Joe merged commit fc3fef2 into opensearch-project:main Apr 4, 2024
68 checks passed
SuZhou-Joe added a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Apr 6, 2024
…roject#6303)

* feat: add APIs to support plugin state in request (opensearch-project#312)

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: use request app to store request workspace id

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless if

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
SuZhou-Joe added a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Apr 7, 2024
…roject#6303)

* feat: add APIs to support plugin state in request (opensearch-project#312)

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: use request app to store request workspace id

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless if

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
SuZhou-Joe added a commit to ruanyl/OpenSearch-Dashboards that referenced this pull request Apr 7, 2024
…roject#6303) (#315)

* feat: add APIs to support plugin state in request (#312)

* feat: add APIs to support plugin state in request



* feat: add APIs to support plugin state in request



---------



* feat: update CHANGELOG



* feat: update



* feat: use request app to store request workspace id



* feat: remove useless if



---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 19, 2024
* feat: add APIs to support plugin state in request (#312)

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: use request app to store request workspace id

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless if

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit fc3fef2)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
SuZhou-Joe pushed a commit that referenced this pull request Apr 19, 2024
* feat: add APIs to support plugin state in request (#312)

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add APIs to support plugin state in request

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: use request app to store request workspace id

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: remove useless if

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit fc3fef2)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Workspace] support workspace in saved objects client
5 participants