Repository navigation
Allow reading and writing shared config file #20
Description
Activity
- addedenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
on Apr 14, 2022 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 ❤️ and sorry for being a bit unresponsive! 😔
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 🙂 ).
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
pyyamlas 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
pytestto 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-rulesIn 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- linked a pull request that will close this issueEnhancement/20 allow reading and writing shared config file #23
on May 21, 2022
We want to create a new config file that is shared across the different libraries and tools that use the gridscale API: gridscale/terraform-provider-gridscale#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 gridscale/terraform-provider-gridscale#183 for the format of the file and file paths on the different platforms.