You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/kubernetes/services/kubeconfig.service.ts

24 lines
755 B

import { saveAs } from 'file-saver';
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { EnvironmentId } from '@/portainer/environments/types';
const baseUrl = 'kubernetes';
export async function downloadKubeconfigFile(environmentIds: EnvironmentId[]) {
try {
const { headers, data } = await axios.get<Blob>(`${baseUrl}/config`, {
params: { ids: JSON.stringify(environmentIds) },
responseType: 'blob',
headers: {
Accept: 'text/yaml',
},
});
const contentDispositionHeader = headers['content-disposition'];
const filename = contentDispositionHeader.replace('attachment;', '').trim();
saveAs(data, filename);
} catch (e) {
throw parseAxiosError(e as Error, '');
}
}