Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12] Tag output from teleport configure as ERROR or WARNING if applies #24676

Merged
merged 2 commits into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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