kapicorp / kapitan

Generic templated configuration management for Kubernetes, Terraform and other things
https://kapitan.dev
Apache License 2.0
1.83k stars 199 forks source link

f809747 breaks compile #224

Closed rbounds closed 5 years ago

rbounds commented 5 years ago

Describe the bug/feature

Removal of ujson in f8097473df64678b1ba8b34100babe49f050450a breaks compile as json does not support escape_forward_slashes kwarg.

To Reproduce: Steps to reproduce the behavior: cd examples/terraform docker run -u $(id -u) -t --rm -v $(pwd):/src:delegated deepmind/kapitan:latest compile

Example Output:

kapitan/examples/terraform$ docker run -u $(id -u) -t --rm -v $(pwd):/src:delegated deepmind/kapitan:latest compile
Unknown (Non-Kapitan) Error occured
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/kapitan/kapitan/targets.py", line 321, in compile_target
    input_compiler.compile_obj(comp_obj, ext_vars, **kwargs)
  File "/kapitan/kapitan/inputs/base.py", line 46, in compile_obj
    self.compile_input_path(input_path, comp_obj, ext_vars, **kwargs)
  File "/kapitan/kapitan/inputs/base.py", line 66, in compile_input_path
    target_name=target_name, **kwargs)
  File "/kapitan/kapitan/inputs/jsonnet.py", line 67, in compile_file
    fp.write_json(item_value)
  File "/kapitan/kapitan/inputs/base.py", line 126, in write_json
    json.dump(obj, self.fp, indent=indent, escape_forward_slashes=False)
  File "/usr/local/lib/python3.7/json/__init__.py", line 176, in dump
    default=default, sort_keys=sort_keys, **kw).iterencode(obj)
TypeError: __init__() got an unexpected keyword argument 'escape_forward_slashes'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/kapitan/kapitan/targets.py", line 80, in compile_targets
    [p.get() for p in pool.imap_unordered(worker, target_objs) if p]
  File "/kapitan/kapitan/targets.py", line 80, in <listcomp>
    [p.get() for p in pool.imap_unordered(worker, target_objs) if p]
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
TypeError: __init__() got an unexpected keyword argument 'escape_forward_slashes'

Expected Output:

kapitan/examples/terraform$ docker run -u $(id -u) -t --rm -v $(pwd):/src:delegated deepmind/kapitan:0.22 compile
Compiled project2 (0.19s)
Compiled project3 (0.21s)
Compiled project1 (0.25s)
uberspot commented 5 years ago

Sorry about this, we were missing tests for json output. I added a test for that as well now which should catch it in the future. :+1: Thanks for reporting.