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
11 changes: 11 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"context"
"fmt"
"log"
"os"
"strings"

"github.com/Azure/mcp-kubernetes/pkg/security"
"github.com/Azure/mcp-kubernetes/pkg/telemetry"
"github.com/Azure/mcp-kubernetes/pkg/version"
flag "github.com/spf13/pflag"
)

Expand Down Expand Up @@ -67,8 +69,17 @@ func (cfg *ConfigData) ParseFlags() error {
// OTLP settings
flag.StringVar(&cfg.OTLPEndpoint, "otlp-endpoint", "", "OTLP endpoint for OpenTelemetry traces (e.g. localhost:4317, default \"\")")

// Version flag
showVersion := flag.Bool("version", false, "Show version information and exit")

flag.Parse()

// Handle version flag
if *showVersion {
version.PrintVersion()
os.Exit(0)
}

// Update security config with access level
switch cfg.AccessLevel {
case "readonly":
Expand Down
11 changes: 10 additions & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Version information
var (
// GitVersion is the git tag version
GitVersion = "1"
GitVersion = "dev"
// BuildMetadata is extra build time data
BuildMetadata = ""
// GitCommit is the git sha1
Expand Down Expand Up @@ -47,3 +47,12 @@ func GetVersionInfo() map[string]string {
"platform": fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH),
}
}

// PrintVersion prints version information in a human-readable format
func PrintVersion() {
fmt.Printf("mcp-kubernetes version %s\n", GetVersion())
fmt.Printf("Git commit: %s\n", GitCommit)
fmt.Printf("Git tree state: %s\n", GitTreeState)
fmt.Printf("Go version: %s\n", runtime.Version())
fmt.Printf("Platform: %s/%s\n", runtime.GOOS, runtime.GOARCH)
}
Loading