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

kapitan refs fail to handle binary files #791

Closed
ademariag opened this issue Nov 1, 2021 · 0 comments · Fixed by #829
Closed

kapitan refs fail to handle binary files #791

ademariag opened this issue Nov 1, 2021 · 0 comments · Fixed by #829
Labels

Comments

@ademariag
Copy link
Contributor

ademariag commented Nov 1, 2021

Describe the bug/feature
Kapitan refs fail to correctly encode binary files, while it works ok with text files

To Reproduce
Steps to reproduce the behavior:

kapitan refs --write base64:binary/binary -t echo-server --base64 -f /usr/bin/true 
Traceback (most recent call last):
  File "/usr/local/bin/kapitan", line 8, in <module>
    sys.exit(main())
  File "/Users/ademaria/Library/Python/3.9/lib/python/site-packages/kapitan/cli.py", line 562, in main
    args.func(args)
  File "/Users/ademaria/Library/Python/3.9/lib/python/site-packages/kapitan/refs/cmd_parser.py", line 27, in handle_refs_command
    ref_write(args, ref_controller)
  File "/Users/ademaria/Library/Python/3.9/lib/python/site-packages/kapitan/refs/cmd_parser.py", line 50, in ref_write
    data = fp.read()
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 0: invalid continuation byte

Expected behavior
Binary is correctly encoded.

Screenshots
If applicable, add screenshots to help explain your problem/idea.

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

  • python3 --version: Python 3.9.7
  • pip3 --version: pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
  • Are you using pyenv or virtualenv? no

Additional context
Related to work for kapicorp/kapitan-reference#106

WORKAROUND
Simply encode the file before importing. i.e.:

base64 /usr/bin/true  | kapitan refs --write base64:binary/binary -t echo-server -f -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant