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 required fields usage #2214

Merged
merged 6 commits into from
Jan 24, 2024
Merged

Fix required fields usage #2214

merged 6 commits into from
Jan 24, 2024

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented Jan 23, 2024

Description

Fix validate_required_fields usage. We were using this function incorrectly in many places.
When we have an explicit changeset implemented for the Type, the validate_required_fields only works for the type itself. If there are other inline types with their own changeset functions, we cannot use it, as it would expand the fields of the main module, and not run the proper validation.
Together with this, in other to check if embedded fields are required or not, we cannot use validate_required_fields, we need to set the required: true in the embed_cast itself.

Using the macro changeset all of this is done there.

PD: I have tried to put the required values in the places where it makes sense. Until now, any of them on the embeds_* was working, so it was like there were not required. Many of them actually shouldn't be required...

As a bonus, I have removed the sbd from the required list (even though it was not really working) to avoid an error we were having when the cluster doesn't have sbd configured. FYI @abravosuse

Ref: https://github.com/trento-project/web/pull/1422/files#r1196297634

How was this tested?

Current tests passing

@arbulu89 arbulu89 added the bug Something isn't working label Jan 23, 2024
@@ -278,6 +278,8 @@ defmodule Trento.Discovery.Policies.ClusterPolicy do
end)
end

defp parse_sbd_devices(_), do: []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enable empty sbd data coming, for future non sbd scenario.
PD: without this, we were having a nasty error

@arbulu89 arbulu89 marked this pull request as ready for review January 23, 2024 16:01
Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

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

👀

@arbulu89 arbulu89 merged commit 9d4530c into main Jan 24, 2024
24 checks passed
@arbulu89 arbulu89 deleted the fix-required-fields-usage branch January 24, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

None yet

3 participants