Refactoring: Create an http client to handle profile actions#2778
Refactoring: Create an http client to handle profile actions#2778
Conversation
There was a problem hiding this comment.
I have revisited the approach and I have a few comments.
First of all, I am not a big fan of our current API, where we a) include the "path" or the "url" in the query string or b) we include the content of the file in the body. Why not use the body of the request for that? I know it was not introduced on this PR, but we might take the chance to make it better.
We are still constructing the profile client in separate functions (at least in three different places). I do not see the point (and the name of the functions are misleading to me).
Now, some behavior I did not expect (all of them happen in master too):
- Evaluating a profile using a URL that does not exist does not complain.
- Evaluating a local file using a remote Agama host (--host) does not seem to work.
- I cannot get the content of the file using the stdin, although the help says it is supported.
- Using --local does not work for me (e.g., agama --local config validate tw.json). It says I am not authenticated.
However, take them with a grain of salt, because it could be some problem in the environment. I need to have a closer look.
--local is config validate specific option as was decided here #2670. So, proper usage is Note that screenshot contains debugging output |
imobachgs
left a comment
There was a problem hiding this comment.
Hi!
- The
*_clientfunctions are still there. If you want to keep them, it is fine. But, please, find a better name. - Not related to this PR, I do not think
CliInputshould be responsible for converting to a query parameter, a body for a JSON call, etc. But I can live with that until the following refactoring :) - The POST actions should use JSON in their bodies instead of a
a=bformat.
I do not want to make this longer, but it would be nice to at least address points 1 and 3. WDYT?
... this is "in between step" and in the end I plan to rename them. The main focus currently was on removing those queries. However, I plan to keep them (with better names) as they are called on several places and it seems cleaner to me to call one function instead of that long client creation.
... I think that I'll be able to remove most of those "query" functions in the final cleanup ... at least I hope so.
... in fact it is posted as json (client.post encapsulates the content as a json). I'll polish it a bit.
... definitely that's why I asked before stating it as a final version ;-) |
|
Sorry I did a force push because I accidentally put an unwanted modification of Gemfile.lock into one of previous commits |
imobachgs
left a comment
There was a problem hiding this comment.
It looks better now. Please, add the changes entry and so on.
imobachgs
left a comment
There was a problem hiding this comment.
Please, add the reference and you are clear to merge. Thank! :-)
rust/package/agama.changes
Outdated
| Mon Nov 10 14:35:25 UTC 2025 - Michal Filka <mfilka@suse.com> | ||
|
|
||
| - Created ProfileClient based on HTTP API base client for profile | ||
| validation requests and refactored / cleaned relevant code |
There was a problem hiding this comment.
Please, add the reference (gh#agama-project/agaam#2778).
## Problem By mistake previous refactoring (gh##2778) removed printing of resulting profile Now output looks like: <img width="967" height="505" alt="agama_generate_config" src="https://github.com/user-attachments/assets/b4444309-a9c0-46ef-8541-386190bd9336" />
Problem
Not a real problem, just something what was overlooked when during implementation.
Solution
Create an http client to handle profile validation and other actions to use similar approach as in other cases.