Skip to content

Commit

Permalink
Inform user if their talisman build is older than 60 days
Browse files Browse the repository at this point in the history
  • Loading branch information
dcRUSTy committed Sep 9, 2020
1 parent d407996 commit db89b1b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build
Expand Up @@ -2,5 +2,5 @@
VERSION=$(git describe --tags HEAD)
export GO111MODULE=on
go get github.com/mitchellh/gox
gox -os="linux darwin windows" -arch="386 amd64" -ldflags="-s -w -X main.Version=${VERSION}"
gox -os="linux darwin windows" -arch="386 amd64" -ldflags="-s -w -X main.Version=${VERSION} -X main.buildTimeStampString=`date +%s`"
shasum -b -a256 talisman_{l,d,w}* > checksums
25 changes: 18 additions & 7 deletions talisman.go
Expand Up @@ -4,7 +4,9 @@ import (
"github.com/spf13/afero"
flag "github.com/spf13/pflag"
"runtime"
"strconv"
"talisman/prompt"
"time"
)

import (
Expand All @@ -24,12 +26,13 @@ var (
showVersion bool
pattern string
//Version : Version of talisman
Version = "Development Build"
scan bool
checksum string
reportdirectory string
scanWithHtml bool
interactive bool
Version = "Development Build"
buildTimeStampString = "0"
scan bool
checksum string
reportdirectory string
scanWithHtml bool
interactive bool
)

const (
Expand All @@ -55,6 +58,7 @@ type options struct {

//Logger is the default log device, set to emit at the Error level by default
func main() {
warnIfBuildIsOlderThan60Days()
flag.BoolVarP(&fdebug, "debug", "d", false, "enable debug mode (warning: very verbose)")
flag.BoolVarP(&showVersion, "version", "v", false, "show current version of talisman")
flag.StringVarP(&pattern, "pattern", "p", "", "pattern (glob-like) of files to scan (ignores githooks)")
Expand Down Expand Up @@ -92,7 +96,6 @@ func main() {
checksum: checksum,
reportdirectory: reportdirectory,
scanWithHtml: scanWithHtml,

}

prompter := prompt.NewPrompt()
Expand All @@ -101,6 +104,14 @@ func main() {
os.Exit(run(os.Stdin, _options, promptContext))
}

func warnIfBuildIsOlderThan60Days() {
buildTimeStamp, _ := strconv.ParseInt(buildTimeStampString, 10, 64)
secondsInSixtyDays := int64(5184000)
if time.Now().Unix()-buildTimeStamp > secondsInSixtyDays {
fmt.Printf("Talisman build is more than 60 days old. Do verify manually if a update is available.\n")
}
}

func run(stdin io.Reader, _options options, promptContext prompt.PromptContext) (returnCode int) {
if err := validateGitExecutable(afero.NewOsFs(), runtime.GOOS); err != nil {
log.Printf("error validating git executable: %v", err)
Expand Down

0 comments on commit db89b1b

Please sign in to comment.