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

Fixes profile merge order to match Node.js SDK #203

Merged
merged 16 commits into from
Oct 2, 2023

Conversation

aadityasinha-dotcom
Copy link
Contributor

What It Does

Resolves #190

How to Test

Review Checklist
I certify that I have:

Additional Comments

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

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

Files Coverage Δ
tests/unit/test_zowe_core.py 99.58% <100.00%> (+<0.01%) ⬆️
src/core/zowe/core_for_zowe_sdk/profile_manager.py 80.72% <97.22%> (-3.18%) ⬇️
src/core/zowe/core_for_zowe_sdk/config_file.py 89.25% <92.30%> (+1.75%) ⬆️

... and 1 file with indirect coverage changes

📢 Thoughts on this report? Let us know!.

for i, (config_type, cfg) in enumerate(config_layers.items()):
loaded_cfg = always_merger.merge(loaded_cfg, cfg.profiles)
Copy link
Contributor Author

@aadityasinha-dotcom aadityasinha-dotcom Aug 9, 2023

Choose a reason for hiding this comment

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

I did use the deepmerge library so that it can merge each layer as a whole config

Copy link
Member

@t1m0thyj t1m0thyj Aug 10, 2023

Choose a reason for hiding this comment

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

Not all config layers can be merged with the same merger function. See the Node.js SDK for how profiles of each layer should be merged:

  1. Project and Project User are deep merged into a temporary Project Merged layer
  2. Global and Global User are deep merged into a temporary Global Merged layer
  3. Add profiles to Project Merged layer which are only present in Global Merged layer

src/core/zowe/core_for_zowe_sdk/profile_manager.py Outdated Show resolved Hide resolved
for i, (config_type, cfg) in enumerate(config_layers.items()):
loaded_cfg = always_merger.merge(loaded_cfg, cfg.profiles)
Copy link
Member

@t1m0thyj t1m0thyj Aug 10, 2023

Choose a reason for hiding this comment

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

Not all config layers can be merged with the same merger function. See the Node.js SDK for how profiles of each layer should be merged:

  1. Project and Project User are deep merged into a temporary Project Merged layer
  2. Global and Global User are deep merged into a temporary Global Merged layer
  3. Add profiles to Project Merged layer which are only present in Global Merged layer

@JTonda JTonda requested a review from t1m0thyj August 16, 2023 15:05
@aadityasinha-dotcom
Copy link
Contributor Author

aadityasinha-dotcom commented Sep 27, 2023

@t1m0thyj please review this PR

Comment on lines 289 to 299
# Creating copies of the usrProject and project objects
usrProjectCopy = deepcopy(usrProject)
projectCopy = deepcopy(project)
prjt = always_merger.merge(usrProject, project)

usrGlobal = self.global_user_config.profiles
glbal = self.global_config.profiles

# Creating copies of the usrGlobal and glbal objects
usrGlobalCopy = deepcopy(usrGlobal)
glbalCopy = deepcopy(glbal)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created the copies using deepcopy for the objects before getting merged

@t1m0thyj t1m0thyj requested a review from traeok September 29, 2023 19:52
Copy link
Member

@zFernand0 zFernand0 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 a tough time trying to find differences in behavior with the NodeJS SDK.
LGTM! 😋

@zFernand0 zFernand0 dismissed t1m0thyj’s stale review September 29, 2023 20:04

changes addressed 😋

@t1m0thyj t1m0thyj merged commit 467340a into zowe:main Oct 2, 2023
19 checks passed
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.

Fix profile merge order to match Node.js SDK
4 participants