@@ -323,19 +323,34 @@ func healthCheck(cfg config.AppConfig, logger log.Logger) error {
323323
324324func printVersion (writer io.Writer ) error {
325325 var buffer bytes.Buffer
326- var libcontainersshVersion string
326+ var libcontainersshVersion , buildRevision , buildTime , buildArch , buildmodified string
327327 bi , ok := debug .ReadBuildInfo ()
328328 if ! ok {
329329 return fmt .Errorf ("read build info %t" , ok )
330330 }
331+ fmt .Printf ("%+v\n " , bi )
331332 for _ , dep := range bi .Deps {
332333 if dep .Path == "go.containerssh.io/libcontainerssh" {
333334 libcontainersshVersion = dep .Version
335+ break
334336 }
335337 }
336- buffer .WriteString ("libcontainerssh version " )
337- buffer .WriteString (libcontainersshVersion )
338- buffer .WriteString ("\n " )
338+ for _ , setting := range bi .Settings {
339+ if setting .Key == "vcs.revision" {
340+ buildRevision = setting .Value
341+ } else if setting .Key == "vcs.time" {
342+ buildTime = setting .Value
343+ } else if setting .Key == "GOARCH" {
344+ buildArch = setting .Value
345+ } else if setting .Key == "modified" {
346+ buildmodified = setting .Value
347+ }
348+ }
349+ stringGolangVersion := bi .GoVersion + " - " + buildArch + "\n "
350+ stringLibcontainersshVersion := fmt .Sprintf ("libcontainerssh version : %s\n " , libcontainersshVersion )
351+ stringBuildRevision := fmt .Sprintf ("build revision: %s(%s) {{%s}}\n " , buildRevision , buildTime , buildmodified )
352+ stringConcateBuildInfo := stringGolangVersion + stringLibcontainersshVersion + stringBuildRevision
353+ buffer .WriteString (stringConcateBuildInfo )
339354 if _ , err := writer .Write (buffer .Bytes ()); err != nil {
340355 return fmt .Errorf ("failed to write Version information (%w)" , err )
341356 }
0 commit comments