mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feature(kubeconfig): access to all kube environment contexts from within the Portainer UI [EE-1727] (#5966)
This commit is contained in:
parent
c0a4727114
commit
6be1ff4d9c
22 changed files with 404 additions and 434 deletions
|
@ -2,18 +2,38 @@ import angular from 'angular';
|
|||
|
||||
class KubernetesConfigService {
|
||||
/* @ngInject */
|
||||
constructor(KubernetesConfig, FileSaver) {
|
||||
constructor(KubernetesConfig, FileSaver, SettingsService) {
|
||||
this.KubernetesConfig = KubernetesConfig;
|
||||
this.FileSaver = FileSaver;
|
||||
this.SettingsService = SettingsService;
|
||||
}
|
||||
|
||||
async downloadConfig() {
|
||||
const response = await this.KubernetesConfig.get();
|
||||
async downloadKubeconfigFile(environmentIDs) {
|
||||
const response = await this.KubernetesConfig.get(environmentIDs);
|
||||
const headers = response.headers();
|
||||
const contentDispositionHeader = headers['content-disposition'];
|
||||
const filename = contentDispositionHeader.replace('attachment;', '').trim();
|
||||
return this.FileSaver.saveAs(response.data, filename);
|
||||
}
|
||||
|
||||
async expiryMessage() {
|
||||
const settings = await this.SettingsService.publicSettings();
|
||||
const expiryDays = settings.KubeconfigExpiry;
|
||||
const prefix = 'Kubeconfig file will ';
|
||||
switch (expiryDays) {
|
||||
case '0':
|
||||
return prefix + 'not expire.';
|
||||
case '24h':
|
||||
return prefix + 'expire in 1 day.';
|
||||
case '168h':
|
||||
return prefix + 'expire in 7 days.';
|
||||
case '720h':
|
||||
return prefix + 'expire in 30 days.';
|
||||
case '8640h':
|
||||
return prefix + 'expire in 1 year.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesConfigService;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue