mirror of https://github.com/portainer/portainer
feat(kubernetes): Prevent deployment/edition of resources inside a system namespace (#4039)
* feat(kubernetes): Prevent deployment/edition of resources inside a system namespace * feat(kubernetes): minor UI update Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>pull/4029/head
parent
181a6f4553
commit
8b79f2524d
|
@ -37,7 +37,8 @@ class KubernetesCreateApplicationController {
|
|||
KubernetesStackService,
|
||||
KubernetesConfigurationService,
|
||||
KubernetesNodeService,
|
||||
KubernetesPersistentVolumeClaimService
|
||||
KubernetesPersistentVolumeClaimService,
|
||||
KubernetesNamespaceHelper
|
||||
) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
|
@ -51,6 +52,7 @@ class KubernetesCreateApplicationController {
|
|||
this.KubernetesConfigurationService = KubernetesConfigurationService;
|
||||
this.KubernetesNodeService = KubernetesNodeService;
|
||||
this.KubernetesPersistentVolumeClaimService = KubernetesPersistentVolumeClaimService;
|
||||
this.KubernetesNamespaceHelper = KubernetesNamespaceHelper;
|
||||
|
||||
this.ApplicationDeploymentTypes = KubernetesApplicationDeploymentTypes;
|
||||
this.ApplicationDataAccessPolicies = KubernetesApplicationDataAccessPolicies;
|
||||
|
@ -592,7 +594,8 @@ class KubernetesCreateApplicationController {
|
|||
|
||||
const [resourcePools, nodes] = await Promise.all([this.KubernetesResourcePoolService.get(), this.KubernetesNodeService.get()]);
|
||||
|
||||
this.resourcePools = resourcePools;
|
||||
this.resourcePools = _.filter(resourcePools, (resourcePool) => !this.KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name));
|
||||
|
||||
this.formValues.ResourcePool = this.resourcePools[0];
|
||||
|
||||
_.forEach(nodes, (item) => {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { KubernetesConfigurationTypes } from 'Kubernetes/models/configuration/mo
|
|||
|
||||
class KubernetesCreateConfigurationController {
|
||||
/* @ngInject */
|
||||
constructor($async, $state, Notifications, Authentication, KubernetesConfigurationService, KubernetesResourcePoolService) {
|
||||
constructor($async, $state, Notifications, Authentication, KubernetesConfigurationService, KubernetesResourcePoolService, KubernetesNamespaceHelper) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.Notifications = Notifications;
|
||||
|
@ -13,6 +13,7 @@ class KubernetesCreateConfigurationController {
|
|||
this.KubernetesConfigurationService = KubernetesConfigurationService;
|
||||
this.KubernetesResourcePoolService = KubernetesResourcePoolService;
|
||||
this.KubernetesConfigurationTypes = KubernetesConfigurationTypes;
|
||||
this.KubernetesNamespaceHelper = KubernetesNamespaceHelper;
|
||||
|
||||
this.onInit = this.onInit.bind(this);
|
||||
this.createConfigurationAsync = this.createConfigurationAsync.bind(this);
|
||||
|
@ -74,7 +75,9 @@ class KubernetesCreateConfigurationController {
|
|||
this.formValues.Data.push(new KubernetesConfigurationFormValuesDataEntry());
|
||||
|
||||
try {
|
||||
this.resourcePools = await this.KubernetesResourcePoolService.get();
|
||||
const resourcePools = await this.KubernetesResourcePoolService.get();
|
||||
this.resourcePools = _.filter(resourcePools, (resourcePool) => !this.KubernetesNamespaceHelper.isSystemNamespace(resourcePool.Namespace.Name));
|
||||
|
||||
this.formValues.ResourcePool = this.resourcePools[0];
|
||||
await this.getConfigurations();
|
||||
} catch (err) {
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<form class="form-horizontal" name="kubernetesConfigurationCreationForm" autocomplete="off">
|
||||
<form ng-if="!ctrl.isSystemNamespace()" class="form-horizontal" name="kubernetesConfigurationCreationForm" autocomplete="off">
|
||||
<kubernetes-configuration-data ng-if="ctrl.formValues" form-values="ctrl.formValues" is-valid="ctrl.state.isDataValid"></kubernetes-configuration-data>
|
||||
|
||||
<!-- actions -->
|
||||
|
@ -99,6 +99,32 @@
|
|||
</div>
|
||||
<!-- !actions -->
|
||||
</form>
|
||||
<div ng-if="ctrl.isSystemNamespace()">
|
||||
<div class="col-sm-12 form-section-title" style="margin-top: 10px;">
|
||||
Data
|
||||
</div>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr class="text-muted">
|
||||
<td style="width: 10%; border-top: none;">Key</td>
|
||||
<td style="width: 90%; border-top: none;">Value</td>
|
||||
</tr>
|
||||
|
||||
<tr ng-repeat="item in ctrl.formValues.Data track by $index">
|
||||
<td>{{ item.Key }}</td>
|
||||
<td>
|
||||
<div style="white-space: pre-wrap;">{{ item.Value }}</div>
|
||||
<div style="margin-top: 2px;">
|
||||
<span class="btn btn-primary btn-xs" ng-click="ctrl.copyConfigurationValue($index)"> <i class="fa fa-copy space-right" aria-hidden="true"></i>Copy </span>
|
||||
<span id="copyValueNotification_{{ $index }}" style="display: none; color: #23ae89; margin-left: 5px;" class="small">
|
||||
<i class="fa fa-check" aria-hidden="true"></i> copied
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,7 @@ class KubernetesConfigurationController {
|
|||
constructor(
|
||||
$async,
|
||||
$state,
|
||||
clipboard,
|
||||
Notifications,
|
||||
LocalStorage,
|
||||
KubernetesConfigurationService,
|
||||
|
@ -21,6 +22,7 @@ class KubernetesConfigurationController {
|
|||
) {
|
||||
this.$async = $async;
|
||||
this.$state = $state;
|
||||
this.clipboard = clipboard;
|
||||
this.Notifications = Notifications;
|
||||
this.LocalStorage = LocalStorage;
|
||||
this.ModalService = ModalService;
|
||||
|
@ -55,6 +57,13 @@ class KubernetesConfigurationController {
|
|||
this.selectTab(2);
|
||||
}
|
||||
|
||||
copyConfigurationValue(idx) {
|
||||
this.clipboard.copyText(this.formValues.Data[idx].Value);
|
||||
$('#copyValueNotification_' + idx)
|
||||
.show()
|
||||
.fadeOut(2500);
|
||||
}
|
||||
|
||||
isFormValid() {
|
||||
if (this.formValues.IsSimple) {
|
||||
return this.formValues.Data.length > 0 && this.state.isDataValid;
|
||||
|
|
Loading…
Reference in New Issue