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

Save Profile Properties to Config File & Secure Vault Storage (#73, #72) #201

Merged
merged 33 commits into from
Sep 28, 2023

Conversation

samadpls
Copy link
Contributor

@samadpls samadpls commented Jul 21, 2023

What It Does

Resolves #73 , #72

How to Test

Review Checklist
I certify that I have:

Additional Comments

Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good start to me 👍 Left one comment

src/core/zowe/core_for_zowe_sdk/config_file.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Attention: 16 lines in your changes are missing coverage. Please review.

Files Coverage Δ
tests/unit/test_zowe_core.py 99.57% <100.00%> (+0.13%) ⬆️
src/core/zowe/core_for_zowe_sdk/profile_manager.py 83.90% <87.50%> (+0.81%) ⬆️
src/core/zowe/core_for_zowe_sdk/config_file.py 87.50% <84.93%> (-0.70%) ⬇️

📢 Thoughts on this report? Let us know!.

@zFernand0 zFernand0 self-requested a review August 2, 2023 15:06
@t1m0thyj t1m0thyj changed the base branch from main to multi-credentials August 11, 2023 23:13
…_highest_priority_layer` functions

Signed-off-by: samadpls <[email protected]>
@samadpls samadpls changed the title issue #73 Save profile properties to zowe.config.json file issue #73 & #72 Save profile properties & Vault to zowe.config.json file Aug 14, 2023
@samadpls samadpls changed the title issue #73 & #72 Save profile properties & Vault to zowe.config.json file Save Profile Properties to Config File & Secure Vault Storage (#73, #72) Aug 14, 2023
@JTonda JTonda requested a review from t1m0thyj August 16, 2023 15:04
Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments 🙂 Also please address failing tests

src/core/zowe/core_for_zowe_sdk/config_file.py Outdated Show resolved Hide resolved
src/core/zowe/core_for_zowe_sdk/config_file.py Outdated Show resolved Hide resolved
src/core/zowe/core_for_zowe_sdk/config_file.py Outdated Show resolved Hide resolved
src/core/zowe/core_for_zowe_sdk/config_file.py Outdated Show resolved Hide resolved
Signed-off-by: samadpls <[email protected]>
Signed-off-by: samadpls <[email protected]>
@samadpls samadpls requested a review from t1m0thyj August 23, 2023 18:47
Base automatically changed from multi-credentials to main August 29, 2023 17:34
Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having some issues when testing this PR using the following procedure:

  1. Using Zowe CLI, run zowe config init --no-prompt to create a zowe.config.json template.
  2. Using the Python SDK, run a test script to update a profile property:
    from zowe.core_for_zowe_sdk import ProfileManager
    pm = ProfileManager(show_warnings=False)
    pm.load(profile_type="zosmf")
    pm.set_property("profiles.zosmf.properties.port", 1443)
    pm.save()
    
  3. Receive an error because "zowe.config.user.json" is missing:
Traceback (most recent call last):
  File "/Users/Timothy/Projects/zowe/zowe-client-python-sdk/test.py", line 9, in <module>
    pm.set_property("profiles.zosmf.properties.port", 1443)
  File "/Users/Timothy/Projects/zowe/zowe-client-python-sdk/src/core/zowe/core_for_zowe_sdk/profile_manager.py", line 362, in set_property
    highest_priority_layer = self.get_highest_priority_layer(json_path)
  File "/Users/Timothy/Projects/zowe/zowe-client-python-sdk/src/core/zowe/core_for_zowe_sdk/profile_manager.py", line 334, in get_highest_priority_layer
    layer.init_from_file()
  File "/Users/Timothy/Projects/zowe/zowe-client-python-sdk/src/core/zowe/core_for_zowe_sdk/config_file.py", line 119, in init_from_file
    self.autodiscover_config_dir()
  File "/Users/Timothy/Projects/zowe/zowe-client-python-sdk/src/core/zowe/core_for_zowe_sdk/config_file.py", line 234, in autodiscover_config_dir
    raise FileNotFoundError(f"Could not find the file {self.filename}")
FileNotFoundError: Could not find the file zowe.config.user.json

Signed-off-by: samadpls <[email protected]>
Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work thus far @samadpls!

Regarding the error w/ a missing zowe.config.user.json:

If I provide a zowe.config.user.json in my working directory, the code continues, but it then tries to open a zowe.config.user.json in my Zowe home directory. It fails here as it cannot find the file in my .zowe folder.

However, the code looks good so far, so I think once the error handling is added for accessing zowe.config.user.json, it should work as intended 🙂

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -42,6 +42,8 @@

# Profile datatype is used by ConfigFile to return Profile Data along with
# metadata such as profile_name and secure_props_not_found


class Profile(NamedTuple):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the autodiscover_config_dir function, do we want to skip over zowe.config.user.json if it does not exist? It is optional, so we should avoid throwing exceptions for a missing user-level config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be resolved by implementing a try-except block while invoking the function.

@JTonda JTonda requested review from t1m0thyj and traeok September 18, 2023 15:04
Copy link
Member

@traeok traeok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested w/ changes and LGTM, thanks @samadpls!

Copy link
Member

@t1m0thyj t1m0thyj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @samadpls!

@t1m0thyj t1m0thyj merged commit ebc5c3f into main Sep 28, 2023
20 checks passed
@t1m0thyj t1m0thyj deleted the save-profile-prop branch September 28, 2023 15:45
@t1m0thyj t1m0thyj linked an issue Oct 2, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] Save profile properties to zowe.config.json file [core] Save secure profile properties to vault
4 participants