Skip to content

Commit

Permalink
[v12] Tag output from teleport configure as ERROR or WARNING if appli…
Browse files Browse the repository at this point in the history
…es (#24676)

* Tag output from `teleport configure` as ERROR or WARNING if applies

* use utils.Color to set warnings and error colors
  • Loading branch information
stevenGravy committed Apr 17, 2023
1 parent 6276858 commit 7a5bdeb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tool/teleport/common/teleport.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,32 +957,32 @@ func onConfigDump(flags dumpFlags) error {
entries, err := os.ReadDir(flags.DataDir)
if err != nil && !os.IsNotExist(err) {
fmt.Fprintf(
os.Stderr, "Could not check the contents of %s: %s\nThe data directory may contain existing cluster state.\n", flags.DataDir, err.Error())
os.Stderr, "%s Could not check the contents of %s: %s\n The data directory may contain existing cluster state.\n", utils.Color(utils.Yellow, "WARNING:"), flags.DataDir, err.Error())
}

if err == nil && len(entries) != 0 {
fmt.Fprintf(
os.Stderr,
"The data directory %s is not empty and may contain existing cluster state. Running this configuration is likely a mistake. To join a new cluster, specify an alternate --data-dir or clear the %s directory.\n",
flags.DataDir, flags.DataDir)
"%s The data directory %s is not empty and may contain existing cluster state. Running this configuration is likely a mistake. To join a new cluster, specify an alternate --data-dir or clear the %s directory.\n",
utils.Color(utils.Yellow, "WARNING:"), flags.DataDir, flags.DataDir)
}

if strings.Contains(flags.Roles, defaults.RoleDatabase) {
fmt.Fprintln(os.Stderr, "Role db requires further configuration, db_service will be disabled")
fmt.Fprintf(os.Stderr, "%s Role db requires further configuration, db_service will be disabled. Use 'teleport db configure' command to create Teleport database service configurations.\n", utils.Color(utils.Red, "ERROR:"))
}

if strings.Contains(flags.Roles, defaults.RoleWindowsDesktop) {
fmt.Fprintln(os.Stderr, "Role windowsdesktop requires further configuration, windows_desktop_service will be disabled")
fmt.Fprintf(os.Stderr, "%s Role windowsdesktop requires further configuration, windows_desktop_service will be disabled. See https://goteleport.com/docs/desktop-access/ for configuration information.\n", utils.Color(utils.Red, "ERROR:"))
}

if configPath != "" {
canWriteToDataDir, err := utils.CanUserWriteTo(flags.DataDir)
if err != nil && !trace.IsNotImplemented(err) {
fmt.Fprintf(os.Stderr, "Failed to check data dir permissions: %+v", err)
fmt.Fprintf(os.Stderr, "%s Failed to check data dir permissions: %+v\n", utils.Color(utils.Yellow, "WARNING:"), err)
}
canWriteToConfDir, err := utils.CanUserWriteTo(filepath.Dir(configPath))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to check config dir permissions: %+v", err)
fmt.Fprintf(os.Stderr, "%s Failed to check config dir permissions: %+v\n", utils.Color(utils.Yellow, "WARNING:"), err)
}
requiresRoot := !canWriteToDataDir || !canWriteToConfDir

Expand Down

0 comments on commit 7a5bdeb

Please sign in to comment.