1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

fix(podman-play): fix regex for pod kube recreate (#582)

Signed-off-by: Simon Kuhball <simon@kuhball.de>
Co-authored-by: rwxd <rwxd@pm.me>
This commit is contained in:
Simon 2023-05-31 09:27:49 +02:00 committed by GitHub
parent 296faf6154
commit 52911bfc22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,9 +132,6 @@ except ImportError:
from ansible.module_utils.basic import AnsibleModule # noqa: F402
NAME = re.compile('name "([^"]+)" is in use')
class PodmanKubeManagement:
def __init__(self, module, executable):
@ -194,7 +191,12 @@ class PodmanKubeManagement:
"No metadata in Kube file!\n%s" % pod)
else:
with open(self.module.params['kube_file']) as text:
re_pod = NAME.search(text.read())
# the following formats are matched for a kube name:
# should match name field within metadata (2 or 4 spaces in front of name)
# the name can be written without quotes, in single or double quotes
# the name can contain -_
re_pod_name = re.compile(r'^\s{2,4}name: ["|\']?(?P<pod_name>[\w|\-|\_]+)["|\']?', re.MULTILINE)
re_pod = re_pod_name.search(text.read())
if re_pod:
pod_name = re_pod.group(1)
if not pod_name: