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

fix regex in ynh_write_var_in_file/ynh_read_var_in_file #1880

Closed

Conversation

kay0u
Copy link
Member

@kay0u kay0u commented Jun 25, 2024

The problem

https://ci-apps-dev.yunohost.org/ci/logs/17223.log

In this case, the file settings.yml looks like

app: borg__2
apps: all
checksum__etc_sudoers.d_borg__2: 4f07f486aad033a0a8118f0230f55edc
checksum__etc_systemd_system_borg__2.service: c1e7c8d438102836c209f62a17cc33bc
checksum__etc_systemd_system_borg__2.timer: c53468085887c032f414d278bd3a48e2
checksum__etc_yunohost_hooks.d_backup_method_05-borg__2_app: a994558bbacdb10f449f60b153457f58
checksum__var_www_borg__2_backup-with-borg: 25270eec1050acf5d6adf6d2bbbcb0e8
checksum__var_www_borg__2_logging.conf: 1079d7c7ce64c436266c27451e6badaa
conf: 1
current_revision: 68d887fa7dd00f424c4c73f5fa11d77950aae8a6
data: 1
[...]

when we try to get the conf:

yunohost app config get borg

ynh_read_var_in_file --file=/etc/yunohost/apps/borg/settings.yml --key=conf is called. The variable var_part is: ^\s*((const|var|let)\s+)?\$?(\w+(\[\s*["']?\w+["']?\])*(->|\.|\[))*\s*["']?conf["']?\s*\]?\s*(=>|:|=)\s*

which match both checksum__var_www_borg__2_logging.conf: and conf: while we only need conf :

Solution

var_part is: ^\s*((const|var|let)\s+)?\$?((\[\s*["']?\w+["']?\])*(->|\.|\[))*\s*["']?conf["']?\s*\]?\s*(=>|:|=)\s* instead of
var_part is: ^\s*((const|var|let)\s+)?\$?(\w+(\[\s*["']?\w+["']?\])*(->|\.|\[))*\s*["']?conf["']?\s*\]?\s*(=>|:|=)\s*
This seems to fix it, but how can we be sure it will not create regressions?

PR Status

...

How to test

Install borg in testing: sudo yunohost app install https://github.com/YunoHost-Apps/borg_ynh/tree/testing --debug
Try to get the config of the app:
yunohost app config get borg

@kay0u kay0u closed this Jun 28, 2024
@OniriCorpe OniriCorpe deleted the fix-regex-in-ynh_write_var_in_file/ynh_read_var_in_file branch July 3, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant