Convert of old INI-Configfile fails because of missing YAML Rendering #367

Closed
opened 2020-11-14 11:56:19 +00:00 by 0nelight · 3 comments

What I'm trying to do and why

I tried to convert an old INI-Config-File to the new YAML-Format but run into an Error that the file cannot be written because of the missing YAML Rendering.

Steps to reproduce

sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml

Actual behavior

sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml Traceback (most recent call last): File "/usr/local/bin/upgrade-borgmatic-config", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/borgmatic/commands/convert_config.py", line 104, in main args.destination_config_filename, destination_config, mode=source_config_file_mode File "/usr/local/lib/python3.7/dist-packages/borgmatic/config/generate.py", line 128, in write_configuration config_file.write(rendered_config) TypeError: write() argument must be str, not CommentedMap

Other notes / implementation ideas

instead of this in /commands/convert_config.py:

destination_config = convert.convert_legacy_parsed_config(
	source_config, source_excludes, schema
	)

generate.write_configuration(
	args.destination_config_filename, destination_config, mode=source_config_file_mode
    )

this:

destination_config = convert.convert_legacy_parsed_config(
	source_config, source_excludes, schema
	)
 
destination_config = generate._render_configuration(destination_config)
 
generate.write_configuration(
	args.destination_config_filename, destination_config, mode=source_config_file_mode
    )

Environment

borgmatic version: 1.5.10

borgmatic installation method: pip

Borg version: 1.1.11

Python version: Python 3.7.3

operating system and version: Debian 10

#### What I'm trying to do and why I tried to convert an old INI-Config-File to the new YAML-Format but run into an Error that the file cannot be written because of the missing YAML Rendering. #### Steps to reproduce `sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml` #### Actual behavior `sudo upgrade-borgmatic-config -s ../borgmatic_config_files_old/backupconfig -d backupconfig.yaml Traceback (most recent call last): File "/usr/local/bin/upgrade-borgmatic-config", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/borgmatic/commands/convert_config.py", line 104, in main args.destination_config_filename, destination_config, mode=source_config_file_mode File "/usr/local/lib/python3.7/dist-packages/borgmatic/config/generate.py", line 128, in write_configuration config_file.write(rendered_config) TypeError: write() argument must be str, not CommentedMap` #### Other notes / implementation ideas instead of this in [/commands/convert_config.py](https://projects.torsion.org/witten/borgmatic/src/commit/79bee755eed653c64a6a55a76b86695a10bb328f/borgmatic/commands/convert_config.py): ``` destination_config = convert.convert_legacy_parsed_config( source_config, source_excludes, schema ) generate.write_configuration( args.destination_config_filename, destination_config, mode=source_config_file_mode ) ``` this: ``` destination_config = convert.convert_legacy_parsed_config( source_config, source_excludes, schema ) destination_config = generate._render_configuration(destination_config) generate.write_configuration( args.destination_config_filename, destination_config, mode=source_config_file_mode ) ``` #### Environment **borgmatic version:** 1.5.10 **borgmatic installation method:** pip **Borg version:** 1.1.11 **Python version:** Python 3.7.3 **operating system and version:** Debian 10
0nelight reopened this issue 2020-11-14 11:58:00 +00:00
Owner

Thank you so much for reporting this and tracking down the source of the problem! It looks like the write_configuration() function signature changed somewhere along the way, but convert_config.py wasn't ever updated to account for that. An integration test here would've been really useful.

Thank you so much for reporting this and tracking down the source of the problem! It looks like the `write_configuration()` function signature changed somewhere along the way, but `convert_config.py` wasn't ever updated to account for that. An integration test here would've been really useful.
witten added the
bug
label 2020-11-14 21:50:05 +00:00
Owner

Fixed in master! Thanks again for reporting this.

Fixed in master! Thanks again for reporting this.
Owner

Just released in borgmatic 1.5.11!

Just released in borgmatic 1.5.11!
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#367
No description provided.