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

Implement client side configuration #26

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.ssh/
# deploy/
id_ed25*
id_ed25519*
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ I spend an awful amount of time in the terminal and it makes sense i should
be able to spin up and use a request bin on my terminal. Hence this
project sdump


### How to use public hosted version

```sh
Expand All @@ -32,7 +31,7 @@ ssh -p 2222 ssh.sdump.app
- `sdump http`: starts the HTTP server.
- `sdump ssh`: starts the SSH server
- `sdump delete-http`: deletes/prunes old ingested requests. This can be a form
of a cron job that runs every few days or so
of a cron job that runs every few days or so

### Configuration file

Expand All @@ -57,12 +56,12 @@ ssh:
## port to run ssh server on
port: 2222
## allow_list is a list of public keys that can connect to the ssh server
# this is useful if you were running a private instance for a few coworkers
# this is useful if you were running a private instance for a few coworkers
# or friends
allow_list:
- ./.ssh/id_rsa.pub
- /Users/lanreadelowo/.ssh/id_rsa.pub

## keys for the ssh server
identities:
- "id_ed25519"
Expand All @@ -80,8 +79,8 @@ http:
database:
## database dsn
dsn: postgres://sdump:sdump@localhost:3432/sdump?sslmode=disable
## should we log sql queries? In prod, no but in local mode,
## you probably want to
## should we log sql queries? In prod, no but in local mode,
## you probably want to
log_queries: true

# limit the size of jSON request body that can be sent to endpoints
Expand All @@ -93,7 +92,7 @@ http:
use_tls: true
## custom name you want to use to identify the service
service_name: SDUMP
## OTEL Endpoint
## OTEL Endpoint
endpoint: http://localhost:4200
## Should we trace all http and DB requests
is_enabled: false
Expand Down
1 change: 1 addition & 0 deletions cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func teaHandler(cfg *config.Config) func(s ssh.Session) (tea.Model, []tea.Progra
tui.WithWidth(pty.Window.Width),
tui.WithHeight(pty.Window.Height),
tui.WithSSHFingerPrint(sshFingerPrint),
tui.WithColorscheme(cfg.TUI.ColorScheme),
)
if err != nil {
wish.Fatalln(s, fmt.Errorf("%v...Could not set up TUI session", err))
Expand Down
12 changes: 7 additions & 5 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cron:
tui:
## the color_scheme to use for the request body
# see https://github.com/alecthomas/chroma/tree/master/styles
color_scheme: monokai
color_scheme: catppuccin-mocha

ssh:
## port to run ssh server on
Expand All @@ -35,14 +35,16 @@ http:
## limit the number of ingested requests from a specific client
requests_per_minute: 10

## database configuration. postgres essentially
## database configuration.
database:
## database dsn
dsn: postgres://sdump:sdump@localhost:3432/sdump?sslmode=disable
# dsn: "file::memory:?cache=shared"
# driver: "sqlite"

dsn: postgres://sdump:sdump@localhost:3432/sdump?sslmode=disable
driver: "postgres"

## should we log sql queries? In prod, no but in local mode, you probably want to
log_queries: true
# driver: "sqlite"

# limit the size of jSON request body that can be sent to endpoints
max_request_body_size: 500
Expand Down
8 changes: 5 additions & 3 deletions internal/tui/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type model struct {

requestList list.Model
httpClient *http.Client
colorscheme string

sseClient *sse.Client
receiveChan chan item
Expand Down Expand Up @@ -87,9 +88,10 @@ func newModel(cfg *config.Config, width, height int) model {
}

m := model{
width: width,
height: height,
title: "Sdump",
colorscheme: cfg.TUI.ColorScheme,
width: width,
height: height,
title: "Sdump",
spinner: spinner.New(
spinner.WithSpinner(spinner.Line),
spinner.WithStyle(lipgloss.NewStyle().Foreground(lipgloss.Color("205"))),
Expand Down
10 changes: 9 additions & 1 deletion internal/tui/option.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package tui

import "github.com/adelowo/sdump/config"
import (
"github.com/adelowo/sdump/config"
)

type Option func(*model)

func WithColorscheme(colorscheme string) Option {
return func(m *model) {
m.colorscheme = colorscheme
}
}

func WithConfig(cfg *config.Config) Option {
return func(m *model) {
m.cfg = cfg
Expand Down
Loading