diff --git a/cmd/kanvas-snapshot/main.go b/cmd/kanvas-snapshot/main.go index 9fe592ce48..5c72ec80ad 100644 --- a/cmd/kanvas-snapshot/main.go +++ b/cmd/kanvas-snapshot/main.go @@ -57,7 +57,9 @@ var generateKanvasSnapshotCmd = &cobra.Command{ designName = ExtractNameFromURI(chartURI) Log.Warnf("No design name provided. Using extracted name: %s", designName) } - + if email != "" && !isValidEmail(email) { + handleError(errors.ErrInvalidEmailFormat(email)) + } // Create Meshery Snapshot designID, err := CreateMesheryDesign(chartURI, designName, email) if err != nil { diff --git a/internal/errors/error.go b/internal/errors/error.go index bd0cfd93e3..19cbba28bb 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -71,6 +71,15 @@ func ErrUnexpectedResponseCode(statusCode int, body string) error { ) } +func ErrRequiredFieldNotProvided(err error, field string) error { + return errors.New(ErrRequiredFieldNotProvidedCode, errors.Alert, + []string{"All required flags are not passed."}, + []string{err.Error()}, + []string{"Required flag \"%s\" is not passed."}, + []string{"Ensure value for flag \"%s\" is correctly provided."}, + ) +} + func ErrInvalidEmailFormat(email string) error { return errors.New(ErrInvalidEmailFormatCode, errors.Alert, []string{"Invalid email format provided."},