Files
Chaim Lev-Ari dd68560ad0 chore(deps): upgrade prettier (#2592)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 16:39:58 +03:00

26 lines
951 B
TypeScript

import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
import { useEnvironmentRegistries } from '@/react/portainer/environments/queries/useEnvironmentRegistries';
import { Registry } from '@/react/portainer/registries/types/registry';
/** get all secrets linked to the default service account in the namespace using the registry access settings */
export function useSecretsLinkedToDefaultSA(namespace: string) {
const environmentId = useEnvironmentId();
return useEnvironmentRegistries(environmentId, {
select: (registries) =>
filterRegistrySecretNamesForNamespace(registries, namespace),
});
function filterRegistrySecretNamesForNamespace(
registries: Registry[],
namespace: string
) {
return registries
.filter((registry) =>
registry.RegistryAccesses?.[environmentId]?.Namespaces?.includes(
namespace
)
)
.map((registry) => `registry-${registry.Id}`);
}
}