Skip to content

Add new line if not present in the clients.yml file#145

Closed
ponytojas wants to merge 3 commits intoInternational-Data-Spaces-Association:masterfrom
ponytojas:master
Closed

Add new line if not present in the clients.yml file#145
ponytojas wants to merge 3 commits intoInternational-Data-Spaces-Association:masterfrom
ponytojas:master

Conversation

@ponytojas
Copy link
Copy Markdown

@ponytojas ponytojas commented Sep 12, 2024

Add newline before appending to config/clients.yml
This change ensures that a newline is added before appending new content to the config/clients.yml file. It addresses the following scenarios:
1. If the file already ends with a newline, no additional newline is added.
2. If the file doesn't end with a newline, a newline is inserted before the new content.
This modification improves the reliability of the configuration file generation process by preventing potential formatting issues or unintended merging of content.

EDIT

I added also a check for existing configuration in the clients.yml file based on the client_name and client_id to avoid duplicates

EDIT 2

After careful consideration, I've decided to refactor and rewrite a significant portion of the code while maintaining the core logic. This refactoring was necessary to properly handle several edge cases that were not initially accounted for in the original implementation.

Unfortunately, due to the new manipulations performed by the code, I had to introduce a dependency:

  • yq: A lightweight command-line YAML processor.

The code checks for the existence of a newline at the end of the file, but now in addition to the newline check, the code verifies if a client_id or client_name already exists in the file. If found, the existing entry is modified with the new data instead of adding a duplicate entry.

This enhancement allows for more robust handling of clients, preventing duplicates and ensuring that existing entries are properly updated when new information is available.

@ponytojas ponytojas closed this by deleting the head repository Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant