Skip to content

Conversation

@takenory
Copy link
Collaborator

@takenory takenory commented Feb 5, 2024

This PR is to add the export/import that @maeda-m proposed in #42.
Thanks to @maeda-m for his useful suggestion!

@takenory takenory requested a review from maeda-m February 5, 2024 08:58
Comment on lines +40 to +44
if import_address_with_comments.blank?
abort 'IP addresses to add must be specified with IMPORT environment variable'
else
filter_rule.allowed_ips = ([filter_rule.allowed_ips_with_comments, import_address_with_comments]).join("\n")
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @takenory . Thank you for the pull request.

In my review at #36 (review), I made a mistake in my suggestion.

Right now, the Import feature adds to the current allowed IP addresses. But, I think it should replace the current allowed IP addresses with the imported ones.

Suggested change
if import_address_with_comments.blank?
abort 'IP addresses to add must be specified with IMPORT environment variable'
else
filter_rule.allowed_ips = ([filter_rule.allowed_ips_with_comments, import_address_with_comments]).join("\n")
end
if import_address_with_comments.blank?
abort 'IP addresses to import must be specified with IMPORT environment variable'
else
filter_rule.allowed_ips = import_address_with_comments
end

My suggestion has a downside. Since it's not adding, if setting the allowed IP addresses fails, we would have to run the import again or manually add remote addresses. But, since we can run rake tasks, I think we can handle it.

I would appreciate your feedback on this matter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maeda-m Thx for suggetion.

I thought it was debatable whether the behavior of import should be "replace" or not.
When importing issues from CSV in Redmine, the imported data behaves as "appended", not "replaced".

If the risk is that a successful import with incorrect data will "replace" the original IP address settings (and in some cases make them unrecoverable), I think it is safer to behave as an "addition".

@maeda-m maeda-m self-requested a review March 14, 2024 02:46
Copy link

@maeda-m maeda-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@takenory

LGTM 👍

If we consider the risk of the original IP address settings being "replaced" due to successful import of incorrect data (which might become irrecoverable in some cases), it's safer to act as "addition" rather than replacement.

Also, when importing issues from CSV in Redmine, the imported data behaves as an "addition" rather than a "replacement", so it's less surprising if redmine_ip_filter also follows that behavior.

@takenory
Copy link
Collaborator Author

@maeda-m
Thanks for your review.
I would like to merge this PR feature added by your suggestion.

@takenory takenory merged commit 9345840 into redmica:master Mar 14, 2024
@takenory takenory deleted the feature/add_import_export_task branch March 14, 2024 07:27
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.

2 participants