mirror of https://github.com/portainer/portainer
fix(app): handle no options and volume mounts [EE-5078] (#9075)
* fix(app): handle no options and vol mounts EE-5078 * rm comment --------- Co-authored-by: testa113 <testa113>pull/9077/head
parent
90759182db
commit
a4dfeda4ae
|
@ -30,6 +30,7 @@ import KubernetesPersistentVolumeClaimConverter from 'Kubernetes/converters/pers
|
||||||
import PortainerError from 'Portainer/error';
|
import PortainerError from 'Portainer/error';
|
||||||
import { KubernetesIngressHelper } from 'Kubernetes/ingress/helper';
|
import { KubernetesIngressHelper } from 'Kubernetes/ingress/helper';
|
||||||
import KubernetesCommonHelper from 'Kubernetes/helpers/commonHelper';
|
import KubernetesCommonHelper from 'Kubernetes/helpers/commonHelper';
|
||||||
|
import { KubernetesConfigurationKinds } from 'Kubernetes/models/configuration/models';
|
||||||
|
|
||||||
function _apiPortsToPublishedPorts(pList, pRefs) {
|
function _apiPortsToPublishedPorts(pList, pRefs) {
|
||||||
const ports = _.map(pList, (item) => {
|
const ports = _.map(pList, (item) => {
|
||||||
|
@ -213,6 +214,7 @@ class KubernetesApplicationConverter {
|
||||||
configurationVolume.fileMountPath = matchingVolumeMount.mountPath;
|
configurationVolume.fileMountPath = matchingVolumeMount.mountPath;
|
||||||
configurationVolume.rootMountPath = matchingVolumeMount.mountPath;
|
configurationVolume.rootMountPath = matchingVolumeMount.mountPath;
|
||||||
configurationVolume.configurationName = configurationName;
|
configurationVolume.configurationName = configurationName;
|
||||||
|
configurationVolume.configurationType = volume.configMap ? KubernetesConfigurationKinds.CONFIGMAP : KubernetesConfigurationKinds.SECRET;
|
||||||
|
|
||||||
acc.push(configurationVolume);
|
acc.push(configurationVolume);
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,6 +224,7 @@ class KubernetesApplicationConverter {
|
||||||
configurationVolume.rootMountPath = matchingVolumeMount.mountPath;
|
configurationVolume.rootMountPath = matchingVolumeMount.mountPath;
|
||||||
configurationVolume.configurationKey = item.key;
|
configurationVolume.configurationKey = item.key;
|
||||||
configurationVolume.configurationName = configurationName;
|
configurationVolume.configurationName = configurationName;
|
||||||
|
configurationVolume.configurationType = volume.configMap ? KubernetesConfigurationKinds.CONFIGMAP : KubernetesConfigurationKinds.SECRET;
|
||||||
|
|
||||||
acc.push(configurationVolume);
|
acc.push(configurationVolume);
|
||||||
});
|
});
|
||||||
|
@ -294,12 +297,17 @@ class KubernetesApplicationConverter {
|
||||||
res.DataAccessPolicy = app.DataAccessPolicy;
|
res.DataAccessPolicy = app.DataAccessPolicy;
|
||||||
res.EnvironmentVariables = KubernetesApplicationHelper.generateEnvVariablesFromEnv(app.Env);
|
res.EnvironmentVariables = KubernetesApplicationHelper.generateEnvVariablesFromEnv(app.Env);
|
||||||
res.PersistedFolders = KubernetesApplicationHelper.generatePersistedFoldersFormValuesFromPersistedFolders(app.PersistedFolders, persistentVolumeClaims); // generate from PVC and app.PersistedFolders
|
res.PersistedFolders = KubernetesApplicationHelper.generatePersistedFoldersFormValuesFromPersistedFolders(app.PersistedFolders, persistentVolumeClaims); // generate from PVC and app.PersistedFolders
|
||||||
res.Secrets = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(app.Env, app.ConfigurationVolumes, configurations, 'valueFrom.secretKeyRef.name');
|
res.Secrets = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(
|
||||||
|
app.Env,
|
||||||
|
app.ConfigurationVolumes,
|
||||||
|
configurations,
|
||||||
|
KubernetesConfigurationKinds.SECRET
|
||||||
|
);
|
||||||
res.ConfigMaps = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(
|
res.ConfigMaps = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(
|
||||||
app.Env,
|
app.Env,
|
||||||
app.ConfigurationVolumes,
|
app.ConfigurationVolumes,
|
||||||
configurations,
|
configurations,
|
||||||
'valueFrom.configMapKeyRef.name'
|
KubernetesConfigurationKinds.CONFIGMAP
|
||||||
);
|
);
|
||||||
res.AutoScaler = KubernetesApplicationHelper.generateAutoScalerFormValueFromHorizontalPodAutoScaler(app.AutoScaler, res.ReplicaCount);
|
res.AutoScaler = KubernetesApplicationHelper.generateAutoScalerFormValueFromHorizontalPodAutoScaler(app.AutoScaler, res.ReplicaCount);
|
||||||
res.PublishedPorts = KubernetesApplicationHelper.generatePublishedPortsFormValuesFromPublishedPorts(app.ServiceType, app.PublishedPorts, ingresses);
|
res.PublishedPorts = KubernetesApplicationHelper.generatePublishedPortsFormValuesFromPublishedPorts(app.ServiceType, app.PublishedPorts, ingresses);
|
||||||
|
|
|
@ -145,10 +145,11 @@ class KubernetesApplicationHelper {
|
||||||
/* #endregion */
|
/* #endregion */
|
||||||
|
|
||||||
/* #region CONFIGURATIONS FV <> ENV & VOLUMES */
|
/* #region CONFIGURATIONS FV <> ENV & VOLUMES */
|
||||||
static generateConfigurationFormValuesFromEnvAndVolumes(env, volumes, configurations, filterCondition) {
|
static generateConfigurationFormValuesFromEnvAndVolumes(env, volumes, configurations, configurationKind) {
|
||||||
|
const filterCondition = configurationKind === KubernetesConfigurationKinds.CONFIGMAP ? 'valueFrom.configMapKeyRef.name' : 'valueFrom.secretKeyRef.name';
|
||||||
const finalRes = _.flatMap(configurations, (cfg) => {
|
const finalRes = _.flatMap(configurations, (cfg) => {
|
||||||
const cfgEnv = _.filter(env, [filterCondition, cfg.Name]);
|
const cfgEnv = _.filter(env, [filterCondition, cfg.Name]);
|
||||||
const cfgVol = _.filter(volumes, { configurationName: cfg.Name });
|
const cfgVol = volumes.filter((volume) => volume.configurationName === cfg.Name && volume.configurationType === configurationKind);
|
||||||
if (!cfgEnv.length && !cfgVol.length) {
|
if (!cfgEnv.length && !cfgVol.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,14 +483,21 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- !config-element -->
|
<!-- !config-element -->
|
||||||
<div class="col-sm-12 !p-0">
|
<div class="col-sm-12 !p-0">
|
||||||
<span
|
<button
|
||||||
|
type="button"
|
||||||
class="btn btn-primary btn-sm btn btn-sm btn-light mb-2 !ml-0"
|
class="btn btn-primary btn-sm btn btn-sm btn-light mb-2 !ml-0"
|
||||||
|
ng-disabled="ctrl.configMaps.length === 0"
|
||||||
ng-click="ctrl.addConfigMap()"
|
ng-click="ctrl.addConfigMap()"
|
||||||
ng-if="ctrl.formValues.Containers.length <= 1"
|
ng-if="ctrl.formValues.Containers.length <= 1"
|
||||||
data-cy="k8sAppCreate-addConfigButton"
|
data-cy="k8sAppCreate-addConfigButton"
|
||||||
>
|
>
|
||||||
<pr-icon icon="'plus'" size="'sm'"></pr-icon> Add ConfigMap
|
<pr-icon icon="'plus'" size="'sm'"></pr-icon> Add ConfigMap
|
||||||
</span>
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="my-2 w-full">
|
||||||
|
<p class="vertical-center text-warning text-xs" ng-if="ctrl.configMaps.length === 0"
|
||||||
|
><pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon> There are no ConfigMaps available in this namespace.</p
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- #region SECRETS -->
|
<!-- #region SECRETS -->
|
||||||
|
@ -626,14 +633,21 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- !config-element -->
|
<!-- !config-element -->
|
||||||
<div class="col-sm-12 !p-0">
|
<div class="col-sm-12 !p-0">
|
||||||
<span
|
<button
|
||||||
|
type="button"
|
||||||
|
ng-disabled="ctrl.secrets.length === 0"
|
||||||
class="btn btn-primary btn-sm btn btn-sm btn-light mb-2 !ml-0"
|
class="btn btn-primary btn-sm btn btn-sm btn-light mb-2 !ml-0"
|
||||||
ng-click="ctrl.addSecret()"
|
ng-click="ctrl.addSecret()"
|
||||||
ng-if="ctrl.formValues.Containers.length <= 1"
|
ng-if="ctrl.formValues.Containers.length <= 1"
|
||||||
data-cy="k8sAppCreate-addSecretButton"
|
data-cy="k8sAppCreate-addSecretButton"
|
||||||
>
|
>
|
||||||
<pr-icon icon="'plus'" size="'sm'"></pr-icon> Add Secret
|
<pr-icon icon="'plus'" size="'sm'"></pr-icon> Add Secret
|
||||||
</span>
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="my-2 w-full">
|
||||||
|
<p class="vertical-center text-warning text-xs" ng-if="ctrl.secrets.length === 0"
|
||||||
|
><pr-icon icon="'alert-triangle'" mode="'warning'"></pr-icon> There are no secrets available in this namespace.</p
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<!-- #endregion -->
|
<!-- #endregion -->
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue