From 8b79f2524d1f74c88ec1f9512a9cb1332637e284 Mon Sep 17 00:00:00 2001 From: Maxime Bajeux Date: Tue, 14 Jul 2020 07:39:13 +0200 Subject: [PATCH] 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 --- .../create/createApplicationController.js | 7 +++-- .../create/createConfigurationController.js | 7 +++-- .../configurations/edit/configuration.html | 28 ++++++++++++++++++- .../edit/configurationController.js | 9 ++++++ 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 15ad90b2b..86679639f 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -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) => { diff --git a/app/kubernetes/views/configurations/create/createConfigurationController.js b/app/kubernetes/views/configurations/create/createConfigurationController.js index 696a2efc7..7182c267d 100644 --- a/app/kubernetes/views/configurations/create/createConfigurationController.js +++ b/app/kubernetes/views/configurations/create/createConfigurationController.js @@ -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) { diff --git a/app/kubernetes/views/configurations/edit/configuration.html b/app/kubernetes/views/configurations/edit/configuration.html index 3d97546ea..6b5a0ae8f 100644 --- a/app/kubernetes/views/configurations/edit/configuration.html +++ b/app/kubernetes/views/configurations/edit/configuration.html @@ -76,7 +76,7 @@
-
+ @@ -99,6 +99,32 @@
+
+
+ Data +
+ + + + + + + + + + + + +
KeyValue
{{ item.Key }} +
{{ item.Value }}
+
+ Copy + +
+
+
diff --git a/app/kubernetes/views/configurations/edit/configurationController.js b/app/kubernetes/views/configurations/edit/configurationController.js index 3906d9f59..59427d11d 100644 --- a/app/kubernetes/views/configurations/edit/configurationController.js +++ b/app/kubernetes/views/configurations/edit/configurationController.js @@ -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;