Skip to content

Commit

Permalink
rename getParameter getParamterValue
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov committed Aug 26, 2020
1 parent adb17c3 commit a5f557c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions frontend/packages/kubevirt-plugin/src/selectors/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as _ from 'lodash';
import { K8sResourceKind, TemplateParameter } from '@console/internal/module/k8s';
import { K8sResourceKind } from '@console/internal/module/k8s';
import { VMGenericLikeEntityKind } from '../types/vmLike';

export const getKind = (value) => _.get(value, 'kind') as K8sResourceKind['kind'];
Expand Down Expand Up @@ -36,8 +36,9 @@ export const getAnnotation = (
defaultValue?: string,
): string => _.get(entity, ['metadata', 'annotations', annotationName], defaultValue);

export const getParameter = (obj, name: string, defaultValue = {}): TemplateParameter =>
_.get(obj, ['parameters'], []).find((parameter) => parameter.name === name) || defaultValue;
export const getParameterValue = (obj, name: string, defaultValue = null): string =>
_.get(obj, ['parameters'], []).find((parameter) => parameter.name === name)?.value ||
defaultValue;

export const getAnnotationKeySuffix = (
entity: K8sResourceKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
CloudInitDataHelper,
CloudInitDataFormKeys,
} from '../../k8s/wrapper/vm/cloud-init-data-helper';
import { getAnnotation, getAnnotations, getLabels, getParameter } from '../selectors';
import { getAnnotation, getAnnotations, getLabels, getParameterValue } from '../selectors';
import {
TEMPLATE_FLAVOR_LABEL,
TEMPLATE_OS_LABEL,
Expand Down Expand Up @@ -85,8 +85,8 @@ export const getTemplateOperatingSystems = (templates: TemplateKind[]) => {
return {
id: osId,
name: getAnnotation(template, nameAnnotation),
dataVolumeName: getParameter(template, TEMPLATE_DATAVOLUME_NAME_PARAMETER)?.value,
dataVolumeNamespace: getParameter(template, TEMPLATE_DATAVOLUME_NAMESPACE_PARAMETER)?.value,
dataVolumeName: getParameterValue(template, TEMPLATE_DATAVOLUME_NAME_PARAMETER),
dataVolumeNamespace: getParameterValue(template, TEMPLATE_DATAVOLUME_NAMESPACE_PARAMETER),
};
}),
);
Expand Down

0 comments on commit a5f557c

Please sign in to comment.