Skip to content

Project Import: Use allowed namespaces when importing#7

Draft
sniok wants to merge 2 commits intoAzure:mainfrom
sniok:import-project-fixes
Draft

Project Import: Use allowed namespaces when importing#7
sniok wants to merge 2 commits intoAzure:mainfrom
sniok:import-project-fixes

Conversation

@sniok
Copy link
Collaborator

@sniok sniok commented Nov 21, 2025

Requires #8


Use allowed namespaces when importing
Cancel namespace websocket connection after checking if the project is aks one

@sniok sniok marked this pull request as ready for review December 3, 2025 17:01
@Tatsinnit Tatsinnit requested review from ashu8912 and yolossn December 9, 2025 17:29
@Tatsinnit Tatsinnit added the enhancement New feature or request label Dec 9, 2025
Copy link
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

In the commit messages.. it would be good to have the components modified. eg. "ImportAKSProjects:"

ps. Are we going with aksd:? (or aks-plugin: btw, maybe we should move the folder from "plugins/aks-desktop" to "aks" then we can use the shorter "aks" and not have the plugins folder with the only plugin ever used in this repo?

@illume illume marked this pull request as draft December 29, 2025 13:29
@sniok sniok marked this pull request as ready for review January 12, 2026 19:39
Copilot AI review requested due to automatic review settings January 12, 2026 19:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request implements allowed namespace support for AKS project imports and adds cleanup of WebSocket connections after checking if a project is an AKS-managed one.

Changes:

  • Add cancellation of namespace WebSocket connection after verifying if a project is AKS-managed
  • Configure allowed namespaces in localStorage during cluster import to restrict namespace visibility

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
plugins/aks-desktop/src/utils/shared/isAksProject.tsx Adds WebSocket connection cancellation after checking if a project is AKS-managed
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx Configures allowed namespaces in cluster settings during import
Comments suppressed due to low confidence (1)

plugins/aks-desktop/src/utils/shared/isAksProject.tsx:21

  • The cancel function should also be called in the error handler to properly clean up the WebSocket connection. Currently, the WebSocket connection is only cancelled in the success callback but not when an error occurs, which could lead to resource leaks.
      () => {
        res(false);
      },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

localStorage.getItem(`cluster_settings.${clusterName}`) || '{}'
);
settings.allowedNamespaces ??= [];
settings.allowedNamespaces.push(...namespacesInCluster.map(it => it.namespace.name));
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The allowedNamespaces array can contain duplicates if the import function is called multiple times for the same cluster. Consider checking if a namespace already exists in the array before adding it, or use a Set to ensure uniqueness. This could happen if a user imports the same namespaces again.

Suggested change
settings.allowedNamespaces.push(...namespacesInCluster.map(it => it.namespace.name));
const allowedNamespacesSet = new Set<string>(settings.allowedNamespaces);
for (const { namespace } of namespacesInCluster) {
allowedNamespacesSet.add(namespace.name);
}
settings.allowedNamespaces = Array.from(allowedNamespacesSet);

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this can't hurt doing.

Comment on lines +264 to +266
const settings = JSON.parse(
localStorage.getItem(`cluster_settings.${clusterName}`) || '{}'
);
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The JSON.parse call could throw an exception if the localStorage value is not valid JSON. While the fallback of '{}' handles the case when the value doesn't exist, if the value exists but is corrupted or malformed, it will throw an error. Consider wrapping this in a try-catch block to handle potential parse errors gracefully.

Suggested change
const settings = JSON.parse(
localStorage.getItem(`cluster_settings.${clusterName}`) || '{}'
);
const rawSettings = localStorage.getItem(`cluster_settings.${clusterName}`);
let settings: any;
try {
settings = rawSettings ? JSON.parse(rawSettings) : {};
} catch {
settings = {};
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here. It's a valid point IMHO.

@illume
Copy link
Collaborator

illume commented Jan 13, 2026

For the commit message, can you please add the component to the context? ImportAKSProjects.tsx

@illume illume marked this pull request as draft January 26, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants