This repository was archived by the owner on Jan 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 "os"
1010 "os/signal"
1111 "path/filepath"
12+ "runtime/debug"
1213 "strings"
1314 "syscall"
1415 "time"
@@ -21,10 +22,6 @@ import (
2122 "go.containerssh.io/libcontainerssh/service"
2223)
2324
24- var (
25- version = "0.5.0"
26- )
27-
2825// Main is a helper function to start a standard ContainerSSH instance. It should be used as the outer-most function
2926// and should never be used as an embedding technique.
3027func Main () {
@@ -326,8 +323,18 @@ func healthCheck(cfg config.AppConfig, logger log.Logger) error {
326323
327324func printVersion (writer io.Writer ) error {
328325 var buffer bytes.Buffer
329- buffer .WriteString ("v" )
330- buffer .WriteString (version )
326+ var libcontainersshVersion string
327+ bi , ok := debug .ReadBuildInfo ()
328+ if ! ok {
329+ return fmt .Errorf ("read build info %t" , ok )
330+ }
331+ for _ , dep := range bi .Deps {
332+ if dep .Path == "go.containerssh.io/libcontainerssh" {
333+ libcontainersshVersion = dep .Version
334+ }
335+ }
336+ buffer .WriteString ("libcontainerssh version " )
337+ buffer .WriteString (libcontainersshVersion )
331338 buffer .WriteString ("\n " )
332339 if _ , err := writer .Write (buffer .Bytes ()); err != nil {
333340 return fmt .Errorf ("failed to write Version information (%w)" , err )
You can’t perform that action at this time.
0 commit comments