fix(pvc): show access modes [EE-5581] (#10554)

Co-authored-by: testa113 <testa113>
pull/10708/head
Ali 2023-11-30 09:48:55 +13:00 committed by GitHub
parent 87b486b798
commit e3a995d515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 20 deletions

View File

@ -18,6 +18,7 @@ class KubernetesPersistentVolumeClaimConverter {
res.Namespace = data.metadata.namespace; res.Namespace = data.metadata.namespace;
res.CreationDate = data.metadata.creationTimestamp; res.CreationDate = data.metadata.creationTimestamp;
res.Storage = `${data.spec.resources.requests.storage}B`; res.Storage = `${data.spec.resources.requests.storage}B`;
res.AccessModes = data.spec.accessModes || [];
res.StorageClass = _.find(storageClasses, { Name: data.spec.storageClassName }); res.StorageClass = _.find(storageClasses, { Name: data.spec.storageClassName });
res.Yaml = yaml ? yaml.data : ''; res.Yaml = yaml ? yaml.data : '';
res.ApplicationOwner = data.metadata.labels ? data.metadata.labels[KubernetesPortainerApplicationOwnerLabel] : ''; res.ApplicationOwner = data.metadata.labels ? data.metadata.labels[KubernetesPortainerApplicationOwnerLabel] : '';

View File

@ -3,12 +3,12 @@
*/ */
const _KubernetesStorageClassAccessPolicies = Object.freeze([ const _KubernetesStorageClassAccessPolicies = Object.freeze([
{ {
Name: 'RWO', Name: 'ReadWriteOnce',
Description: 'Allow read-write from a single pod only (RWO)', Description: 'Allow read-write from a single pod only (RWO)',
selected: true, selected: true,
}, },
{ {
Name: 'RWX', Name: 'ReadWriteMany',
Description: 'Allow read-write access from one or more pods concurrently (RWX)', Description: 'Allow read-write access from one or more pods concurrently (RWX)',
selected: false, selected: false,
}, },

View File

@ -11,6 +11,7 @@ const _KubernetesPersistentVolumeClaim = Object.freeze({
StorageClass: {}, // KubernetesStorageClass StorageClass: {}, // KubernetesStorageClass
CreationDate: '', CreationDate: '',
ApplicationOwner: '', ApplicationOwner: '',
AccessModes: [],
ApplicationName: '', ApplicationName: '',
MountPath: '', // used for Application creation from ApplicationFormValues | not used from API conversion MountPath: '', // used for Application creation from ApplicationFormValues | not used from API conversion
Yaml: '', Yaml: '',

View File

@ -49,15 +49,22 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Storage</td> <td>Storage Class</td>
<td data-cy="k8sVolDetail-volStorageClassname">{{ ctrl.volume.PersistentVolumeClaim.StorageClass.Name }}</td> <td data-cy="k8sVolDetail-volStorageClassname">{{ ctrl.volume.PersistentVolumeClaim.StorageClass.Name }}</td>
</tr> </tr>
<tr> <tr>
<td>Shared Access Policy</td> <td>Access Modes</td>
<td data-cy="k8sVolDetail-volAccessPolicy" <td data-cy="k8sVolDetail-volAccessPolicy">
>{{ ctrl.state.volumeSharedAccessPolicy }} <div ng-repeat="(index, accessPolicy) in ctrl.state.volumeSharedAccessPolicies" class="flex flex-col gap-y-1">
<portainer-tooltip ng-if="ctrl.state.volumeSharedAccessPolicyTooltip" message="ctrl.state.volumeSharedAccessPolicyTooltip"></portainer-tooltip <div class="items-center flex gap-x-1">
></td> {{ accessPolicy }}
<portainer-tooltip
ng-if="ctrl.state.volumeSharedAccessPolicyTooltips[index]"
message="ctrl.state.volumeSharedAccessPolicyTooltips[index]"
></portainer-tooltip>
</div>
</div>
</td>
</tr> </tr>
<tr> <tr>
<td>Provisioner</td> <td>Provisioner</td>

View File

@ -174,8 +174,8 @@ class KubernetesVolumeController {
increaseSize: false, increaseSize: false,
volumeSize: 0, volumeSize: 0,
volumeSizeUnit: 'GB', volumeSizeUnit: 'GB',
volumeSharedAccessPolicy: '', volumeSharedAccessPolicies: [],
volumeSharedAccessPolicyTooltip: '', volumeSharedAccessPolicyTooltips: '',
errors: { errors: {
volumeSize: false, volumeSize: false,
}, },
@ -186,16 +186,12 @@ class KubernetesVolumeController {
try { try {
await this.getVolume(); await this.getVolume();
await this.getEvents(); await this.getEvents();
if (this.volume.PersistentVolumeClaim.StorageClass !== undefined) { this.state.volumeSharedAccessPolicies = this.volume.PersistentVolumeClaim.AccessModes;
this.state.volumeSharedAccessPolicy = this.volume.PersistentVolumeClaim.StorageClass.AccessModes[this.volume.PersistentVolumeClaim.StorageClass.AccessModes.length - 1];
let policies = KubernetesStorageClassAccessPolicies(); let policies = KubernetesStorageClassAccessPolicies();
this.state.volumeSharedAccessPolicyTooltips = this.state.volumeSharedAccessPolicies.map((policy) => {
policies.forEach((policy) => { const matchingPolicy = policies.find((p) => p.Name === policy);
if (policy.Name == this.state.volumeSharedAccessPolicy) { return matchingPolicy ? matchingPolicy.Description : undefined;
this.state.volumeSharedAccessPolicyTooltip = policy.Description;
}
}); });
}
} catch (err) { } catch (err) {
this.Notifications.error('Failure', err, 'Unable to load view data'); this.Notifications.error('Failure', err, 'Unable to load view data');
} finally { } finally {