Skip to content

Commit

Permalink
Pull versioned golang images in Zlint testsuite to avoid pulling with…
Browse files Browse the repository at this point in the history
… latest (#28855)

* Pull versioned golang images in Zlint testsuite to avoid pulling with latest

 - Leverage the versioned golang images which should be more static avoiding
   issues we somtimes encounter pulling latest images from our docker mirror.
 - We use the golang runtime version to avoid having to update this test
   continuously.

* Fallback to latest if the version tag isn't a release tag
  • Loading branch information
stevendpclark authored Nov 7, 2024
1 parent 6c184c8 commit 68413ad
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions builtin/logical/pkiext/zlint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"context"
"encoding/json"
"fmt"
"regexp"
"runtime"
"strings"
"sync"
"testing"
"time"
Expand All @@ -20,14 +23,23 @@ import (
var (
zRunner *docker.Runner
buildZLintOnce sync.Once
releaseRegex = regexp.MustCompile(`^go\d+\.\d+\.\d+$`)
)

func buildZLintContainer(t *testing.T) {
containerfile := `
FROM docker.mirror.hashicorp.services/library/golang:latest
// Leverage the Go version running the test to pull a version tagged image
// to avoid the issues we sometimes encounter pulling images with the latest tag
runtimeVer := runtime.Version()
goVersion := "latest"
// The version returned from Go might not be a release tag such as go1.23.2, if it
// isn't fallback to latest
if releaseRegex.MatchString(runtimeVer) {
goVersion = strings.TrimPrefix(runtime.Version(), "go")
}
containerfile := fmt.Sprintf(`
FROM docker.mirror.hashicorp.services/library/golang:%s
RUN go install github.com/zmap/zlint/v3/cmd/[email protected]
`
`, goVersion)

bCtx := docker.NewBuildContext()

Expand Down

0 comments on commit 68413ad

Please sign in to comment.