-
Notifications
You must be signed in to change notification settings - Fork 268
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
How to use oci_cli_rc file in Python SDK #561
Comments
oci_cli_rc file only used by OCI cli and not by the OCI Python SDK |
@spareslant Adi is right, the oci_cli_rc_file is CLI specific. Is there a specific reason you would want to use such as a file against Python SDK? |
Hi @KartikShrikantHegde , we were testing oci session based authentication. i.e
Please note an additional compartment-id in above config. As you know this section may have more keywords as well, that can act as default. But When using Before moving to session based auth, we were using following kind of code in our python scripts config = oci.config.from_file(config_file, profile)
region = config["region"]
compartment_id = config["compartment-id"] After moving to session based auth, above code fails, as compartment-id has been removed from ~/.oci/config file. It would be good if above code could be written something like below to give a unified view of a section in one object. config = oci.config.from_file(config_file, rc_file, profile) |
@spareslant I would like to understand the use case for needing such support. What is the need to use session auth with any config file? Session auth generates a new config file for that session right? |
@KartikShrikantHegde , session auth is not creating any new config file at least thats what we saw. We observed that session auth is writing back to ~/.oci/config file and overwrites the existing profile section. As I mentioned above, it also removed non-required keys from the profile section. In our case it removed compartment-id. We mitigated this problem using oci_cli_rc file for bash scripts, but unfortunately OCI Python SDK is totally oblivious of the existence of this file. It would be great if both Bash scripts and Python scripts can use same set of config files and Python SDK can provide a unified view of a profile section in a single object. At the moment config object obtained from oci.config.from_file is not aware of non-required keys in profile section (which are in oci_cli_rc file) |
@spareslant We will investigate and reproduce the issue in CLI before we can determine if there is a bug at the CLI end. If it is indeed a bug in CLI, we would like to provide a fix rather than change how our SDKs work especially w.r.t to reading from the config file. |
Are you saying that you are going to fix
|
Hi @spareslant While using CLI, If you want to preserve any default values in the config, then keeping it in the ~/.oci/oci_cli_rc file is the right approach. And you seem to have done the same. But in SDK, today we don't support reading from the oci_cli_rc file as it's only CLI specific file. So you would have to write your own implementation for it. Having a unified file to read from for both CLI and Python SDK is a valid request and we will add it to our backlog for prioritization. Note that, we cannot promise when will we have it until we do the prioritization and pick it up to work on it. I will leave the issue open so that if others have the same request, they can upvote on it. |
Hi,
I could not find any example of using oci_cli_rc file using Python SDK. I looked at following page, but no reference for the use ofoci_cli_rc file.
https://docs.oracle.com/en-us/iaas/tools/python/2.108.0/api/config.html?highlight=config#module-oci.config
The text was updated successfully, but these errors were encountered: