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

Handle saptune payload #1801

Merged
merged 21 commits into from
Sep 13, 2023
Merged

Handle saptune payload #1801

merged 21 commits into from
Sep 13, 2023

Conversation

CDimonaco
Copy link
Member

Description

Handle Saptune payload in Host Policy.

How was this tested?

Automated tests

@CDimonaco CDimonaco added enhancement New feature or request elixir Pull requests that update Elixir code labels Sep 11, 2023
@CDimonaco CDimonaco self-assigned this Sep 11, 2023
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey @CDimonaco ,
Seeing the code, my major concern is this "transformation" of the payload in the policy. Not that it is done there. How it is done.
You are combining the updating the incoming message data.
Wouldn't be cleaner to get the data from the message and create a new map from scratch;
For example

%{packaget_version: package_version} = result = Map.get(payload, "result")
{}
|> Map.put("package_version", package_version)
|> Map.put("services", build_saptune_service(result)
|> Map.put("enabled_solutions", build_saptune_enabled_solutions(result)
    ...

Maybe it is a bit more verbose, but it you totally build the payload, without depending that much in the incoming data. In the current way it is really attached

deftype do
field :package_version, :string
field :configured_version, :string
field :tuning_state, :string
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be an enum as we only have 3 options: compliant, not compliant and no tuning..
(yes, with spaces, we could change that as well to use snake_case I guess)

@CDimonaco CDimonaco force-pushed the handle_saptune_payload branch from 7d3e8bb to ee4e4bd Compare September 12, 2023 09:55
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey @CDimonaco,
The code looks good in general.
I dropped some comments.
Besides that, can we add moduledocs to all the files?

I guess once we have tests we will see if all the code is correct

lib/trento/domain/value_objects/saptune_staging.ex Outdated Show resolved Hide resolved
deftype do
field :enabled, :boolean
field :notes, {:array, :string}
field :solutions_ids, {:array, :string}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would call this solutions

Copy link
Member Author

Choose a reason for hiding this comment

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

idk solutions in other value object refer to the whole solution object, I prefer to stick to ids, to just not confuse the stuff 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

well, but you have notes above, which is a list of note ids as well...
so we follow the same rule in both entries I guess

lib/trento/domain/value_objects/saptune_service_status.ex Outdated Show resolved Hide resolved
@CDimonaco CDimonaco force-pushed the handle_saptune_payload branch from f0d6884 to 9525e82 Compare September 13, 2023 08:52
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Hey @CDimonaco , @EMaksy
All looking great.
Once we have the services entry sorted out we can merge

deftype do
field :enabled, :boolean
field :notes, {:array, :string}
field :solutions_ids, {:array, :string}
Copy link
Contributor

Choose a reason for hiding this comment

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

well, but you have notes above, which is a list of note ids as well...
so we follow the same rule in both entries I guess

}),
do: %{"id" => solution_id, "notes" => note_list, "partial" => partially_applied}

defp format_saptune_staging_informations(%{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not simply format_saptune_staging ?
In any case the final informations with a plural s looks wrong

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

Green light from my side!
Once the needed module docs are there, we can merge

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

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

@EMaksy Some suggestions on the moduledocs

lib/trento/domain/value_objects/saptune_note.ex Outdated Show resolved Hide resolved
lib/trento/domain/value_objects/saptune_service_status.ex Outdated Show resolved Hide resolved
lib/trento/domain/value_objects/saptune_solution.ex Outdated Show resolved Hide resolved
@EMaksy EMaksy force-pushed the handle_saptune_payload branch 2 times, most recently from 9c2af10 to 14ece18 Compare September 13, 2023 12:39
@EMaksy EMaksy force-pushed the handle_saptune_payload branch 2 times, most recently from a1727c2 to 74724dc Compare September 13, 2023 12:59
@CDimonaco CDimonaco marked this pull request as ready for review September 13, 2023 13:10
@CDimonaco CDimonaco merged commit 7ea50d5 into main Sep 13, 2023
@CDimonaco CDimonaco deleted the handle_saptune_payload branch September 13, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants