From 924edd2acb53e9973ad3fdbd74ab3a46ea8809b5 Mon Sep 17 00:00:00 2001 From: Marek Libra Date: Mon, 29 Apr 2019 13:13:56 +0200 Subject: [PATCH] v2v: Compose image name dynamically Allows downstream patches. --- src/config/index.js | 10 ++++++++-- src/k8s/objects/v2v/vmware/conversionPod.js | 4 ++-- src/k8s/objects/v2v/vmware/vmWareDeployment.js | 4 ++-- src/k8s/requests/v2v/startV2VvmwareController.js | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index c241a33d9..3ee5732af 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,4 +1,10 @@ +import { get } from 'lodash'; + +const getRegistryUrl = () => get(window.SERVER_FLAGS, 'Registry', 'quay.io/nyoxi'); // TODO: upstream should be moved under quay.io/kubevirt +const getV2vImageTag = () => get(window.SERVER_FLAGS, 'ImageTagV2V', 'latest'); + export const VMWARE_TO_KUBEVIRT_OS_CONFIG_MAP_NAMESPACE = 'kube-public'; // note: common-templates are in the "openshift" namespace export const VMWARE_TO_KUBEVIRT_OS_CONFIG_MAP_NAME = 'vmware-to-kubevirt-os'; // single configMap per cluster, contains mapping of vmware guestId to common-templates OS ID -export const KUBEVIRT_V2V_CONVERSION_CONTAINER_IMAGE = 'quay.io/nyoxi/kubevirt-v2v-conversion:1.12.1-1-gf665c0a'; -export const KUBEVIRT_V2V_VMWARE_CONTAINER_IMAGE = 'quay.io/nyoxi/kubevirt-vmware:1.12.1-1'; + +export const getKubevirtV2vConversionContainerImage = () => `${getRegistryUrl()}/kubevirt-v2v-conversion:${getV2vImageTag()}`; +export const getKubevirtV2vVmwareContainerImage = () => `${getRegistryUrl()}/kubevirt-vmware:${getV2vImageTag()}`; diff --git a/src/k8s/objects/v2v/vmware/conversionPod.js b/src/k8s/objects/v2v/vmware/conversionPod.js index 9148b6a78..b7064fe96 100644 --- a/src/k8s/objects/v2v/vmware/conversionPod.js +++ b/src/k8s/objects/v2v/vmware/conversionPod.js @@ -1,4 +1,4 @@ -import { KUBEVIRT_V2V_CONVERSION_CONTAINER_IMAGE } from '../../../../config'; +import { getKubevirtV2vConversionContainerImage } from '../../../../config'; import { PodModel } from '../../../../models'; import { CONVERSION_BASE_NAME, CONVERSION_GENERATE_NAME } from '../../../requests/v2v'; @@ -14,7 +14,7 @@ export const buildConversionPod = ({ volumes, volumeMounts, namespace, serviceAc containers: [ { name: CONVERSION_BASE_NAME, - image: KUBEVIRT_V2V_CONVERSION_CONTAINER_IMAGE, + image: getKubevirtV2vConversionContainerImage(), securityContext: { privileged: true, }, diff --git a/src/k8s/objects/v2v/vmware/vmWareDeployment.js b/src/k8s/objects/v2v/vmware/vmWareDeployment.js index 3acc1bdb2..0b072f38c 100644 --- a/src/k8s/objects/v2v/vmware/vmWareDeployment.js +++ b/src/k8s/objects/v2v/vmware/vmWareDeployment.js @@ -1,4 +1,4 @@ -import { KUBEVIRT_V2V_VMWARE_CONTAINER_IMAGE } from '../../../../config'; +import { getKubevirtV2vVmwareContainerImage } from '../../../../config'; import { DeploymentModel } from '../../../../models'; export const buildVmWareDeployment = ({ name, namespace }) => ({ @@ -26,7 +26,7 @@ export const buildVmWareDeployment = ({ name, namespace }) => ({ containers: [ { name, - image: KUBEVIRT_V2V_VMWARE_CONTAINER_IMAGE, + image: getKubevirtV2vVmwareContainerImage(), imagePullPolicy: 'Always', command: ['kubevirt-vmware'], env: [ diff --git a/src/k8s/requests/v2v/startV2VvmwareController.js b/src/k8s/requests/v2v/startV2VvmwareController.js index d79e75405..bee57c07e 100644 --- a/src/k8s/requests/v2v/startV2VvmwareController.js +++ b/src/k8s/requests/v2v/startV2VvmwareController.js @@ -6,7 +6,7 @@ import { getDeploymentContainer } from '../../../selectors/deployment'; import { getContainerImage } from '../../../selectors/pod'; import { buildAddOwnerReferencesPatch, buildOwnerReference } from '../../util'; import { getName } from '../../../selectors'; -import { KUBEVIRT_V2V_VMWARE_CONTAINER_IMAGE } from '../../../config'; +import { getKubevirtV2vVmwareContainerImage } from '../../../config'; const { info } = console; @@ -26,7 +26,7 @@ export const startV2VVMWareController = async ({ namespace }, { k8sGet, k8sCreat try { activeDeployment = await k8sGet(DeploymentModel, name, namespace); - if (getContainerImage(getDeploymentContainer(activeDeployment, name)) !== KUBEVIRT_V2V_VMWARE_CONTAINER_IMAGE) { + if (getContainerImage(getDeploymentContainer(activeDeployment, name)) !== getKubevirtV2vVmwareContainerImage()) { throw new Error(OLD_VERSION); } } catch (e) {