mirror of
https://github.com/lukaszraczylo/kportal.git
synced 2026-06-30 05:44:37 +00:00
style: Extract UI constants and refactor main view rendering (#30)
- [x] Add golangci-lint configuration with gocritic ifElseChain disabled
- [x] Rename error variables to avoid shadowing (createErr, watcherErr, watchErr, etc.)
- [x] Replace `interface{}` with `any` type alias throughout codebase
- [x] Add package-level documentation comments to all internal packages
- [x] Reorder struct fields alphabetically for consistency
- [x] Extract UI constants (terminal dimensions, column widths, colors) to constants.go
- [x] Refactor BubbleTeaUI main view rendering into smaller helper functions
- [x] Simplify nested conditionals and improve code clarity
- [x] Add `isForwardDisabled()` helper method to BubbleTeaUI
- [x] Update file permissions from 0644 to 0600 in config tests
- [x] Add `#nosec` comments and error suppression where appropriate
- [x] Improve test table struct field ordering for readability
- [x] Fix resource parsing in AddForward using strings.SplitN
- [x] Add comprehensive tests for new UI helper functions and constants
This commit is contained in:
@@ -15,20 +15,21 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/nvm/kportal/internal/config"
|
||||
"github.com/nvm/kportal/internal/logger"
|
||||
)
|
||||
|
||||
// Proxy is an HTTP reverse proxy with logging capabilities
|
||||
type Proxy struct {
|
||||
localPort int // Port to listen on (user-facing)
|
||||
targetPort int // Port to forward to (k8s tunnel)
|
||||
listener net.Listener
|
||||
logger *Logger
|
||||
server *http.Server
|
||||
forwardID string
|
||||
filterPath string // Glob pattern for path filtering
|
||||
includeHdrs bool
|
||||
listener net.Listener
|
||||
filterPath string
|
||||
localPort int
|
||||
targetPort int
|
||||
requestCount uint64
|
||||
mu sync.Mutex
|
||||
includeHdrs bool
|
||||
running bool
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ func (p *Proxy) Start() error {
|
||||
// Start serving (blocking)
|
||||
go func() {
|
||||
if err := p.server.Serve(ln); err != nil && err != http.ErrServerClosed {
|
||||
// Log error but don't crash - proxy will be replaced on reconnect
|
||||
logger.Debug("HTTP proxy serve error (will be replaced on reconnect)", map[string]any{"error": err.Error()})
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user