-
Notifications
You must be signed in to change notification settings - Fork 86
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
Profile API merge error #2383
Profile API merge error #2383
Conversation
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: jace-roell <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2383 +/- ##
=======================================
Coverage 91.27% 91.28%
=======================================
Files 638 638
Lines 18190 18207 +17
Branches 3888 3822 -66
=======================================
+ Hits 16603 16620 +17
Misses 1586 1586
Partials 1 1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: jace-roell <[email protected]>
packages/imperative/src/config/__tests__/ProfileInfo.TeamConfig.unit.test.ts
Fixed
Show fixed
Hide fixed
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: jace-roell <[email protected]>
📅 Suggested merge-by date: 12/27/2024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jace-roell A user config merges differently when both config files are at the same level (profiles are merged property-by-property) than when one profile is global and one profile is in a project directory (the entire profile is replaced). Details are documented here: zowe-cli/docs/How_config_files_are_merged.md Have you manually tested such combinations to confirm that they all work as intended? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In practice the properties seems to be loaded in accordance with the document that Geneshared:
Using the script below
/* Save this file as `test.mjs` and run `node test.mjs` */
import { ProfileInfo } from "@zowe/imperative";
import * as util from "util";
(async () => {
const profInfo = new ProfileInfo("zowe");
await profInfo.readProfilesFromDisk();
const zosmfProfAttrs = profInfo.getDefaultProfile("zosmf");
const zosmfMergedArgs = profInfo.mergeArgsForProfile(zosmfProfAttrs, { getSecureVals: true });
console.log("Known args: ", util.inspect(zosmfMergedArgs.knownArgs, {depth: 3, colors: true}))
})().catch((err) => {
console.error(err);
process.exit(1);
});
I can see the following outputs:
-
On `prof-info-api-fail` - rejectUnathorized is merged according to the document
zFernand0 @ Mac (arm64) ~/gh/zowe/cli.master [15:39:25] > $ node test.mjs ⬡ system [±prof-info-api-fail ●(✹)] Known args: [ { argName: 'port', dataType: 'number', argValue: 1234, argLoc: { locType: 1, osLoc: [ '/Users/zFernand0/.zowe/zowe.config.user.json' ], jsonLoc: 'profiles.zosmf.properties.port' }, secure: false, inSchema: true }, { argName: 'rejectUnauthorized', dataType: 'boolean', argValue: false, argLoc: { locType: 1, osLoc: [ '/Users/zFernand0/.zowe/zowe.config.user.json' ], jsonLoc: 'profiles.base.properties.rejectUnauthorized' }, secure: false, inSchema: true } ]
-
On Master (rejectUnathorized is not merged according to the document)
zFernand0 @ Mac (arm64) ~/gh/zowe/cli.master [15:39:25] > $ node test.mjs ⬡ system [±master ●(✹)] Known args: [ { argName: 'port', dataType: 'number', argValue: 1234, argLoc: { locType: 1, osLoc: [ '/Users/zFernand0/.zowe/zowe.config.user.json' ], jsonLoc: 'profiles.zosmf.properties.port' }, secure: false, inSchema: true } ]
The reason for the requested changes is that is you look closely, the osLoc
for rejecjectUnauthorized is pointing to the global user config instead of where it came from (the global regular/non-user config). Having a wrong osLoc
value may cause other issues in the future if properties need to be updated. I believe we go to that osLoc and update them. Then, attempting to update the rejectUnauthorized value may result in a new base profile being created in the config.user.json file 😋
And yeah, my configs are as simple as:
`zowe.config.user.json`
{
"$schema": "./zowe.schema.json",
"profiles": {
"zosmf": {
"type": "zosmf",
"properties": {
"port": 1234
},
"secure": []
}
},
"defaults": {
"zosmf": "zosmf"
},
"autoStore": true
}
`zowe.config.json`
{
"$schema": "./zowe.schema.json",
"profiles": {
"base": {
"type": "base",
"properties": {
"rejectUnauthorized": false
},
"secure": []
}
},
"defaults": {
"base": "base"
},
"autoStore": true
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting some edits to the changelog entry
Signed-off-by: jace-roell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice changelog @jace-roell!
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: Jace Roell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some lint warnings regarding indentation after removing the if/else login for the osLocInfo
😋
https://github.com/zowe/zowe-cli/actions/runs/12394840626/job/34599196199?pr=2383#step:5:44
But other than that, this PR LGTM! 😋
Quality Gate passedIssues Measures |
Signed-off-by: jace-roell <[email protected]>
Signed-off-by: jace-roell <[email protected]>
Release succeeded for the The following packages have been published:
Powered by Octorelease 🚀 |
What It Does
Resolves an issue where team config base profiles were being overwritten if a user config did not have a base profile.
How to Test
See attached issue for details.
Example Config Files:
zowe.config.user.json:
zowe.config.json:
Review Checklist
I certify that I have:
Additional Comments