Skip to content

Commit

Permalink
Add Zarf build version when inspecting packages (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
YrrepNoj authored Dec 2, 2021
1 parent 2e48600 commit b370a77
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X 'github.com/defenseunicorns/zarf/cli/config.CLIVersion=$(CLI_VERSION)'" -o ../build/zarf main.go
build-mac:
mkdir -p ../build
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o ../build/zarf-mac-apple main.go
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o ../build/zarf-mac-intel main.go
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X 'github.com/defenseunicorns/zarf/cli/config.CLIVersion=$(CLI_VERSION)'" -o ../build/zarf-mac-apple main.go
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X 'github.com/defenseunicorns/zarf/cli/config.CLIVersion=$(CLI_VERSION)'" -o ../build/zarf-mac-intel main.go
4 changes: 4 additions & 0 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func GetComponents() []ZarfComponent {
return config.Components
}

func GetBuildData() ZarfBuildData {
return config.Package
}

func GetValidPackageExtensions() [3]string {
return [...]string{".tar.zst", ".tar", ".zip"}
}
Expand Down
6 changes: 6 additions & 0 deletions cli/internal/packager/inspect.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package packager

import (
"fmt"
"io/ioutil"

"github.com/defenseunicorns/zarf/cli/config"
"github.com/defenseunicorns/zarf/cli/internal/utils"
"github.com/mholt/archiver/v3"
"github.com/sirupsen/logrus"
Expand All @@ -29,5 +31,9 @@ func Inspect(packageName string) {

utils.ColorPrintYAML(text)

// Load the config to get the build version
config.Load(tempPath.base + "/zarf.yaml")
fmt.Printf("The package was built with Zarf CLI version %s\n", config.GetBuildData().Version)
cleanup(tempPath)

}

0 comments on commit b370a77

Please sign in to comment.