2023-03-07 22:22:08 +00:00
|
|
|
import { useQuery } from 'react-query';
|
|
|
|
|
|
|
|
import { withError } from '@/react-tools/react-query';
|
|
|
|
import { EnvironmentId } from '@/react/portainer/environments/types';
|
|
|
|
|
|
|
|
import { getPVCsForCluster } from './service';
|
|
|
|
|
2023-06-11 21:46:48 +00:00
|
|
|
// useQuery to get a list of all persistent volume claims from an array of namespaces
|
2023-03-07 22:22:08 +00:00
|
|
|
export function usePVCsForCluster(
|
|
|
|
environemtId: EnvironmentId,
|
|
|
|
namespaces?: string[]
|
|
|
|
) {
|
|
|
|
return useQuery(
|
|
|
|
['environments', environemtId, 'kubernetes', 'pvcs'],
|
|
|
|
() => namespaces && getPVCsForCluster(environemtId, namespaces),
|
|
|
|
{
|
2023-06-11 21:46:48 +00:00
|
|
|
...withError('Unable to retrieve perrsistent volume claims'),
|
2023-03-07 22:22:08 +00:00
|
|
|
enabled: !!namespaces,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|