mirror of https://github.com/portainer/portainer
feat(k8s):add kubeconfig expiry days on mouse hover EE-1300 (#5589)
* add kubeconfig expiry days on mouse hover * replace settings with publicSettings for non-admin userpull/5605/head
parent
d8b88d1004
commit
756ef060db
|
@ -22,6 +22,8 @@ type publicSettingsResponse struct {
|
||||||
OAuthLogoutURI string `json:"OAuthLogoutURI" example:"https://gitlab.com/oauth/logout"`
|
OAuthLogoutURI string `json:"OAuthLogoutURI" example:"https://gitlab.com/oauth/logout"`
|
||||||
// Whether telemetry is enabled
|
// Whether telemetry is enabled
|
||||||
EnableTelemetry bool `json:"EnableTelemetry" example:"true"`
|
EnableTelemetry bool `json:"EnableTelemetry" example:"true"`
|
||||||
|
// The expiry of a Kubeconfig
|
||||||
|
KubeconfigExpiry string `example:"24h" default:"0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// @id SettingsPublic
|
// @id SettingsPublic
|
||||||
|
@ -49,6 +51,7 @@ func generatePublicSettings(appSettings *portainer.Settings) *publicSettingsResp
|
||||||
AuthenticationMethod: appSettings.AuthenticationMethod,
|
AuthenticationMethod: appSettings.AuthenticationMethod,
|
||||||
EnableEdgeComputeFeatures: appSettings.EnableEdgeComputeFeatures,
|
EnableEdgeComputeFeatures: appSettings.EnableEdgeComputeFeatures,
|
||||||
EnableTelemetry: appSettings.EnableTelemetry,
|
EnableTelemetry: appSettings.EnableTelemetry,
|
||||||
|
KubeconfigExpiry: appSettings.KubeconfigExpiry,
|
||||||
}
|
}
|
||||||
//if OAuth authentication is on, compose the related fields from application settings
|
//if OAuth authentication is on, compose the related fields from application settings
|
||||||
if publicSettings.AuthenticationMethod == portainer.AuthenticationOAuth {
|
if publicSettings.AuthenticationMethod == portainer.AuthenticationOAuth {
|
||||||
|
|
|
@ -1,15 +1,45 @@
|
||||||
export default class KubeConfigController {
|
export default class KubeConfigController {
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor($window, KubernetesConfigService) {
|
constructor($async, $window, KubernetesConfigService, SettingsService) {
|
||||||
|
this.$async = $async;
|
||||||
this.$window = $window;
|
this.$window = $window;
|
||||||
this.KubernetesConfigService = KubernetesConfigService;
|
this.KubernetesConfigService = KubernetesConfigService;
|
||||||
|
this.SettingsService = SettingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadKubeconfig() {
|
async downloadKubeconfig() {
|
||||||
await this.KubernetesConfigService.downloadConfig();
|
await this.KubernetesConfigService.downloadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async expiryHoverMessage() {
|
||||||
|
const settings = await this.SettingsService.publicSettings();
|
||||||
|
const expiryDays = settings.KubeconfigExpiry;
|
||||||
|
switch (expiryDays) {
|
||||||
|
case '0':
|
||||||
|
this.state.expiryDays = 'not expire';
|
||||||
|
break;
|
||||||
|
case '24h':
|
||||||
|
this.state.expiryDays = 'expire in 1 day';
|
||||||
|
break;
|
||||||
|
case '168h':
|
||||||
|
this.state.expiryDays = 'expire in 7 days';
|
||||||
|
break;
|
||||||
|
case '720h':
|
||||||
|
this.state.expiryDays = 'expire in 30 days';
|
||||||
|
break;
|
||||||
|
case '8640h':
|
||||||
|
this.state.expiryDays = 'expire in 1 year';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
this.state = { isHTTPS: this.$window.location.protocol === 'https:' };
|
return this.$async(async () => {
|
||||||
|
this.state = {
|
||||||
|
isHTTPS: this.$window.location.protocol === 'https:',
|
||||||
|
expiryDays: '',
|
||||||
|
};
|
||||||
|
await this.expiryHoverMessage();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<button
|
<span class="interactive" tooltip-append-to-body="true" tooltip-placement="bottom" tooltip-class="portainer-tooltip" uib-tooltip="Kubeconfig file will {{ $ctrl.state.expiryDays }}">
|
||||||
|
<button
|
||||||
ng-if="$ctrl.state.isHTTPS"
|
ng-if="$ctrl.state.isHTTPS"
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-xs btn-primary"
|
class="btn btn-xs btn-primary"
|
||||||
|
@ -9,3 +10,4 @@
|
||||||
>
|
>
|
||||||
Kubeconfig <i class="fas fa-download space-right"></i>
|
Kubeconfig <i class="fas fa-download space-right"></i>
|
||||||
</button>
|
</button>
|
||||||
|
</span>
|
||||||
|
|
|
@ -21,6 +21,7 @@ export function PublicSettingsViewModel(settings) {
|
||||||
this.OAuthLoginURI = settings.OAuthLoginURI;
|
this.OAuthLoginURI = settings.OAuthLoginURI;
|
||||||
this.EnableTelemetry = settings.EnableTelemetry;
|
this.EnableTelemetry = settings.EnableTelemetry;
|
||||||
this.OAuthLogoutURI = settings.OAuthLogoutURI;
|
this.OAuthLogoutURI = settings.OAuthLogoutURI;
|
||||||
|
this.KubeconfigExpiry = settings.KubeconfigExpiry;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LDAPSettingsViewModel(data) {
|
export function LDAPSettingsViewModel(data) {
|
||||||
|
|
Loading…
Reference in New Issue