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

Initialize additional properties for the ConvertV1Profiles.convert function #2182

Merged
merged 17 commits into from
Jul 5, 2024

Conversation

gejohnston
Copy link
Member

@gejohnston gejohnston commented Jun 20, 2024

What It Does

Initialize additional properties within the ConvertV1Profiles class to enable Zowe Explorer (or other VSCode extensions) to successfully call the ConvertV1Profiles.convert function.

This PR is intended to address the issue #2170

  • Added a new property to the options of the convert function. The 'profileInfo' property contains a ProfileInfo object that a VSCode extension must pass to the convert function.
  • Added the function initCredMgr to initialize the CredMgr for either CLI or VSCode extensions.
  • Corrected the function isZoweKeyRingAvailable to properly initialize the keyring for Zowe Explorer.
  • Added the function loadV1Schemas which reads in the schema information from the V1 profiles.
    • ZE initialization does not otherwise populate that information.
  • Replaced the call to PluginIssues.instance.getInstalledPlugins with the new function isPluginInstalled.
    • PluginIssues.instance.getInstalledPlugins required data that is not available in VSCode extensions.
  • Ensured that we replace the old V1 SCS plugin CredMgr with the current embedded SCS CredMgr, before attempting to load a credential manager.
    • Write an error message to the log when CredMgr is already initialized with the old SCS plugin.
  • Included doc in the signature of the ConvertV1Profiles.convert function to inform callers that they should NOT initialize the credential manager before calling the convert function.
  • Replaced the irrelevant 'reInitCredMgr' property in the IConvertV1ProfResult object with a new 'credsWereMigrated' property to indicate whether or not credentials were successfully migrated within the OS vault.
  • Consolidated the reporting of exceptions that are caught. Included a stack trace within such reported messages.
  • Improved the text of reported message and altered some formatting choices.
  • Only uninstall the old SCS plugin from the CLI. Otherwise, provide a message that the user must uninstall the old SCS plugin with a CLI command.

How to Test

Perform the conversion the same way as before (in CLI or ZE). Observe a successful conversion.

A sample of the output of the CLI command follows:

zowe config convert-profiles --delete
[2024/06/20 12:06:44.400] [WARN] [PluginManagementFacility.js:262] Your configured 'CredentialManager' setting specified a plugin named '@zowe/secure-credential-store-for-zowe-cli' that is not a known credential manager. You should only use this plugin for testing until it is added to zowe's list of known credential managers. If that plugin does not implement a credential manager override class, the built-in zowe credential manager will be used.
If you confirm the deletion of V1 profiles, they are deleted from disk after
a successful conversion. Otherwise, they remain but are no longer used.
You can also delete your V1 profiles later.

Do you want to delete your V1 profiles now [y/N]: y

Converted base profiles: base
Converted cics profiles: cics123
Converted endevor profiles: ndvrSample
Converted jclcheck profiles: jcl123
Converted tso profiles: tso_prof
Converted zosmf profiles: ca32, de20

Your new profiles have been saved to C:\Users\ej608771\.zowe\zowe.config.json. To change your configuration, update that file in your text editor.

Deleted the old profiles directory C:\Users\ej608771\.zowe\profiles-old.

Deleted obsolete secure value Zowe-Plugin/endevor_ndvrSample_user.
Deleted obsolete secure value Zowe-Plugin/base_base_user.
Deleted obsolete secure value Zowe-Plugin/jclcheck_jcl123_user.
Deleted obsolete secure value Zowe-Plugin/cics_cics123_user.
Deleted obsolete secure value Zowe-Plugin/cics_cics123_password.
Deleted obsolete secure value Zowe-Plugin/endevor_ndvrSample_password.
Deleted obsolete secure value Zowe-Plugin/jclcheck_jcl123_password.
Deleted obsolete secure value Zowe-Plugin/base_base_password.

The obsolete plug-in @zowe/secure-credential-store-for-zowe-cli will be uninstalled because the SCS is now embedded within the Zowe clients.

Successfully uninstalled plug-in @zowe/secure-credential-store-for-zowe-cli.

A sample of the result object of the ConvertV1Profiles.convert function (which would be seen by a VSCode extension) follows:

