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

Add extension-api facades to cluster & workspace stores #1546

Merged

Conversation

jakolehm
Copy link
Contributor

@jakolehm jakolehm commented Nov 27, 2020

Both Cluster and Workspace stores currently leak internals to extension-api. This PR adds a facade store for both of them and exposes only usable apis.

This also allows us to work more freely on store internals (we only expose apis explicitly). Good example of accidental leaks is #1453 .

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm added area/extension Something to related to the extension api discussion Initial discussions and proposals labels Nov 27, 2020
@jakolehm jakolehm requested a review from a team November 27, 2020 07:30
@nevalla
Copy link
Contributor

nevalla commented Nov 27, 2020

I like the idea. With this we can refactor internal store without breaking the Extensions API and we don't need to expose all internal methods to extensions.

/**
* Active cluster id
*/
activeClusterId = internalClusterStore.activeCluster;
Copy link
Collaborator

Choose a reason for hiding this comment

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

have you tested that this works? When I was thinking about it yesterday I wasn't convinced that this would work and that we would have to do something like the following:

Suggested change
activeClusterId = internalClusterStore.activeCluster;
get activeClusterId() {
return internalClusterStore.activeCluster;
}
set activeClusterId(newId: string) {
internalClusterStore.activeCluster = newId;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get/set is better.

src/extensions/stores/cluster-store.ts Outdated Show resolved Hide resolved
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
Copy link
Collaborator

@Nokel81 Nokel81 left a comment

Choose a reason for hiding this comment

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

Looks good, definitely a better way of making sure that we don't leak APIs to extensions.

src/extensions/stores/workspace-store.ts Show resolved Hide resolved
@jakolehm jakolehm added bug Something isn't working and removed discussion Initial discussions and proposals labels Nov 27, 2020
@jakolehm jakolehm added this to the 4.0.0 milestone Nov 27, 2020
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
@jakolehm jakolehm merged commit 07e6df9 into master Nov 30, 2020
@jakolehm jakolehm deleted the fix/stop-leaking-cluster-and-workspace-store-internals branch November 30, 2020 07:36
@jakolehm jakolehm mentioned this pull request Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants