Skip to content

Commit

Permalink
chore: type env name in strict type operations (#183)
Browse files Browse the repository at this point in the history
Signed-off-by: Akshay Patidar <[email protected]>
  • Loading branch information
akshaypatidar1999 authored Mar 18, 2023
1 parent 786c1cb commit afeec36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions internal/command/commands/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ func (c *Component) Run(args []string) int {
return 1
}
if envTypeResp.Strict {
consentMessage := "\nYou are executing the above command on production environment. Are you sure? Enter Y/n: "
allowedInputs := map[string]struct{}{"Y": {}, "n": {}}
val, err := c.Input.AskWithConstraints(consentMessage, allowedInputs)
consentMessage := fmt.Sprintf("\nYou are executing the above command on a restricted environment. Are you sure? Enter \033[1m%s\033[0m to continue:", *envName)
val, err := c.Input.Ask(consentMessage)

if err != nil {
c.Logger.Error(err.Error())
return 1
}

if val != "Y" {
if val != *envName {
c.Logger.Info("Aborting the operation")
return 1
}
Expand Down
7 changes: 3 additions & 4 deletions internal/command/commands/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,15 @@ func (s *Service) askForConsent(envName *string) int {
return 1
}
if envTypeResp.Strict {
consentMessage := "\nYou are executing the above command on production environment. Are you sure? Enter Y/n:"
allowedInputs := map[string]struct{}{"Y": {}, "n": {}}
val, err := s.Input.AskWithConstraints(consentMessage, allowedInputs)
consentMessage := fmt.Sprintf("\nYou are executing the above command on a restricted environment. Are you sure? Enter \033[1m%s\033[0m to continue:", *envName)
val, err := s.Input.Ask(consentMessage)

if err != nil {
s.Logger.Error(err.Error())
return 1
}

if val != "Y" {
if val != *envName {
s.Logger.Info("Aborting the operation")
return 1
}
Expand Down

0 comments on commit afeec36

Please sign in to comment.