From 372ce44f89672ed0f38618e171a8b673090100e2 Mon Sep 17 00:00:00 2001 From: Edyta Krukowska Date: Fri, 5 Feb 2021 09:01:44 +0100 Subject: Fix conditions for volumes Issue-ID: DCAEGEN2-2546 Signed-off-by: Edyta Krukowska Change-Id: I62bb6a9bc6ed2efefafa491331ad1c5c477a924b --- k8s/k8sclient/k8sclient.py | 4 ++-- k8s/tests/test_k8sclient_deploy.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s/k8sclient/k8sclient.py b/k8s/k8sclient/k8sclient.py index 3122e63..c1f378f 100644 --- a/k8s/k8sclient/k8sclient.py +++ b/k8s/k8sclient/k8sclient.py @@ -298,10 +298,10 @@ def _parse_volumes(volume_list): vname = str(uuid.uuid4()) vcontainer = v['container']['bind'] vro = (v['container'].get('mode') == 'ro') - if 'host' in v: + if ('host' in v) and ('path' in v['host']): vhost = v['host']['path'] volumes.append(client.V1Volume(name=vname, host_path=client.V1HostPathVolumeSource(path=vhost))) - if 'config_volume' in v: + if ('config_volume' in v) and ('name' in v['config_volume']): vconfig_volume = v['config_volume']['name'] volumes.append(client.V1Volume(name=vname, config_map=client.V1ConfigMapVolumeSource(default_mode="0644", name=vconfig_volume, diff --git a/k8s/tests/test_k8sclient_deploy.py b/k8s/tests/test_k8sclient_deploy.py index 486029e..55daf3b 100644 --- a/k8s/tests/test_k8sclient_deploy.py +++ b/k8s/tests/test_k8sclient_deploy.py @@ -2,7 +2,7 @@ # org.onap.dcae # ================================================================================ # Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved. -# Copyright (c) 2020 Nokia. All rights reserved. +# Copyright (c) 2020-2021 Nokia. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -- cgit 1.2.3-korg