Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: ensure vendored tools versions print out #586

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@

ARCH ?= amd64
CLI_VERSION ?= $(if $(shell git describe --tags),$(shell git describe --tags),"UnknownVersion")
K9S_VERSION=$(shell go list -f '{{.Version}}' -m github.com/derailed/k9s)
CRANE_VERSION=$(shell go list -f '{{.Version}}' -m github.com/google/go-containerregistry)
SYFT_VERSION=$(shell go list -f '{{.Version}}' -m github.com/anchore/syft)
ARCHIVER_VERSION=$(shell go list -f '{{.Version}}' -m github.com/mholt/archiver/v3)
HELM_VERSION=$(shell go list -f '{{.Version}}' -m helm.sh/helm/v3)
BUILD_ARGS := -s -w -X 'github.com/defenseunicorns/uds-cli/src/config.CLIVersion=$(CLI_VERSION)' \
-X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf'
-X 'github.com/defenseunicorns/zarf/src/config.ActionsCommandZarfPrefix=zarf' \
-X 'github.com/derailed/k9s/cmd.version=$(K9S_VERSION)' \
-X 'github.com/google/go-containerregistry/cmd/crane/cmd.Version=$(CRANE_VERSION)' \
-X 'github.com/defenseunicorns/zarf/src/cmd/tools.syftVersion=$(SYFT_VERSION)' \
-X 'github.com/defenseunicorns/zarf/src/cmd/tools.archiverVersion=$(ARCHIVER_VERSION)' \
-X 'github.com/defenseunicorns/zarf/src/cmd/tools.helmVersion=$(HELM_VERSION)'

.PHONY: help
help: ## Display this help information
Expand Down
20 changes: 20 additions & 0 deletions src/test/e2e/zarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

"github.com/defenseunicorns/zarf/src/pkg/utils/exec"
"github.com/stretchr/testify/require"
)

Expand All @@ -20,3 +21,22 @@ func TestZarfLint(t *testing.T) {
require.NoError(t, err)
require.Contains(t, stdErr, "Image not pinned with digest - ghcr.io/stefanprodan/podinfo:6.4.0")
}

// K9S_VERSION=$(shell go list -f '{{.Version}}' -m github.com/derailed/k9s)
// CRANE_VERSION=$(shell go list -f '{{.Version}}' -m github.com/google/go-containerregistry)
// SYFT_VERSION=$(shell go list -f '{{.Version}}' -m github.com/anchore/syft)
// ARCHIVER_VERSION=$(shell go list -f '{{.Version}}' -m github.com/mholt/archiver/v3)
// HELM_VERSION=$(shell go list -f '{{.Version}}' -m helm.sh/helm/v3)

// // vendored tool versions are set as build args
func TestZarfToolsVersions(t *testing.T) {
decleaver marked this conversation as resolved.
Show resolved Hide resolved
cmd := strings.Split("zarf tools helm version", " ")
_, stderr, err := e2e.UDS(cmd...)
getHelmVersionCmd := strings.Split("list -f '{{.Version}}' -m helm.sh/helm/v3", " ")
versionRes, _, _ := exec.Cmd("go", getHelmVersionCmd...)
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
helmVersion := strings.Split(versionRes, "'")
version := strings.Split(stderr, "\n")
require.NoError(t, err)
require.Contains(t, version[4], "helm")
require.Contains(t, version[4], helmVersion[1])
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont love having "magic" array values, think you're fine if you update the contains to just version instead of version[4] and maybe just add [1] to line 37 for the helm version. I know its somewhat duplicative but probably worth testing the other tools too. Let me know what you think. Thanks again for uds-cli'ing!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to remove some of the magicalness by doing what we talked about and then moving the tool version index reference out of the requires and up to where toolVersion is set. hopefully that makes things more readable.

Loading