mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
feat(oci): oci helm support [r8s-361] (#787)
This commit is contained in:
parent
b6a6ce9aaf
commit
2697d6c5d7
80 changed files with 4264 additions and 812 deletions
|
@ -4,8 +4,11 @@ import axios, { parseAxiosError } from '@/portainer/services/axios';
|
|||
import { withGlobalError } from '@/react-tools/react-query';
|
||||
|
||||
type Params = {
|
||||
/** The name of the chart to get the values for */
|
||||
chart: string;
|
||||
/** The repository URL or registry ID */
|
||||
repo: string;
|
||||
/** The version of the chart to get the values for */
|
||||
version?: string;
|
||||
};
|
||||
|
||||
|
@ -16,18 +19,26 @@ async function getHelmChartValues(params: Params) {
|
|||
});
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
throw parseAxiosError(err as Error, 'Unable to get Helm chart values');
|
||||
throw parseAxiosError(err, 'Unable to get Helm chart values');
|
||||
}
|
||||
}
|
||||
|
||||
export function useHelmChartValues(params: Params) {
|
||||
export function useHelmChartValues(params: Params, isLatestVersion = false) {
|
||||
const hasValidRepoUrl = !!params.repo;
|
||||
return useQuery({
|
||||
queryKey: ['helm-chart-values', params.repo, params.chart, params.version],
|
||||
queryKey: [
|
||||
'helm-chart-values',
|
||||
params.repo,
|
||||
params.chart,
|
||||
// if the latest version is fetched, use the latest version key to cache the latest version
|
||||
isLatestVersion ? 'latest' : params.version,
|
||||
],
|
||||
queryFn: () => getHelmChartValues(params),
|
||||
enabled: !!params.chart && !!params.repo,
|
||||
enabled: !!params.chart && hasValidRepoUrl,
|
||||
select: (data) => ({
|
||||
values: data,
|
||||
}),
|
||||
retry: 1,
|
||||
staleTime: 60 * 1000 * 20, // 60 minutes, because values are not expected to change often
|
||||
...withGlobalError('Unable to get Helm chart values'),
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue