Skip to content
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
go-version: ${{ matrix.go-version }}
check-latest: true

- name: Generate mocks
run: make generate-mocks

- name: Run golangci-lint (latest)
uses: golangci/golangci-lint-action@v6
with:
Expand All @@ -46,6 +49,9 @@ jobs:
check-latest: true
cache: true

- name: Generate mocks
run: make generate-mocks

- name: Verify dependencies
run: go mod tidy && git diff --exit-code go.mod go.sum

Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea/
NOTES.md
NOTES.md
mocks/
*.log
berth
11 changes: 11 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
template: testify

packages:
github.com/docker/docker/client:
config:
dir: ./mocks/client
filename: "APIClient.go"
pkgname: "client"
structname: "Mock{{.InterfaceName}}"
interfaces:
APIClient:
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ run:
@echo "Running $(APP_NAME)..."
$(GO) run $(APP_PATH)

generate-mocks:
go install github.com/vektra/mockery/v3@latest
export MOCKERY_IN_PACKAGE=true
mockery --config .mockery.yaml

clean:
@echo "Cleaning up..."
$(GO) clean
rm -f $(APP_NAME)
@echo "Cleanup complete."

test:
test: generate-mocks
@echo "Running tests..."
$(GO) test ./...

Expand Down
41 changes: 38 additions & 3 deletions cmd/berth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main

import (
"fmt"
"log/slog"
"os"

tea "github.com/charmbracelet/bubbletea"
Expand All @@ -11,9 +12,43 @@ import (

// main function initializes and runs the Bubble Tea program.
func main() {
p := tea.NewProgram(tui.InitialModel(), tea.WithAltScreen())
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
// Setup logging to a file
logFile, err := os.OpenFile("berth.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Printf("Error opening log file: %v\n", err)
os.Exit(1)
}
defer logFile.Close()

handler := slog.NewTextHandler(logFile, &slog.HandlerOptions{Level: slog.LevelDebug})
slog.SetDefault(slog.New(handler))

// Recover from panics and log them
defer func() {
if r := recover(); r != nil {
slog.Error("Panic recovered in main defer", "panic", r)
fmt.Printf("Alas, there's been a panic: %v\n", r)
os.Exit(1)
}
}()

var program *tea.Program
func() {
defer func() {
if r := recover(); r != nil {
slog.Error("Panic recovered during program initialization", "panic", r)
fmt.Printf("Alas, there's been a panic during init: %v\n", r)
os.Exit(1)
}
}()
slog.Debug("Initializing Bubble Tea program...")
program = tea.NewProgram(tui.InitialModel(), tea.WithAltScreen())
}()

slog.Debug("Running Bubble Tea program...")
if _, err := program.Run(); err != nil {
slog.Error("Program error", "error", err)
fmt.Printf("Alas, there's been an error: %v\n", err)
os.Exit(1)
}
}
34 changes: 33 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,57 @@ require (
github.com/charmbracelet/bubbles v0.21.0
github.com/charmbracelet/bubbletea v1.3.6
github.com/charmbracelet/lipgloss v1.1.0
github.com/docker/docker v28.3.3+incompatible
github.com/opencontainers/image-spec v1.1.1
github.com/stretchr/testify v1.10.0
)

require (
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/x/ansi v0.9.3 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/containerd/errdefs v1.0.0 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/atomicwriter v0.1.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
go.opentelemetry.io/otel v1.37.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.37.0 // indirect
go.opentelemetry.io/otel/metric v1.37.0 // indirect
go.opentelemetry.io/otel/trace v1.37.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.3.8 // indirect
golang.org/x/text v0.26.0 // indirect
golang.org/x/time v0.12.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.2 // indirect
)
Loading