Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "kcp", Short: "A CLI tool for kafka cluster planning and migration", Long: "A comprehensive CLI tool for planning and executing kafka cluster migrations to confluent cloud. Docs: " + build_info.DocsURL(), SilenceErrors: true, PersistentPreRun: func(cmd *cobra.Command, args []string) { lumberjackLogger := &lumberjack.Logger{ Filename: "kcp.log", MaxSize: 25, Compress: true, } fileHandler := NewPrettyHandler(lumberjackLogger, PrettyHandlerOptions{ SlogOpts: slog.HandlerOptions{ Level: slog.LevelDebug, }, }) consoleLevel := slog.LevelWarn if verbose { consoleLevel = slog.LevelDebug } consoleHandler := NewPrettyHandler(os.Stdout, PrettyHandlerOptions{ SlogOpts: slog.HandlerOptions{ Level: consoleLevel, }, Console: true, }) logger := slog.New(NewFanOutHandler(fileHandler, consoleHandler)) slog.SetDefault(logger) logging.SetFile(slog.New(fileHandler)) if build_info.IsDev() { fmt.Printf("\n%s\n%s\n%s\n%s\n%s\n\n", color.RedString("┌─────────────────────────────────────────────────────────────────────────────────────────────┐"), color.RedString("│ ⚠️ WARNING: This is a development build — not a defined release. │"), color.RedString("│ This build and any state files it generates should NOT be used for production or live use. │"), color.RedString("│ Install a released binary: https://github.com/confluentinc/kcp/releases │"), color.RedString("└─────────────────────────────────────────────────────────────────────────────────────────────┘")) } fmt.Printf("%s %s %s %s\n", color.CyanString("Executing kcp with build"), color.GreenString("version=%s", build_info.Version), color.YellowString("commit=%s", build_info.Commit), color.BlueString("date=%s", build_info.Date)) // Detailed, structured build provenance for support diagnostics. Logged at // Debug so it lands in kcp.log (file handler is Debug+) without doubling the // coloured banner above on the console (Debug is below the console default). // // vcs_modified is Go's `vcs.modified` build stamp — did the working tree have // uncommitted changes when the binary was built? It matters for support because // the commit hash alone doesn't fully describe a dirty build: // "true" — built from a dirty tree; commit + local edits, not reproducible. // "false" — built from a clean checkout; commit hash fully describes the binary. // "" — no VCS stamp (built outside a git checkout, e.g. from a tarball). var vcsModified string if bi, ok := debug.ReadBuildInfo(); ok { for _, s := range bi.Settings { if s.Key == "vcs.modified" { vcsModified = s.Value break } } } slog.Debug("build provenance", "cmd", cmd.CommandPath(), "version", build_info.Version, "commit", build_info.Commit, "date", build_info.Date, "dev_build", build_info.IsDev(), "vcs_modified", vcsModified, "go", runtime.Version(), "os", runtime.GOOS, "arch", runtime.GOARCH, ) if err := checkWritePermissions(); err != nil { fmt.Fprintf(os.Stderr, "%s\n", color.RedString("Error: %v", err)) os.Exit(1) } }, }
Functions ¶
This section is empty.
Types ¶
type FanOutHandler ¶ added in v0.7.0
type FanOutHandler struct {
// contains filtered or unexported fields
}
func NewFanOutHandler ¶ added in v0.7.0
func NewFanOutHandler(handlers ...slog.Handler) *FanOutHandler
type PrettyHandler ¶
func NewPrettyHandler ¶
func NewPrettyHandler( out io.Writer, opts PrettyHandlerOptions, ) *PrettyHandler
type PrettyHandlerOptions ¶
type PrettyHandlerOptions struct {
SlogOpts slog.HandlerOptions
// Console renders INFO records as clean, human-facing narrative (no
// time/level prefix) and colours the level on WARN/ERROR. The file
// handler leaves this false so kcp.log keeps the full structured form.
Console bool
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Command gen-docs regenerates the per-command markdown reference under docs/assets/command-reference/ from the Cobra command tree.
|
Command gen-docs regenerates the per-command markdown reference under docs/assets/command-reference/ from the Cobra command tree. |
Click to show internal directories.
Click to hide internal directories.