Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jsonnet input type cannot output a string #431

Closed
tprobinson opened this issue Dec 10, 2019 · 1 comment
Closed

Jsonnet input type cannot output a string #431

tprobinson opened this issue Dec 10, 2019 · 1 comment
Assignees
Labels

Comments

@tprobinson
Copy link

Describe the bug/feature
If a jsonnet component outputs a string instead of an object, Kapitan will crash during compilation:

Unknown (Non-Kapitan) Error occured
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "multiprocessing/pool.py", line 121, in worker
  File "kapitan/targets.py", line 387, in compile_target
  File "kapitan/inputs/base.py", line 59, in compile_obj
  File "kapitan/inputs/base.py", line 74, in compile_input_path
  File "kapitan/inputs/jsonnet.py", line 61, in compile_file
AttributeError: 'str' object has no attribute 'items'
"""

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

Traceback (most recent call last):
  File "kapitan/targets.py", line 95, in compile_targets
  File "kapitan/targets.py", line 95, in <listcomp>
  File "multiprocessing/pool.py", line 748, in next
AttributeError: 'str' object has no attribute 'items'

To Reproduce
Steps to reproduce the behavior:

  1. Set up a test Kapitan project as follows:

inventory/targets/test.yml

classes:
  - test

parameters:
  kapitan:
    vars:
      target: test

inventory/classes/test.yml

parameters:
  kapitan:
    compile:
    - output_path: .
      input_type: jsonnet
      output_type: json
      input_paths:
        - components/test.jsonnet

components/test.jsonnet

'test'
  1. Run kapitan compile

Expected behavior
The output file contains a double-quoted string, which is valid JSON.

** If it's a bug (please complete the following information):**

  • python --version: Python 2.7.16
  • pip3 --version: Not installed.
  • Are you using pyenv or virtualenv?: Neither, using static kapitan binary on Ubuntu 19.10
@uberspot uberspot added the bug label Dec 10, 2019
@uberspot uberspot self-assigned this Dec 10, 2019
uberspot added a commit that referenced this issue Dec 10, 2019
…an object with items. Now kapitan will convert to object before outputting.
uberspot added a commit that referenced this issue Dec 10, 2019
…an object with items. Now kapitan will convert to object before outputting.
uberspot added a commit that referenced this issue Dec 10, 2019
…an object with items. Now kapitan will convert to object before outputting. Also cover list and non-string use-cases
uberspot added a commit that referenced this issue Dec 10, 2019
…an object with items. Now kapitan will convert to object before outputting. Also cover list and non-string use-cases
uberspot added a commit that referenced this issue Dec 10, 2019
Fix issue #431: jsonnet compile fails for a single string that isn't …
@uberspot
Copy link
Contributor

Fixed on master. Added a test + a small doc update for it as well.
We'll do another rc version within the week. :)
Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants