-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Most of the functionality was untouched, there were only few deviations to the original styling and alignment of components. The most notable changes are as follows: - The backend and cache tables no longer have a range column, range requests are now indicated by a preceding ®. - The watcher graphs are rendered with a different library and no longer have a confusing x axis - The colors do not match the original version - The cluster stats page includes the role count - Errors retrieving metrics no longer exits the process. The footer is updated to display errors and requires manual intervention to exit. If errors are intermittent future successful reports will restore functionality.
- Loading branch information
1 parent
650279d
commit 45ce29d
Showing
8 changed files
with
911 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Teleport | ||
// Copyright (C) 2025 Gravitational, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package top | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/charmbracelet/lipgloss" | ||
) | ||
|
||
// boxedView wraps the provided content in a rounded border, | ||
// with the title embedded in the top. For example, if the | ||
// content was \t\t\tHello and the title was Some Heading the | ||
// returned content would be: | ||
// | ||
// ╭Some Heading────────╮ | ||
// │ │ | ||
// │ Hello │ | ||
// ╰────────────────────╯ | ||
func boxedView(title string, content string, width int) string { | ||
rounderBorder := lipgloss.RoundedBorder() | ||
|
||
const borderCorners = 2 | ||
width = width - borderCorners | ||
availableSpace := width - lipgloss.Width(title) | ||
|
||
var filler string | ||
if availableSpace > 0 { | ||
filler = strings.Repeat(rounderBorder.Top, availableSpace) | ||
} | ||
|
||
titleContent := lipgloss.NewStyle(). | ||
Foreground(selectedColor). | ||
Render(title) | ||
|
||
renderedTitle := rounderBorder.TopLeft + titleContent + filler + rounderBorder.TopRight | ||
|
||
// empty out the top border since it | ||
// is already manually applied to the title. | ||
rounderBorder.TopLeft = "" | ||
rounderBorder.Top = "" | ||
rounderBorder.TopRight = "" | ||
|
||
contentStyle := lipgloss.NewStyle(). | ||
BorderStyle(rounderBorder). | ||
PaddingLeft(1). | ||
PaddingRight(1). | ||
Faint(true). | ||
Width(width) | ||
|
||
return renderedTitle + contentStyle.Render(content) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Teleport | ||
// Copyright (C) 2025 Gravitational, Inc. | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package top | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/alecthomas/kingpin/v2" | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/gravitational/roundtrip" | ||
"github.com/gravitational/trace" | ||
|
||
"github.com/gravitational/teleport/lib/service/servicecfg" | ||
commonclient "github.com/gravitational/teleport/tool/tctl/common/client" | ||
tctlcfg "github.com/gravitational/teleport/tool/tctl/common/config" | ||
) | ||
|
||
// Command is a debug command that consumes the | ||
// Teleport /metrics endpoint and displays diagnostic | ||
// information an easy to consume way. | ||
type Command struct { | ||
config *servicecfg.Config | ||
top *kingpin.CmdClause | ||
diagURL string | ||
refreshPeriod time.Duration | ||
} | ||
|
||
// Initialize sets up the "tctl top" command. | ||
func (c *Command) Initialize(app *kingpin.Application, _ *tctlcfg.GlobalCLIFlags, config *servicecfg.Config) { | ||
c.config = config | ||
c.top = app.Command("top", "Report diagnostic information.") | ||
c.top.Arg("diag-addr", "Diagnostic HTTP URL").Default("http://127.0.0.1:3000").StringVar(&c.diagURL) | ||
c.top.Arg("refresh", "Refresh period").Default("5s").DurationVar(&c.refreshPeriod) | ||
} | ||
|
||
// TryRun attempts to run subcommands. | ||
func (c *Command) TryRun(ctx context.Context, cmd string, _ commonclient.InitFunc) (match bool, err error) { | ||
if cmd != c.top.FullCommand() { | ||
return false, nil | ||
} | ||
|
||
diagClient, err := roundtrip.NewClient(c.diagURL, "") | ||
if err != nil { | ||
return true, trace.Wrap(err) | ||
} | ||
|
||
p := tea.NewProgram( | ||
newTopModel(c.refreshPeriod, diagClient), | ||
tea.WithAltScreen(), | ||
tea.WithContext(ctx), | ||
) | ||
|
||
_, err = p.Run() | ||
return true, trace.Wrap(err) | ||
} |
Oops, something went wrong.