Open bkircher opened 2 years ago
I'm looking at examples.py to get an idea now of what to do. This is how it currently works:
#TODO: Insert your API token and User ID api_config.api_key['X-Auth-Token'] = "AUTH_TOKEN" api_config.api_key['X-Auth-UserId'] = "USER_UUID"
This then uses configuration.py from gs_api_client to create the authentication settings. Should this be changed to populate X-Auth-Token and X-Auth-UserId from the yaml file? Then only the project would have to be specified in the examples.py
a first draft: https://github.com/gridscale/gridscale_api_client_python/commit/acb07f79e4526a67225c027a3b7a9c099dcd1b49.
Works on Mac but I can only check next week if the paths are formatted correctly on linux and windows. Happy easter.
Hey. Thanks for the work :heart: and sorry for being a bit unresponsive! :pensive:
As a quick feed back on that branch:
First, can you drop the additions under .idea/ please? I have no objections adding editorconfig, IDE files, whatever if they make sense but if we do we should do it in a separate branch and PR and get the right people to review (like other PyCharm users :slightly_smiling_face: ).
Now to the nitty-gritty, the changes in configloader.py. Let's do it step by step.
Can you make load_config return a list of dicts whereas the keys are as follows?
{
"name": str
"user_id": str
"token": str
"url": str
}
This makes load_config always return a list (possible empty) of all projects that are defined by the user. It does not need to concern itself which one is default or "active" or so.
Since we're parsing YAML we need to add pyyaml
as dependency (setup.py or dev-requirements.txt or both)
We should start by writing a small test to define an interface and the basic behavior. I took the freedom to do this here (2c62062) in your branch. You can run pytest
to see the result. It currently fails. Maybe try to make it green without changing the test?
Ah, just saw another "formality". Can you make sure that you follow git commit message rules? See here for a nice writeup: https://cbea.ms/git-commit/#seven-rules
In your case, use imperative language and capitalization and punctuation. You might also want to configure your git config in a way that it shows your real name and email:
$ git config user.name "Jonathan Lutterbeck"
$ git config user.email jonathan@gridscale.io
We want to create a new config file that is shared across the different libraries and tools that use the gridscale API: https://github.com/gridscale/terraform-provider-gridscale/issues/183
For this we need to have a function that reads that config file into an internal representation and probably also a function that writes such a config file if it does not yet exists.
See https://github.com/gridscale/terraform-provider-gridscale/issues/183 for the format of the file and file paths on the different platforms.