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

Add validators functionality to prompts #61

Merged

Conversation

mpanchajanya
Copy link
Contributor

@mpanchajanya mpanchajanya commented Apr 25, 2023

What this PR does / why we need it

  • Enable validations on prompts
  • Implemented WithValidator() to set validator functions
  • Added couple of custom validators NoUpperCase(), NoOnlySpaces()

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

  • Added unit test to verify the changes including built in validators and custom validators
  • Verified importing the tzr changes into tzc locally and tested tanzu context and tanzu login command with new validators required and NoOnlySpaces

Below testing show Required and no only spaces validators in action

mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix-do-not-allow-empty-context-names)> tanzu context create
? Select context creation type Control plane endpoint
X Sorry, your reply was invalid: value contains only spaces
? Enter control plane endpoint test
X Sorry, your reply was invalid: value contains only spaces
? Give the context a name test
[i] Failed to test for vSphere supervisor: Get "test/wcp/loginbanner": unsupported protocol scheme ""
[x] : error creating kubeconfig with tanzu pinniped-auth login plugin: Get "test/wcp/loginbanner": unsupported protocol scheme ""
[x] : error creating kubeconfig with tanzu pinniped-auth login plugin: Get "test/wcp/loginbanner": unsupported protocol scheme ""
mpanchajanya@mpanchajanF09MK ~/v/r/tanzu-cli (bug-fix-do-not-allow-empty-context-names) [1]> tanzu context create
? Select context creation type Local kubeconfig
X Sorry, your reply was invalid: Value is required
? Enter path to kubeconfig (if any) test
X Sorry, your reply was invalid: Value is required
? Enter kube context to use test
X Sorry, your reply was invalid: Value is required
? Give the context a name test


Release note

prompt config accepts Validator functions to be performed on prompt answers

Additional information

Special notes for your reviewer

@mpanchajanya mpanchajanya force-pushed the add_validators_to_prompt branch 4 times, most recently from e74d709 to 7f615c6 Compare April 27, 2023 03:51
@mpanchajanya mpanchajanya marked this pull request as ready for review April 28, 2023 14:10
@mpanchajanya mpanchajanya requested a review from a team as a code owner April 28, 2023 14:10
Copy link
Contributor

@anujc25 anujc25 left a comment

Choose a reason for hiding this comment

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

LGTM

@mpanchajanya mpanchajanya merged commit 7b3fa01 into vmware-tanzu:main May 4, 2023
4 checks passed
vuil pushed a commit that referenced this pull request May 16, 2023
@marckhouzam marckhouzam added this to the v0.90.0 milestone Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants