added version information
This commit is contained in:
2
Makefile
2
Makefile
@@ -115,7 +115,7 @@ debfiles: debian
|
||||
cp wwclient $(DESTDIR)/var/warewulf/overlays/system/debian/warewulf/bin/
|
||||
|
||||
wwctl:
|
||||
cd cmd/wwctl; GOOS=linux go build -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
|
||||
cd cmd/wwctl; GOOS=linux go build -ldflags="-X 'github.com/hpcng/warewulf/internal/app/wwctl/version/version.Version=$(VERSION)'" -mod vendor -tags "$(WW_BUILD_GO_BUILD_TAGS)" -o ../../wwctl
|
||||
|
||||
wwclient:
|
||||
cd cmd/wwclient; CGO_ENABLED=0 GOOS=linux go build -mod vendor -a -ldflags '-extldflags -static' -o ../../wwclient
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/power"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/profile"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/server"
|
||||
"github.com/hpcng/warewulf/internal/app/wwctl/version"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"github.com/hpcng/warewulf/internal/pkg/help"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -46,6 +47,7 @@ func init() {
|
||||
rootCmd.AddCommand(profile.GetCommand())
|
||||
rootCmd.AddCommand(configure.GetCommand())
|
||||
rootCmd.AddCommand(server.GetCommand())
|
||||
rootCmd.AddCommand(version.GetCommand())
|
||||
|
||||
}
|
||||
|
||||
|
||||
16
internal/app/wwctl/version/main.go
Normal file
16
internal/app/wwctl/version/main.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var Version = "development"
|
||||
|
||||
func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
|
||||
fmt.Println("Version foo:\t", Version)
|
||||
|
||||
return nil
|
||||
}
|
||||
22
internal/app/wwctl/version/root.go
Normal file
22
internal/app/wwctl/version/root.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package version
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
baseCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Version information",
|
||||
Long: "This command will print the Warewulf version.",
|
||||
RunE: CobraRunE,
|
||||
Args: cobra.ExactArgs(0),
|
||||
Aliases: []string{"vers"},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
||||
// GetRootCommand returns the root cobra.Command for the application.
|
||||
func GetCommand() *cobra.Command {
|
||||
return baseCmd
|
||||
}
|
||||
Reference in New Issue
Block a user