import yaml


def configMap(name, **kwargs):
    """
    >>> import nuvolaris.kube as kube, nuvolaris.testutil as tu
    >>> tu.grep(kube.configMap("hello", value="world"), "kind:|name:|value:", sort=True)
    kind: ConfigMap
    name: hello
    value: world
    >>> tu.grep(kube.configMap("hello", **{"file.js":"function", "file.py": "def"}), "file.", sort=True)
    file.js: function
    file.py: def
    """
    out = yaml.safe_load("""apiVersion: v1
kind: ConfigMap
metadata:
  name: %s
data: {}
"""% name)
    for key, value in kwargs.items():
        out['data'][key] = value
    return yaml.dump(out)