Skip to content

Commit

Permalink
Update hardcoded version to constant
Browse files Browse the repository at this point in the history
Replaced all hardcoded instances of the version number "1.13.11.8" with a constant named "Version". This change will make future version updates easier and less error-prone, as the version number will only need to be updated in one place. This change affects the main.go file in the .build/bundle directory.
  • Loading branch information
skrashevich committed Nov 20, 2023
1 parent 1792411 commit 08366bf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .build/bundle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
//go:embed assets.tar.xz
var assets embed.FS

const Version = "1.13.11.8"

func common() []cli.Flag {
homedir, _ := os.UserHomeDir()
return []cli.Flag{
Expand Down Expand Up @@ -80,7 +82,7 @@ func main() {

app := &cli.App{
Name: "double-take",
Version: "1.13.11.8",
Version: Version,
Author: "skrashevich",
Usage: "double-take",
Description: "double-take",
Expand Down Expand Up @@ -238,7 +240,7 @@ func uninstall(c *cli.Context) error {
func execute(c *cli.Context) error {
store := c.String("store")
store = filepath.Join(store, "bundle")
fmt.Println("Starting double-take 1.13.11.8 with store at", store)
fmt.Printf("Starting double-take %s with store at %s\n", Version, store)
if err := mountProc(store); err != nil {
fmt.Println("failed mounting /proc")
}
Expand Down Expand Up @@ -324,8 +326,8 @@ func start(c *cli.Context) error {
version = string(d)
}

if version != "1.13.11.8" {
fmt.Printf("Extracting double-take 1.13.11.8 bundle data (xz) into %s ...\n", store)
if version != Version {
fmt.Printf("Extracting double-take %s bundle data (xz) into %s ...\n", Version, store)
os.RemoveAll(path.Join(store, "bundle"))
err := copyBinary(store, c.Bool("continue-on-error"))
if err != nil {
Expand All @@ -334,7 +336,7 @@ func start(c *cli.Context) error {
}
fmt.Println("Failed copying binaries:", err.Error())
}
must(ioutil.WriteFile(path.Join(store, "VERSION"), []byte("1.13.11.8"), os.ModePerm))
must(ioutil.WriteFile(path.Join(store, "VERSION"), []byte((Version)), os.ModePerm))
}

var mounts []string
Expand Down

0 comments on commit 08366bf

Please sign in to comment.