Skip to content

Commit

Permalink
Moving version from variable to text file
Browse files Browse the repository at this point in the history
  • Loading branch information
surajnarwade committed Jul 17, 2017
1 parent 2985361 commit 1b4957f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions build/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.7.0
12 changes: 11 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ limitations under the License.
package cmd

import (
"os"

"fmt"

"github.com/spf13/cobra"

"io/ioutil"

"strings"
)

var (
// VERSION is version number that wil be displayed when running ./kompose version
VERSION = "0.7.0"
VERSION string
// GITCOMMIT is hash of the commit that wil be displayed when running ./kompose version
// this will be overwritten when running build like this: go build -ldflags="-X github.com/kubernetes/kompose/cmd.GITCOMMIT=$(GITCOMMIT)"
// HEAD is default indicating that this was not set during build
Expand All @@ -41,5 +47,9 @@ var versionCmd = &cobra.Command{
}

func init() {
gopath := os.Getenv("GOPATH")
path := gopath + "/src/github.com/kubernetes/kompose/build/VERSION"
version, _ := ioutil.ReadFile(path)
VERSION = strings.TrimSpace(string(version))
RootCmd.AddCommand(versionCmd)
}

0 comments on commit 1b4957f

Please sign in to comment.