#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

from cmk.base.check_legacy_includes.k8s import *  # pylint: disable=wildcard-import,unused-wildcard-import


def inv_k8s_job_container(info, inventory_tree, status_data_tree):
    # Note: This is a stripped-down version of `k8s_pod_container`.
    parsed = parse_k8s(info)

    path = "software.applications.kubernetes.job_container:"
    inv_node = inventory_tree.get_list(path)

    for container_name, container_data in sorted(parsed.items()):
        inv_node.append({
            'name': container_name,
            'image': container_data['image'],
            'image_pull_policy': container_data['image_pull_policy'],
        })


inv_info['k8s_job_container'] = {
    'inv_function': inv_k8s_job_container,
}
