Skip to content

Commit

Permalink
Improve version output for local builds - see #831 (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg authored Jul 8, 2021
1 parent 2561bb7 commit 63d0bef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Alternatively, install with Go:
go get -u github.com/tfsec/tfsec/cmd/tfsec
```

Please note that using `go get` will install directly from the `master` branch and version numbers will not be reported via `tfsec --version`.

## Usage

tfsec will scan the specified directory. If no directory is specified, the current working directory will be used.
Expand Down
6 changes: 5 additions & 1 deletion cmd/tfsec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ var rootCmd = &cobra.Command{
}

if showVersion {
fmt.Println(version.Version)
if version.Version == "" {
fmt.Println("You are running a locally built version of tfsec.")
} else {
fmt.Println(version.Version)
}
os.Exit(0)
}

Expand Down
4 changes: 2 additions & 2 deletions internal/app/tfsec/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type githubRelease struct {
}

func Update() error {
if version.Version == "development" {
return fmt.Errorf("you are running a development branch")
if version.Version == "" {
return fmt.Errorf("you are running a locally built version")
}

latestAvailable, err := getLatestVersion()
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package version

// Version is automatically set using ldflags on build/release. Describes built version of tfsec.
var Version = "development"
var Version = ""

0 comments on commit 63d0bef

Please sign in to comment.