-
Notifications
You must be signed in to change notification settings - Fork 31
add configmgr api copyConfigurationAndDeleteKey
#524
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
add configmgr api copyConfigurationAndDeleteKey
#524
Conversation
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
|
Is this meant to be a persistent change in yaml? Or is this only an in-memory change for the program that has integrated configmgr? |
|
This is an in-memory change only; the caller is responsible for persisting changes to disk. I followed the structure of These lines in the zowe-install-packaging PR shows the call pattern: https://github.com/zowe/zowe-install-packaging/blob/5726c3792404e72ead99468fe37621348d408e7d/bin/libs/configmgr.ts#L425-L429 , where |
|
There really are no "destructive" operations in configmgr to prevent bugs where one consumer/user of the data is not in sync with another. Can we re-conceive this as making a copy of the config under a new name with the following edits applied. |
|
You may find https://github.com/zowe/zowe-install-packaging/blob/v3.x/staging/bin/commands/internal/config/get/index.ts |
|
@JoeNemo This does currently create a copy of the configuration before taking destructive actions; a user always needs to call the API with the next revision name. I'll join the squad call next week to answer other questions that may come up |
…rrays indexed by square brackets Signed-off-by: MarkAckert <[email protected]>
deleteFromConfigurationcopyConfigurationAndDeleteKey
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: MarkAckert <[email protected]>
Signed-off-by: Martin Zeithaml <[email protected]>
|
As review and discussion has been complete and marked approved, I'm going to merge this. |
Proposed changes
Note: Ready for review.
This PR adds a new
copyConfigurationAndDeleteKeyAPI to configmgr which can be used to delete keys from a YAML document. e.g., deletingzowe.setuporzowe.setup.datasetis now possible. ThecopyConfigurationAndDeleteKeyAPI requires that a new configuration name be supplied, so the mutation happens in a new copy of the configuration (matching other update APIs). This is required as part of the Node.JS removal from zwe scripts, and is last step to fully replace theconfig-convertercomponent we use from zowe-install-packaging-tools.The existing modification APIs were not used after experimentation, as the modification / overlay is a union style merge operation rather than a replacement. While that could've been enhanced to support deleting keys, it felt better to have a clean line of separation between the 2 behaviors.
Limitations in regex made parsing of keys containing multiple periods less readable than I wanted, so the code has additional comments in the parsing section.
This PR addresses Issue: Part of zowe/zowe-install-packaging#4307
Type of change
Please delete options that are not relevant.
PR Checklist
Please delete options that are not relevant.
Testing
Added unit tests in
tests/js/config1.js.Further comments
Supports:
zowe.externalHostsandzowe.externalHosts[0]are supported (and yield different outputs).zowe.[_zsf.logging.level]. Works for arrays too:zowe.[_demo.key[0]].[another.key]Notes:
Running
delete "zowe.a"gives:This is legal YAML, but might be confusing if a user comes across it? I don't know how to change the render behavior.
[in position one will not parse as keys, but instead as a key containing periods, which means they will not match and the resulting output will be a no-op. I think this is an acceptable limitation until we have a use case which needs[in position one. This might be worked around by:[[key], but is not tested.