1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-04 21:35:23 +02:00

feat(application): Add the ability to use existing volumes when creating an application (#4044)

* feat(applications): update UI to use existing volumes

* feat(application): Add the ability to use existing volumes when creating an application

* feat(application): Existing persisted folders should default to associated volumes

* feat(application): add form validation to existing volume

* feat(application): remove the ability to use an existing volume with statefulset application

* feat(k8s/applications): minor UI update

* feat(k8s/application): minor UI update

* feat(volume): allow to increase volume size and few other things

* feat(volumes): add the ability to allow volume expansion

* fix(storage): fix the storage patch request

* fix(k8s/applications): remove conflict leftover

* feat(k8s/configure): minor UI update

* feat(k8s/volume): minor UI update

* fix(storage): change few things

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
Maxime Bajeux 2020-08-07 06:40:24 +02:00 committed by GitHub
parent b9c2bf487b
commit 61f97469ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 436 additions and 40 deletions

View file

@ -209,7 +209,7 @@ class KubernetesApplicationService {
app.ServiceName = headlessService.metadata.name;
} else {
const claimPromises = _.map(claims, (item) => {
if (!item.PreviousName) {
if (!item.PreviousName && !item.Id) {
return this.KubernetesPersistentVolumeClaimService.create(item);
}
});
@ -255,11 +255,12 @@ class KubernetesApplicationService {
await this.KubernetesServiceService.patch(oldHeadlessService, newHeadlessService);
} else {
const claimPromises = _.map(newClaims, (newClaim) => {
if (!newClaim.PreviousName) {
if (!newClaim.PreviousName && !newClaim.Id) {
return this.KubernetesPersistentVolumeClaimService.create(newClaim);
} else if (!newClaim.Id) {
const oldClaim = _.find(oldClaims, { Name: newClaim.PreviousName });
return this.KubernetesPersistentVolumeClaimService.patch(oldClaim, newClaim);
}
const oldClaim = _.find(oldClaims, { Name: newClaim.PreviousName });
return this.KubernetesPersistentVolumeClaimService.patch(oldClaim, newClaim);
});
await Promise.all(claimPromises);
}

View file

@ -2,6 +2,7 @@ import angular from 'angular';
import _ from 'lodash-es';
import PortainerError from 'Portainer/error';
import KubernetesStorageClassConverter from 'Kubernetes/converters/storageClass';
import { KubernetesCommonParams } from 'Kubernetes/models/common/params';
class KubernetesStorageService {
/* @ngInject */
@ -10,6 +11,7 @@ class KubernetesStorageService {
this.KubernetesStorage = KubernetesStorage;
this.getAsync = this.getAsync.bind(this);
this.patchAsync = this.patchAsync.bind(this);
}
/**
@ -31,6 +33,24 @@ class KubernetesStorageService {
get(endpointId) {
return this.$async(this.getAsync, endpointId);
}
/**
* PATCH
*/
async patchAsync(oldStorageClass, newStorageClass) {
try {
const params = new KubernetesCommonParams();
params.id = newStorageClass.Name;
const payload = KubernetesStorageClassConverter.patchPayload(oldStorageClass, newStorageClass);
await this.KubernetesStorage().patch(params, payload).$promise;
} catch (err) {
throw new PortainerError('Unable to patch storage class', err);
}
}
patch(oldStorageClass, newStorageClass) {
return this.$async(this.patchAsync, oldStorageClass, newStorageClass);
}
}
export default KubernetesStorageService;