-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Teleterm: add support for access requesting kube namespaces #47347
base: lisa/kube-namespace-3
Are you sure you want to change the base?
Conversation
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
768b594
to
3140a5c
Compare
357f75a
to
65cb297
Compare
@@ -110,12 +114,21 @@ export function AccessRequestCheckout() { | |||
setShowCheckout(false); | |||
} | |||
|
|||
const filteredData = data?.filter(d => |
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.
I don't think we the need optional chaining here.
excludeKubeClusterWithNamespaces(d, data) | ||
); | ||
|
||
const numAddedResources = filteredData?.length; |
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.
And here.
@@ -258,6 +299,7 @@ export type ResourceRequest = | |||
kind: 'kube'; | |||
resource: { | |||
uri: KubeUri; | |||
namespaces?: KubeResourceNamespaceUri[]; |
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 is unused, no?
But I wonder if it wouldn't be more convenient to keep the selected namespaces here, instead of having them as a separate resource (line 313).
Pros:
- We wouldn't need to remember about removing
kube_cluster
resources (from UI/API requests) when there are namespaces selected. - We wouldn't have to remove namespaces manually when a "parent" kube_cluster is removed from the access request.
Cons:
- This would differ from shared types where the namespace is a regular requestable resource. OTOH I feel that the proposed data model is more correct.
I can imagine having a function like this one in AccessRequestsService
:
async addOrRemoveKubeNamespace(resourceUri: KubeResourceNamespaceUri) {
this.setState(draftState => {
if (draftState.pending.kind !== 'resource') {
throw new Error('Cannot add a kube namespace to a role access request');
}
const { resources } = draftState.pending;
const requestedResource = resources.get(
routing.getKubeUri(
routing.parseKubeResourceNamespaceUri(resourceUri).params
)
);
if (!requestedResource || requestedResource.kind !== 'kube') {
throw new Error('Cannot add a kube namespace to a non-kube resource');
}
const kubeResource = requestedResource.resource;
if (!kubeResource.namespaces) {
kubeResource.namespaces = new Set();
}
if (kubeResource.namespaces.has(resourceUri)) {
kubeResource.namespaces.delete(resourceUri);
} else {
kubeResource.namespaces.add(resourceUri);
}
});
}
Please let me know what do you think about it :)
kubernetesCluster: kubeCluster, | ||
kubernetesNamespace: '', | ||
}); | ||
return response.resources.map(i => { |
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.
What do you think of returning Promise<string>
here?
We could do the mapping to Option
in KubeNamespaceSelector
.
part of #46742
requires:
role.options
field calledrequest_mode.kubernetes_resources
#47173if you want to test connect, i have a staging cluster that i can invite to then:
lisa/connect-team
(it has all the necessary PRs stiched)when request mode requires you to request for namespace
when request mode is a kind that UI doesn't support, it disables the checkout regardless of other resources (it is enabled once user removes the kubernetes):
demo (when no request mode is specified, allows requesting for a
kube_cluster
or akube_clusters
namespace):Screen.Recording.2024-10-08.at.11.58.11.PM.mov
changelog: Add Connect support for selecting Kubernetes namespaces during access requests