Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Insecure option is not available in interactive mode (812) (#219)
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Chong <[email protected]>
  • Loading branch information
keithchong authored Apr 8, 2021
1 parent 2a53bd1 commit f440ca7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ func initiateInteractiveMode(io *BootstrapParameters, client *utility.Client, cm
promptForAll := !ui.UseDefaultValues()
// ask for sealed secrets only when default is absent, and consider insecure/secure cases
err := client.CheckIfSealedSecretsExists(defaultSealedSecretsServiceName)
if !cmd.Flag("insecure").Changed && promptForAll {
io.Insecure = ui.SelectInsecureSecrets(err)
}
if !io.Insecure && err != nil {
io.SealedSecretsService.Namespace = ui.EnterSealedSecretService(&io.SealedSecretsService)
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/cmd/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ func EnterSealedSecretService(sealedSecretService *types.NamespacedName) string
return strings.TrimSpace(sealedNs)
}

// SelectInsecureSecrets, prompts the UI to ask to generate unsealed secrets or not
func SelectInsecureSecrets(err error) bool {
var insecure, msg string
if err != nil {
msg = "Do you want to use 1) unsealed secrets or 2) sealed secrets and provide the details of the Sealed Secrets Operator installation?"
} else {
msg = "You are able to seal secrets. Select Sealed to continue or Unsealed to generate unsealed secrets, which is not recommended."
}
prompt := &survey.Select{
Message: msg,
Help: "WARNING: Deploying the GitOps configuration without encrypting secrets is insecure and is not recommended",
Options: []string{"Sealed", "Unsealed"},
Default: "Sealed",
}
handleError(survey.AskOne(prompt, &insecure, survey.Required))
return insecure == "Unsealed"
}

// EnterGitHostAccessToken , it becomes necessary to add the personal access
// token to access upstream git hosts.
func EnterGitHostAccessToken(serviceRepo string) string {
Expand Down

0 comments on commit f440ca7

Please sign in to comment.