#!/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_pod_info(info, inventory_tree, status_data_tree):
    parsed = parse_k8s(info)

    path = "software.applications.kubernetes.pod_info."
    inv_node = inventory_tree.get_dict(path)
    status_node = status_data_tree.get_dict(path)

    for key, value in sorted(parsed.items()):
        if key in {'node', 'host_network', 'dns_policy'}:
            inv_node[key] = value
        else:
            status_node[key] = value


inv_info['k8s_pod_info'] = {
    'inv_function': inv_k8s_pod_info,
}
