Skip to content

Commit

Permalink
Merge pull request #41 from flant/new-version
Browse files Browse the repository at this point in the history
Added `kubedog version` command, refactor build script
  • Loading branch information
distorhead authored Dec 25, 2018
2 parents 3dd484f + ed7a014 commit e0af242
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release-build
release/build
9 changes: 9 additions & 0 deletions cmd/kubedog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/flant/kubedog/pkg/kube"
"github.com/flant/kubedog/pkg/kubedog"
"github.com/flant/kubedog/pkg/tracker"
"github.com/flant/kubedog/pkg/trackers/follow"
"github.com/flant/kubedog/pkg/trackers/rollout"
Expand Down Expand Up @@ -66,6 +67,14 @@ func main() {
rootCmd.PersistentFlags().IntVarP(&timeoutSeconds, "timeout", "t", -1, "watch timeout in seconds") // default is 0 for follow
rootCmd.PersistentFlags().StringVarP(&logsSince, "logs-since", "", "now", "logs newer than a relative duration like 30s, 5m, or 2h")

versionCmd := &cobra.Command{
Use: "version",
Run: func(_ *cobra.Command, _ []string) {
fmt.Println(kubedog.Version)
},
}
rootCmd.AddCommand(versionCmd)

followCmd := &cobra.Command{Use: "follow"}
rootCmd.AddCommand(followCmd)

Expand Down
13 changes: 0 additions & 13 deletions go-release-build.sh

This file was deleted.

5 changes: 5 additions & 0 deletions pkg/kubedog/kubedog.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package kubedog

var (
Version = "dev"
)
27 changes: 27 additions & 0 deletions release/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

VERSION=$1

if [ -z "$VERSION" ] ; then
echo "Usage: $0 VERSION"
echo
exit 1
fi

RELEASE_BUILD_DIR=$(pwd)/release/build

rm -rf $RELEASE_BUILD_DIR

for arch in linux darwin ; do
outputDir=$RELEASE_BUILD_DIR/$arch-amd64

mkdir -p $outputDir

echo "Building kubedog for $arch, version $VERSION"
GOOS=$arch GOARCH=amd64 go build -ldflags="-s -w -X github.com/flant/kubedog/pkg/kubedog.Version=$VERSION" -o $outputDir/kubedog github.com/flant/kubedog/cmd/kubedog

echo "Calculating checksum kubedog.sha"
sha256sum $outputDir/kubedog | cut -d' ' -f 1 > $outputDir/kubedog.sha
done

0 comments on commit e0af242

Please sign in to comment.