convertResult:
 {
  "msgs": [
    {
      "msgFormat": 1,
      "msgText": "Converted base profiles: base"
    },
    {
      "msgFormat": 1,
      "msgText": "Converted cics profiles: cics123"
    },
    {
      "msgFormat": 1,
      "msgText": "Converted endevor profiles: ndvrSample"
    },
    {
      "msgFormat": 1,
      "msgText": "Converted jclcheck profiles: jcl123"
    },
    {
      "msgFormat": 1,
      "msgText": "Converted tso profiles: tso_prof"
    },
    {
      "msgFormat": 1,
      "msgText": "Converted zosmf profiles: ca32, de20"
    },
    {
      "msgFormat": 5,
      "msgText": "Your new profiles have been saved to C:\\Users\\ej608771\\.zowe\\zowe.config.json. To change your configuration, update that file in your text editor."
    },
    {
      "msgFormat": 5,
      "msgText": "Deleted the old profiles directory C:\\Users\\ej608771\\.zowe\\profiles-old."
    },
    {
      "msgFormat": 5,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/endevor_ndvrSample_user."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/base_base_user."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/jclcheck_jcl123_user."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/cics_cics123_user."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/cics_cics123_password."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/endevor_ndvrSample_password."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/jclcheck_jcl123_password."
    },
    {
      "msgFormat": 1,
      "msgText": "Deleted obsolete secure value Zowe-Plugin/base_base_password."
    },
    {
      "msgFormat": 5,
      "msgText": "The obsolete plug-in @zowe/secure-credential-store-for-zowe-cli should be uninstalled because the SCS is now embedded within the Zowe clients. Zowe CLI plugins can only be uninstalled by the CLI. Use the command 'zowe plugins uninstall @zowe/secure-credential-store-for-zowe-cli'."
    }
  ],
  "v1ScsPluginName": "@zowe/secure-credential-store-for-zowe-cli",
  "credsWereMigrated": true,
  "cfgFilePathNm": "C:\\Users\\ej608771\\.zowe\\zowe.config.json",
  "numProfilesFound": 7,
  "profilesConverted": {
    "base": [
      "base"
    ],
    "cics": [
      "cics123"
    ],
    "endevor": [
      "ndvrSample"
    ],
    "jclcheck": [
      "jcl123"
    ],
    "tso": [
      "tso_prof"
    ],
    "zosmf": [
      "ca32",
      "de20"
    ]
  },
  "profilesFailed": []
}

Review Checklist
I certify that I have:

  • tested my changes with a ZE simulation
  • tested my changes with the real ZE
  • added/updated automated tests
  • updated the changelog
  • followed the contribution guidelines

Additional Comments

Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
…o support Zowe Explorer

Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 99.16667% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.22%. Comparing base (f64452c) to head (7df9fce).
Report is 2 commits behind head on next.

Files Patch % Lines
...ges/imperative/src/config/src/ConvertV1Profiles.ts 99.16% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2182      +/-   ##
==========================================
+ Coverage   91.19%   91.22%   +0.03%     
==========================================
  Files         629      629              
  Lines       17913    17964      +51     
  Branches     3817     3831      +14     
==========================================
+ Hits        16335    16387      +52     
+ Misses       1577     1576       -1     
  Partials        1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <eugene.johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
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.

These changes make sense to me, thanks @gejohnston! LGTM

@gejohnston
Copy link
Member Author

FYI for reviewers: I left the following comment on the SonarCloud complaint.

July 1, 2024 at 2:55 PM
Gene Johnston
Added a comment
This statement exists to catch an error when the item is not initialized. Assigning the statement to a variable will just give rise to an unused variable complaint.

July 1, 2024 at 2:51 PM
Gene Johnston
Status changed to CONFIRMED (was OPEN)

Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Signed-off-by: Gene Johnston <Eugene.Johnston@broadcom.com>
Copy link
Contributor

@anaxceron anaxceron left a comment

Choose a reason for hiding this comment

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

Looks good, @gejohnston, thank you!

Signed-off-by: Gene Johnston <eugene.johnston@broadcom.com>
Copy link

sonarcloud bot commented Jul 3, 2024

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 @gejohnston!

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.

LGTM! 😋
sorry for the delay 😅

@zFernand0 zFernand0 merged commit 90dc883 into next Jul 5, 2024
46 checks passed
@zFernand0 zFernand0 deleted the v1-convert-for-ze branch July 5, 2024 14:30
Copy link

github-actions bot commented Jul 5, 2024

Release succeeded for the next branch. 🎉

The following packages have been published:

  • npm: @zowe/secrets-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/imperative@8.0.0-next.202407051717
  • npm: @zowe/cli-test-utils@8.0.0-next.202407051717
  • npm: @zowe/core-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-uss-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/provisioning-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-console-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-files-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-logs-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zosmf-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-workflows-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-jobs-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/zos-tso-for-zowe-sdk@8.0.0-next.202407051717
  • npm: @zowe/cli@8.0.0-next.202407051717

Powered by Octorelease 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues seen with ConvertV1Profiles.convert() when trying to adopt
6 participants