Skip to content

Commit c9830de

Browse files
authored
chore: Update CLI prompt to run command as root (#1517)
1 parent ca5ff88 commit c9830de

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

cmd/troubleshoot/cli/run.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,8 @@ func runTroubleshoot(v *viper.Viper, args []string) error {
113113

114114
if interactive {
115115
if len(mainBundle.Spec.HostCollectors) > 0 && !util.IsRunningAsRoot() {
116-
msg := "Some host collectors may require elevated privileges to run.\nDo you want to exit and rerun the command as a privileged user?"
117116
fmt.Print(cursor.Show())
118-
if util.PromptYesNo(msg) {
117+
if util.PromptYesNo(util.HOST_COLLECTORS_RUN_AS_ROOT_PROMPT) {
119118
fmt.Println("Exiting...")
120119
return nil
121120
}

internal/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"golang.org/x/text/language"
1515
)
1616

17+
const HOST_COLLECTORS_RUN_AS_ROOT_PROMPT = "Some host collectors need to be run as root.\nDo you want to exit and rerun the command using sudo?"
18+
1719
func HomeDir() string {
1820
if h := os.Getenv("HOME"); h != "" {
1921
return h

pkg/preflight/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func RunPreflights(interactive bool, output string, format string, args []string
5050
if interactive {
5151
if len(specs.HostPreflightsV1Beta2) > 0 && !util.IsRunningAsRoot() {
5252
fmt.Print(cursor.Show())
53-
if util.PromptYesNo("Some host collectors may require elevated privileges to run.\nDo you want to exit and rerun the command as a privileged user?") {
53+
if util.PromptYesNo(util.HOST_COLLECTORS_RUN_AS_ROOT_PROMPT) {
5454
fmt.Println("Exiting...")
5555
return nil
5656
}

0 commit comments

Comments
 (0)