Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
in controllers log the version of binary they are running (#666)
Browse files Browse the repository at this point in the history
* in controllers log the version of binary they are running

* in controllers log the version of binary they are running
  • Loading branch information
murali-reddy committed Apr 4, 2018
1 parent f7dfe63 commit 7ed4b51
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 33 deletions.
6 changes: 2 additions & 4 deletions Makefile
@@ -1,8 +1,6 @@
GO = go
GO_FLAGS =
GOFMT = gofmt
VERSION = dev-$(shell date +%FT%T%z)

KUBECFG = kubecfg
DOCKER = docker
CONTROLLER_IMAGE = kubeless-controller-manager:latest
Expand All @@ -29,10 +27,10 @@ all:
CGO_ENABLED=1 ./script/make.sh

binary:
CGO_ENABLED=1 ./script/binary $(VERSION)
CGO_ENABLED=1 ./script/binary

binary-cross:
./script/binary-cli $(VERSION)
./script/binary-cli


%.yaml: %.jsonnet
Expand Down
2 changes: 2 additions & 0 deletions cmd/kafka-trigger-controller/kafka-controller.go
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/kubeless/kubeless/pkg/controller"
"github.com/kubeless/kubeless/pkg/utils"
"github.com/kubeless/kubeless/pkg/version"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -61,6 +62,7 @@ var rootCmd = &cobra.Command{
}

func main() {
logrus.Infof("Running Kafka controller version: %v", version.Version)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/kubeless/kubeless/pkg/client/informers/externalversions"
"github.com/kubeless/kubeless/pkg/controller"
"github.com/kubeless/kubeless/pkg/utils"
"github.com/kubeless/kubeless/pkg/version"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -92,6 +93,7 @@ var rootCmd = &cobra.Command{
}

func main() {
logrus.Infof("Running Kubeless controller manager version: %v", version.Version)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
11 changes: 2 additions & 9 deletions cmd/kubeless/version/version.go
Expand Up @@ -19,23 +19,16 @@ package version
import (
"fmt"

"github.com/kubeless/kubeless/pkg/version"
"github.com/spf13/cobra"
)

var (
// VERSION will be overwritten automatically by the build system
VERSION = "devel"

// GITCOMMIT will be overwritten automatically by the build system
GITCOMMIT = "HEAD"
)

//VersionCmd contains first-class command for version
var VersionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of Kubeless",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Kubeless version: " + VERSION + " (" + GITCOMMIT + ")")
fmt.Println("Kubeless version: " + version.Version)
},
}
22 changes: 22 additions & 0 deletions pkg/version/version.go
@@ -0,0 +1,22 @@
/*
Copyright (c) 2016-2017 Bitnami
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package version

var (
// Version will be set automatically by the build system via -ldflags
Version string
)
10 changes: 2 additions & 8 deletions script/binary
Expand Up @@ -16,14 +16,8 @@

set -e

if [ -z "$1" ]; then
VERSION=dev-$(date +%FT%T%z)
else
VERSION=$1
fi

GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/cmd/kubeless/version.VERSION=${VERSION} -X github.com/kubeless/kubeless/cmd/kubeless/version.GITCOMMIT=${GITCOMMIT}")
GIT_COMMIT=$(git describe --tags --dirty)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/pkg/version.Version=${GIT_COMMIT}")

# Get rid of existing binary
rm -f ${GOPATH%%:*}/bin/kubeless*
Expand Down
11 changes: 3 additions & 8 deletions script/binary-cli
Expand Up @@ -19,14 +19,9 @@ set -e
OS_PLATFORM_ARG=(-os="darwin linux windows")
OS_ARCH_ARG=(-arch="386 amd64")

if [ -z "$1" ]; then
VERSION=dev-$(shell date +%FT%T%z)
else
VERSION=$1
fi

GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/cmd/kubeless/version.VERSION=${VERSION} -X github.com/kubeless/kubeless/cmd/kubeless/version.GITCOMMIT=${GITCOMMIT}")
GIT_COMMIT=$(git describe --tags --dirty)
BUILD_DATE=$(date)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/pkg/version.Version=${GIT_COMMIT}")

# Get rid of existing binaries
rm -rf bundles/kubeless*
Expand Down
5 changes: 3 additions & 2 deletions script/binary-controller
Expand Up @@ -41,8 +41,9 @@ else
PKG=($4)
fi

GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-ldflags="-w -X version.GITCOMMIT=${GITCOMMIT}")

GIT_COMMIT=$(git describe --tags --dirty)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/pkg/version.Version=${GIT_COMMIT}")

# Get rid of existing binaries
rm -rf bundles/kubeless*
Expand Down
6 changes: 4 additions & 2 deletions script/kafka-controller.sh
Expand Up @@ -29,8 +29,10 @@ else
OS_ARCH_ARG=($2)
fi

GITCOMMIT=$(git rev-parse --short HEAD)
BUILD_FLAGS=(-ldflags="-w -X version.GITCOMMIT=${GITCOMMIT}")

GIT_COMMIT=$(git describe --tags --dirty)
BUILD_DATE=$(date)
BUILD_FLAGS=(-ldflags="-w -X github.com/kubeless/kubeless/pkg/version.Version=${GIT_COMMIT}")

# Get rid of existing binaries
rm -rf bundles/kubeless*
Expand Down

0 comments on commit 7ed4b51

Please sign in to comment.