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

Load profile properties from environment variables #136

Closed
Tracked by #148
t1m0thyj opened this issue Sep 9, 2022 · 4 comments · Fixed by #200
Closed
Tracked by #148

Load profile properties from environment variables #136

t1m0thyj opened this issue Sep 9, 2022 · 4 comments · Fixed by #200
Assignees
Labels
enhancement New feature or request priority-low

Comments

@t1m0thyj
Copy link
Member

t1m0thyj commented Sep 9, 2022

When loading a profile from team config, have an opt-in flag to support loading of properties from environment variables.

For example, in an environment where I don't want to store credentials securely, the user and password properties should be loaded from ZOWE_OPT_USER and ZOWE_OPT_PASSWORD respectively.

@t1m0thyj t1m0thyj added this to the Zowe v2 Team Configuration milestone Sep 9, 2022
@zFernand0 zFernand0 added enhancement New feature or request priority-medium labels Mar 9, 2023
@bhavukkalra
Copy link

Hey there @t1m0thyj. Just for clarification purposes for this issue. Is the idea here to load the Environment variables from a user provided, local .env file?

@bhavukkalra
Copy link

For the below discussion I'll be taking this code as reference:

# (This is what I got from the readme, Doesn't works)
# from zowe.zos_core_for_zowe_sdk import ProfileManager 

# This one works
from zowe.core_for_zowe_sdk import ProfileManager

from zowe.zos_console_for_zowe_sdk import Console

# Creates a dictionary object (example)
# {'host': 'globalhost', 'rejectUnauthorized': True, 'user': 'bhavuk', 'password': 'bh', 'port': 443}
profile = ProfileManager(appname="Give user config name here").load(profile_type="zosmf")

my_console = Console(profile)

Question 1 - The import that is mentioned in the readme in the next branch.

from zowe.zos_core_for_zowe_sdk import ProfileManager 

Doesn't work, I replaced it with something that does. (Correct it in the readme as well via PR?)

Question 2 - I have now clearly understood on how the configs are getting inputed. I have a few clarifying questions on how the above feature is supposed to look like

Example 1 - Create a function load_from_environment_file() in the file profile_manager.py which in implementation could look something like

profile = ProfileManager(appname="Give user config name here").load_from_env_file("ENV_FILE_PATH_HERE)")

load_from_env_file will contain logic for parsing the input .env file and output a dictionary of configs

Example 2 - More Info on the opt-in flag. Like a use case scenario could really help on how are we imagining the functionality should look like.

@t1m0thyj
Copy link
Member Author

Environment variables take priority over values defined in the config
Can load list of properties (host, port, user, password, etc) from schema

@t1m0thyj
Copy link
Member Author

Environment variables have ZOWE_OPT_ prefix
camelCase properties in config/schema JSON map to snake_case in environment variables
For example: Env Var to override rejectUnauthorized property is ZOWE_OPT_REJECT_UNAUTHORIZED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority-low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants