mirror of
https://github.com/rancher/k3k.git
synced 2026-08-18 03:46:31 +00:00
fixed missing version (#196)
This commit is contained in:
+10
-1
@@ -20,6 +20,9 @@ builds:
|
||||
- "amd64"
|
||||
- "arm64"
|
||||
- "s390x"
|
||||
ldflags:
|
||||
- -w -s # strip debug info and symbol table
|
||||
- -X "github.com/rancher/k3k/pkg/buildinfo.Version={{ .Tag }}"
|
||||
|
||||
- id: k3k-kubelet
|
||||
main: ./k3k-kubelet
|
||||
@@ -32,7 +35,10 @@ builds:
|
||||
- "amd64"
|
||||
- "arm64"
|
||||
- "s390x"
|
||||
|
||||
ldflags:
|
||||
- -w -s # strip debug info and symbol table
|
||||
- -X "github.com/rancher/k3k/pkg/buildinfo.Version={{ .Tag }}"
|
||||
|
||||
- id: k3kcli
|
||||
main: ./cli
|
||||
binary: k3kcli
|
||||
@@ -41,6 +47,9 @@ builds:
|
||||
goarch:
|
||||
- "amd64"
|
||||
- "arm64"
|
||||
ldflags:
|
||||
- -w -s # strip debug info and symbol table
|
||||
- -X "github.com/rancher/k3k/pkg/buildinfo.Version={{ .Tag }}"
|
||||
|
||||
archives:
|
||||
- format: binary
|
||||
|
||||
+7
-7
@@ -1,28 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/rancher/k3k/cli/cmds"
|
||||
"github.com/rancher/k3k/cli/cmds/cluster"
|
||||
"github.com/rancher/k3k/cli/cmds/kubeconfig"
|
||||
"github.com/rancher/k3k/pkg/buildinfo"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
const (
|
||||
program = "k3kcli"
|
||||
version = "dev"
|
||||
gitCommit = "HEAD"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cmds.NewApp()
|
||||
app.Version = buildinfo.Version
|
||||
cli.VersionPrinter = func(cCtx *cli.Context) {
|
||||
fmt.Println("k3kcli Version: " + buildinfo.Version)
|
||||
}
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
cluster.NewCommand(),
|
||||
kubeconfig.NewCommand(),
|
||||
}
|
||||
app.Version = version + " (" + gitCommit + ")"
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/go-logr/zapr"
|
||||
"github.com/rancher/k3k/cli/cmds"
|
||||
"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
|
||||
"github.com/rancher/k3k/pkg/buildinfo"
|
||||
"github.com/rancher/k3k/pkg/controller/cluster"
|
||||
"github.com/rancher/k3k/pkg/controller/clusterset"
|
||||
"github.com/rancher/k3k/pkg/log"
|
||||
@@ -22,12 +23,6 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
)
|
||||
|
||||
const (
|
||||
program = "k3k"
|
||||
version = "dev"
|
||||
gitCommit = "HEAD"
|
||||
)
|
||||
|
||||
var (
|
||||
scheme = runtime.NewScheme()
|
||||
clusterCIDR string
|
||||
@@ -73,7 +68,7 @@ func main() {
|
||||
app := cmds.NewApp()
|
||||
app.Flags = flags
|
||||
app.Action = run
|
||||
app.Version = version + " (" + gitCommit + ")"
|
||||
app.Version = buildinfo.Version
|
||||
app.Before = func(clx *cli.Context) error {
|
||||
logger = log.New(debug)
|
||||
return nil
|
||||
@@ -81,12 +76,13 @@ func main() {
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logger.Fatalw("failed to run k3k controller", zap.Error(err))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func run(clx *cli.Context) error {
|
||||
ctx := context.Background()
|
||||
|
||||
logger.Info("Starting k3k - Version: " + buildinfo.Version)
|
||||
|
||||
restConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create config from kubeconfig file: %v", err)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package buildinfo
|
||||
|
||||
var Version = "dev"
|
||||
+9
-3
@@ -4,15 +4,21 @@ set -e pipefail
|
||||
|
||||
TAG=$(git describe --tag --always)
|
||||
|
||||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
|
||||
TAG="${TAG}-dirty"
|
||||
fi
|
||||
|
||||
LDFLAGS="-X \"github.com/rancher/k3k/pkg/buildinfo.Version=${TAG}\""
|
||||
|
||||
echo "Building k3k..."
|
||||
echo "Current TAG: ${TAG}"
|
||||
|
||||
export CGO_ENABLED=0
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/k3k
|
||||
GOOS=linux GOARCH=amd64 go build -o bin/k3k-kubelet ./k3k-kubelet
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o bin/k3k
|
||||
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o bin/k3k-kubelet ./k3k-kubelet
|
||||
|
||||
# build the cli for the local OS and ARCH
|
||||
go build -o bin/k3kcli ./cli
|
||||
go build -ldflags="${LDFLAGS}" -o bin/k3kcli ./cli
|
||||
|
||||
docker build -f package/Dockerfile -t rancher/k3k:dev -t rancher/k3k:${TAG} .
|
||||
docker build -f package/Dockerfile.kubelet -t rancher/k3k-kubelet:dev -t rancher/k3k-kubelet:${TAG} .
|
||||
|
||||
Reference in New Issue
Block a user