fix(kube): updated kube terminology for configmaps/secrets [EE-4816] (#8770)

pull/8872/head
Matt Hook 2023-05-16 09:21:50 +12:00 committed by GitHub
parent 8fa49d47f4
commit 0743f26ab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 25 deletions

View File

@ -172,7 +172,7 @@
<td colspan="4" class="text-muted text-center">Loading...</td> <td colspan="4" class="text-muted text-center">Loading...</td>
</tr> </tr>
<tr ng-if="$ctrl.state.filteredDataSet.length === 0"> <tr ng-if="$ctrl.state.filteredDataSet.length === 0">
<td colspan="4" class="text-muted text-center">No configuration available.</td> <td colspan="4" class="text-muted text-center">No ConfigMaps or Secrets available.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -414,7 +414,8 @@
<div class="row clearfix" ng-if="config.SelectedConfiguration && !config.Overriden"> <div class="row clearfix" ng-if="config.SelectedConfiguration && !config.Overriden">
<div class="col-sm-9 small text-muted !mt-2 !p-0"> <div class="col-sm-9 small text-muted !mt-2 !p-0">
The following keys will be loaded from the <code>{{ config.SelectedConfiguration.Name }}</code> The following keys will be loaded from the <code>{{ config.SelectedConfiguration.Name }}</code>
configuration as environment variables: <span ng-if="config.SelectedConfiguration.Kind === 1">ConfigMap</span><span ng-if="config.SelectedConfiguration.Kind === 2">Secret</span> as environment
variables:
<span ng-repeat="(key, _) in config.SelectedConfiguration.Data"> <span ng-repeat="(key, _) in config.SelectedConfiguration.Data">
<code>{{ key }}</code <code>{{ key }}</code
>{{ $last ? '' : ', ' }} >{{ $last ? '' : ', ' }}

View File

@ -209,12 +209,12 @@
<!-- CONFIGURATIONS --> <!-- CONFIGURATIONS -->
<div class="text-muted" style="margin-bottom: 15px; margin-top: 25px"> <div class="text-muted" style="margin-bottom: 15px; margin-top: 25px">
<pr-icon icon="'file'" class="mr-1"></pr-icon> <pr-icon icon="'file'" class="mr-1"></pr-icon>
Configuration ConfigMap or Secret
</div> </div>
<div class="small text-muted" ng-if="!ctrl.application.Env.length > 0 && !ctrl.hasVolumeConfiguration()" style="margin-bottom: 15px"> <div class="small text-muted" ng-if="!ctrl.application.Env.length > 0 && !ctrl.hasVolumeConfiguration()" style="margin-bottom: 15px">
<pr-icon icon="'info'" mode="'primary'" class="mr-1"></pr-icon> <pr-icon icon="'info'" mode="'primary'" class="mr-1"></pr-icon>
This application is not using any environment variable or configuration. This application is not using any environment variable, ConfigMap or Secret.
</div> </div>
<table class="table" ng-if="ctrl.application.Env.length > 0"> <table class="table" ng-if="ctrl.application.Env.length > 0">
@ -222,7 +222,7 @@
<td style="width: 25%">Container</td> <td style="width: 25%">Container</td>
<td style="width: 25%">Environment variable</td> <td style="width: 25%">Environment variable</td>
<td style="width: 25%">Value</td> <td style="width: 25%">Value</td>
<td style="width: 25%">Configuration</td> <td style="width: 25%">ConfigMap or Secret</td>
</tr> </tr>
<tbody ng-repeat="container in ctrl.application.Containers" style="border-top: 0"> <tbody ng-repeat="container in ctrl.application.Containers" style="border-top: 0">
<tr ng-repeat="envvar in container.Env | orderBy: 'name'"> <tr ng-repeat="envvar in container.Env | orderBy: 'name'">

View File

@ -28,7 +28,7 @@ class KubernetesConfigurationsController {
this.configurations = await this.KubernetesConfigurationService.get(); this.configurations = await this.KubernetesConfigurationService.get();
KubernetesConfigurationHelper.setConfigurationsUsed(this.configurations, this.applications); KubernetesConfigurationHelper.setConfigurationsUsed(this.configurations, this.applications);
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to retrieve configurations'); this.Notifications.error('Failure', err, 'Unable to retrieve ConfigMaps & Secrets');
} finally { } finally {
this.state.configurationsLoading = false; this.state.configurationsLoading = false;
} }
@ -43,11 +43,11 @@ class KubernetesConfigurationsController {
for (const configuration of selectedItems) { for (const configuration of selectedItems) {
try { try {
await this.KubernetesConfigurationService.delete(configuration); await this.KubernetesConfigurationService.delete(configuration);
this.Notifications.success('Configurations successfully removed', configuration.Name); this.Notifications.success('ConfigMaps/Secrets successfully removed', configuration.Name);
const index = this.configurations.indexOf(configuration); const index = this.configurations.indexOf(configuration);
this.configurations.splice(index, 1); this.configurations.splice(index, 1);
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to remove configuration'); this.Notifications.error('Failure', err, 'Unable to remove ConfigMaps/Secrets');
} finally { } finally {
--actionCount; --actionCount;
if (actionCount === 0) { if (actionCount === 0) {
@ -58,7 +58,7 @@ class KubernetesConfigurationsController {
} }
removeAction(selectedItems) { removeAction(selectedItems) {
confirmDelete('Do you want to remove the selected configuration(s)?').then((confirmed) => { confirmDelete('Do you want to remove the selected ConfigMap(s) & Secret(s)?').then((confirmed) => {
if (confirmed) { if (confirmed) {
return this.$async(this.removeActionAsync, selectedItems); return this.$async(this.removeActionAsync, selectedItems);
} }

View File

@ -1,7 +1,7 @@
<page-header <page-header
ng-if="ctrl.state.viewReady" ng-if="ctrl.state.viewReady"
title="'Create configuration'" title="'Create ConfigMap or Secret'"
breadcrumbs="[{ label:'ConfigMaps and Secrets', link:'kubernetes.configurations' }, 'Create a configuration']" breadcrumbs="[{ label:'ConfigMaps and Secrets', link:'kubernetes.configurations' }, 'Create a ConfigMap or Secret']"
reload="true" reload="true"
></page-header> ></page-header>
@ -53,7 +53,7 @@
ng-model="ctrl.formValues.Name" ng-model="ctrl.formValues.Name"
ng-pattern="/^[a-z0-9]([a-z0-9-.]{0,61}[a-z0-9])?$/" ng-pattern="/^[a-z0-9]([a-z0-9-.]{0,61}[a-z0-9])?$/"
ng-change="ctrl.onChangeName()" ng-change="ctrl.onChangeName()"
placeholder="my-configuration" placeholder="my-configmap-or-secret"
auto-focus auto-focus
required required
data-cy="k8sConfigCreate-nameInput" data-cy="k8sConfigCreate-nameInput"
@ -81,10 +81,10 @@
</div> </div>
<div ng-if="ctrl.formValues.ResourcePool"> <div ng-if="ctrl.formValues.ResourcePool">
<div class="col-sm-12 form-section-title"> Configuration kind </div> <div class="col-sm-12 form-section-title"> Kind </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 small text-muted"> Select the kind of data that you want to save in the configuration. </div> <div class="col-sm-12 small text-muted"> Select the kind of data that you want to save. </div>
</div> </div>
<box-selector options="ctrl.typeOptions" value="ctrl.formValues.Kind" on-change="(ctrl.onChangeKind)" radio-name="'Kind'" slim="true"> </box-selector> <box-selector options="ctrl.typeOptions" value="ctrl.formValues.Kind" on-change="(ctrl.onChangeKind)" radio-name="'Kind'" slim="true"> </box-selector>

View File

@ -140,6 +140,11 @@ class KubernetesCreateConfigurationController {
} }
async createConfigurationAsync() { async createConfigurationAsync() {
let kind = 'ConfigMap';
if (this.formValues.Kind === this.KubernetesConfigurationKinds.SECRET) {
kind = 'Secret';
}
try { try {
this.state.actionInProgress = true; this.state.actionInProgress = true;
this.formValues.ConfigurationOwner = this.Authentication.getUserDetails().username; this.formValues.ConfigurationOwner = this.Authentication.getUserDetails().username;
@ -148,11 +153,12 @@ class KubernetesCreateConfigurationController {
} }
await this.KubernetesConfigurationService.create(this.formValues); await this.KubernetesConfigurationService.create(this.formValues);
this.Notifications.success('Success', 'Configuration succesfully created');
this.Notifications.success('Success', `${kind} successfully created`);
this.state.isEditorDirty = false; this.state.isEditorDirty = false;
this.$state.go('kubernetes.configurations'); this.$state.go('kubernetes.configurations');
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to create configuration'); this.Notifications.error('Failure', err, `Unable to create ${kind}`);
} finally { } finally {
this.state.actionInProgress = false; this.state.actionInProgress = false;
} }
@ -166,7 +172,7 @@ class KubernetesCreateConfigurationController {
try { try {
this.configurations = await this.KubernetesConfigurationService.get(); this.configurations = await this.KubernetesConfigurationService.get();
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to retrieve configurations'); this.Notifications.error('Failure', err, 'Unable to retrieve ConfigMaps and Secrets');
} }
} }

View File

@ -1,6 +1,6 @@
<page-header <page-header
ng-if="ctrl.state.viewReady" ng-if="ctrl.state.viewReady"
title="'Configuration details'" title="'ConfigMap or Secret details'"
breadcrumbs="[ breadcrumbs="[
{ label:'Namespaces', link:'kubernetes.resourcePools' }, { label:'Namespaces', link:'kubernetes.resourcePools' },
{ {
@ -46,7 +46,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="!pl-0">Configuration kind</td> <td class="!pl-0">Kind</td>
<td> <td>
{{ ctrl.configuration.Kind | kubernetesConfigurationKindText }} {{ ctrl.configuration.Kind | kubernetesConfigurationKindText }}
</td> </td>

View File

@ -87,6 +87,11 @@ class KubernetesConfigurationController {
// It looks like we're still doing a create/delete process but we've decided to get rid of this // It looks like we're still doing a create/delete process but we've decided to get rid of this
// approach. // approach.
async updateConfigurationAsync() { async updateConfigurationAsync() {
let kind = 'ConfigMap';
if (this.formValues.Kind === KubernetesConfigurationKinds.SECRET) {
kind = 'Secret';
}
try { try {
this.state.actionInProgress = true; this.state.actionInProgress = true;
if ( if (
@ -96,7 +101,7 @@ class KubernetesConfigurationController {
) { ) {
await this.KubernetesConfigurationService.create(this.formValues); await this.KubernetesConfigurationService.create(this.formValues);
await this.KubernetesConfigurationService.delete(this.configuration); await this.KubernetesConfigurationService.delete(this.configuration);
this.Notifications.success('Success', 'Configuration succesfully updated'); this.Notifications.success('Success', `${kind} successfully updated`);
this.$state.go( this.$state.go(
'kubernetes.configurations.configuration', 'kubernetes.configurations.configuration',
{ {
@ -107,11 +112,11 @@ class KubernetesConfigurationController {
); );
} else { } else {
await this.KubernetesConfigurationService.update(this.formValues, this.configuration); await this.KubernetesConfigurationService.update(this.formValues, this.configuration);
this.Notifications.success('Success', 'Configuration succesfully updated'); this.Notifications.success('Success', `${kind} successfully updated`);
this.$state.reload(this.$state.current); this.$state.reload(this.$state.current);
} }
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to update configuration'); this.Notifications.error('Failure', err, `Unable to update ${kind}`);
} finally { } finally {
this.state.actionInProgress = false; this.state.actionInProgress = false;
} }
@ -120,8 +125,9 @@ class KubernetesConfigurationController {
updateConfiguration() { updateConfiguration() {
if (this.configuration.Used) { if (this.configuration.Used) {
const plural = this.configuration.Applications.length > 1 ? 's' : ''; const plural = this.configuration.Applications.length > 1 ? 's' : '';
const thisorthese = this.configuration.Applications.length > 1 ? 'these' : 'this';
confirmUpdate( confirmUpdate(
`The changes will be propagated to ${this.configuration.Applications.length} running application${plural}. Are you sure you want to update this configuration?`, `The changes will be propagated to ${this.configuration.Applications.length} running application${plural}. Are you sure you want to update ${thisorthese} ConfigMap${plural} or Secret${plural}?`,
(confirmed) => { (confirmed) => {
if (confirmed) { if (confirmed) {
return this.$async(this.updateConfigurationAsync); return this.$async(this.updateConfigurationAsync);

View File

@ -10,7 +10,7 @@ export const typeOptions: ReadonlyArray<BoxSelectorOption<number>> = [
icon: FileCode, icon: FileCode,
iconType: 'badge', iconType: 'badge',
label: 'ConfigMap', label: 'ConfigMap',
description: 'This configuration holds non-sensitive information', description: 'This kind holds non-sensitive information',
}, },
{ {
id: 'type_secret', id: 'type_secret',
@ -18,6 +18,6 @@ export const typeOptions: ReadonlyArray<BoxSelectorOption<number>> = [
icon: Lock, icon: Lock,
iconType: 'badge', iconType: 'badge',
label: 'Secret', label: 'Secret',
description: 'This configuration holds sensitive information', description: 'This kind holds sensitive information',
}, },
] as const; ] as const;