How to correctly remove properties from a Zowe config file #1561
-
Hello, In our current zowe implementation, we have several PowerShell scripts that are calling Zowe CLI command under water. These powershell scripts need to be executed from a specific folder, say For the current implementation, we use the username and password for authentication to the APIML. Besides our current PowerShell based implementation, we're developing a new VSCode extension. This extension is also built on top of the Zowe CLI package. The extension has the following requirements among others:
Import the previously used zowe.config.json
As you can see, the profile currently has the secure properties In the above example, the Remove/logout from APIML on user request We have the following logic to logout the user: if (token === '') {
throw new GenericError('Unable to retrieve token for logout. Probably it has already been deleted', MessageLocation.CORE);
}
// Create update session
const updSession = new zowe.imperative.Session({
hostname: MAINFRAME_HOSTNAME,
port: MAINFRAME_PORT,
rejectUnauthorized: MAINFRAME_REJECT_UNAUTHORIZED,
tokenType: MAINFRAME_TOKEN_TYPE,
type: zowe.imperative.SessConstants.AUTH_TYPE_TOKEN,
tokenValue: token
});
await zowe.Logout.apimlLogout(updSession);
// Update tokenValue property
await this.profileInfo.updateKnownProperty({ mergedArgs, property: 'tokenValue', value: '', setSecure: this.profileInfo.isSecured() });
await this.profileInfo.updateKnownProperty({ mergedArgs, property: 'tokenType', value: ''}); Here, the question is also how to correctly remove the
Which makes sense based on the type declaration for IProfArgValue: export declare type IProfArgValue = string | number | boolean | string[] | object; What I'm looking for is some direction on how to properly remove properties from the config file. As mentioned earlier, we can read the config json file in into the extension, remove the properties, and write it back to file. I'm not sure what is left behind, for example in the credential store... In my opinion, it would be nice to have a method like await this.profileInfo.removeKnownProperty({mergedArgs, property: 'tokenValue'}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Could you please try replacing the await this.profileInfo.updateKnownProperty({ mergedArgs, property: 'tokenValue', value: undefined as any, setSecure: false });
await this.profileInfo.updateKnownProperty({ mergedArgs, property: 'tokenType', value: undefined as any }); Two things to note here:
|
Beta Was this translation helpful? Give feedback.
Could you please try replacing the
updateKnownProperty
calls with the following?Two things to note here:
undefined as any
should work to remove the property but of course theas any
is not ideal. We should probably either update the type declaration ofIProfArgValue
to includeundefined
, or perhaps add aremoveKnownProperty
method as you suggested 🙂setSecure
property must be set to false in order to remove an item from the "secure" array in the co…