@@ -4,6 +4,10 @@ import (
44	"fmt" 
55
66	"github.com/spf13/cobra" 
7+ 	apimachineryversion "k8s.io/apimachinery/pkg/version" 
8+ 	"sigs.k8s.io/yaml" 
9+ 
10+ 	ocmcli "github.com/openmcp-project/bootstrapper/internal/ocm-cli" 
711
812	"github.com/openmcp-project/bootstrapper/internal/version" 
913)
@@ -17,18 +21,35 @@ var versionCmd = &cobra.Command{
1721This command displays detailed version information including the build version, 
1822Git commit, build date, Go version, and platform information.` ,
1923	Run : func (cmd  * cobra.Command , args  []string ) {
20- 		printVersion ()
21- 	},
22- }
24+ 		ownVersion  :=  version .GetVersion ()
2325
24- func  printVersion () {
25- 	v  :=  version .GetVersion ()
26+ 		if  ownVersion  ==  nil  {
27+ 			fmt .Println ("Version information not available" )
28+ 			return 
29+ 		}
2630
27- 	if  v  ==  nil  {
28- 		fmt .Println ("Version information not available" )
29- 		return 
30- 	}
31+ 		printVersion (ownVersion , "openMCP Bootstrapper CLI" )
32+ 
33+ 		var  ocmVersion  apimachineryversion.Info 
34+ 		out , err  :=  ocmcli .ExecuteOutput (cmd .Context (), []string {"version" }, nil , ocmcli .NoOcmConfig )
35+ 		if  err  !=  nil  {
36+ 			fmt .Printf ("Error retrieving ocm-cli version: %ownVersion\n " , err )
37+ 			return 
38+ 		}
39+ 
40+ 		err  =  yaml .Unmarshal (out , & ocmVersion )
41+ 		if  err  !=  nil  {
42+ 			fmt .Printf ("Error parsing ocm-cli version output: %ownVersion\n " , err )
43+ 			return 
44+ 		}
45+ 
46+ 		printVersion (& ocmVersion , "OCM CLI" )
47+ 	},
48+ }
3149
50+ func  printVersion (v  * apimachineryversion.Info , header  string ) {
51+ 	fmt .Printf ("\n %s\n " , header )
52+ 	fmt .Printf ("========================\n " )
3253	fmt .Printf ("Version:      %s\n " , v .GitVersion )
3354	if  v .GitCommit  !=  ""  {
3455		fmt .Printf ("Git Commit:   %s\n " , v .GitCommit )
@@ -42,6 +63,7 @@ func printVersion() {
4263	fmt .Printf ("Go Version:   %s\n " , v .GoVersion )
4364	fmt .Printf ("Compiler:     %s\n " , v .Compiler )
4465	fmt .Printf ("Platform:     %s\n " , v .Platform )
66+ 	fmt .Printf ("===================\n " )
4567}
4668
4769func  init () {
0 commit comments