Skip to content

Commit

Permalink
Address review comments and bugs.
Browse files Browse the repository at this point in the history
- delete roles, rolebindings, service accounts by label
- use hack for setting namespace for helm kube client
- fallback to release name/namespace consul
  • Loading branch information
ndhanushkodi committed Sep 22, 2021
1 parent a8a0cf5 commit eb31fec
Show file tree
Hide file tree
Showing 5 changed files with 245 additions and 74 deletions.
11 changes: 6 additions & 5 deletions cli/cmd/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package common

import "strings"

func PrefixLines(prefix, lines string) string {
var prefixedLines string
for _, l := range strings.Split(lines, "\n") {
prefixedLines += prefix + l + "\n"
// Abort returns true if the raw input string is not equal to "y" or "yes".
func Abort(raw string) bool {
confirmation := strings.TrimSuffix(raw, "\n")
if !(strings.ToLower(confirmation) == "y" || strings.ToLower(confirmation) == "yes") {
return true
}
return strings.TrimSuffix(prefixedLines, "\n")
return false
}
12 changes: 6 additions & 6 deletions cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,16 @@ func (c *Command) init() {
func (c *Command) Run(args []string) int {
c.once.Do(c.init)

// The logger is initialized in main with the name cli. Here, we reset the name to install so log lines would be prefixed with install.
c.Log.ResetNamed("install")

defer func() {
if err := c.Close(); err != nil {
c.UI.Output(err.Error())
c.Log.Error(err.Error())
os.Exit(1)
}
}()

// The logger is initialized in main with the name cli. Here, we reset the name to install so log lines would be prefixed with install.
c.Log.ResetNamed("install")

if err := c.validateFlags(args); err != nil {
c.UI.Output(err.Error())
return 1
Expand Down Expand Up @@ -290,8 +291,7 @@ func (c *Command) Run(args []string) int {
c.UI.Output(err.Error(), terminal.WithErrorStyle())
return 1
}
confirmation = strings.TrimSuffix(confirmation, "\n")
if !(strings.ToLower(confirmation) == "y" || strings.ToLower(confirmation) == "yes") {
if common.Abort(confirmation) {
c.UI.Output("Install aborted. To learn how to customize your installation, run:\nconsul-k8s install --help", terminal.WithInfoStyle())
return 1
}
Expand Down
Loading

0 comments on commit eb31fec

Please sign in to comment.