88 "encoding/json"
99 "errors"
1010 "fmt"
11+ "go/version"
1112 "io"
1213 "io/fs"
1314 "os"
@@ -31,8 +32,6 @@ import (
3132 "github.com/project-dalec/dalec/frontend"
3233 "github.com/project-dalec/dalec/frontend/pkg/bkfs"
3334 "github.com/project-dalec/dalec/targets"
34- "github.com/project-dalec/dalec/targets/linux/deb/ubuntu"
35- "github.com/project-dalec/dalec/targets/linux/rpm/azlinux"
3635 "github.com/project-dalec/dalec/test/testenv"
3736 "golang.org/x/exp/maps"
3837 "gotest.tools/v3/assert"
@@ -98,9 +97,10 @@ type testLinuxConfig struct {
9897 Units string
9998 Targets string
10099 }
101- Libdir string
102- Worker workerConfig
103- Release OSRelease
100+ Libdir string
101+ Worker workerConfig
102+ Release OSRelease
103+ GoVersion string
104104
105105 Platforms []ocispecs.Platform
106106 PackageOutputPath func (spec * dalec.Spec , platform ocispecs.Platform ) string
@@ -2274,23 +2274,20 @@ func True(t interface{}, value bool, msgAndArgs ...interface{}) bool {
22742274 t .Parallel ()
22752275 ctx := startTestSpan (baseCtx , t )
22762276
2277- // Skip on distros with older Go versions that can't handle toolchain downloads
2278- // This test uses golang.org/x/[email protected] which may require Go 1.24+ 2279- // focal and mariner2 have Go < 1.22 and network is disabled during builds
2280- skip .If (t , testConfig .Target .Key == azlinux .Mariner2TargetKey || testConfig .Target .Key == ubuntu .FocalDefaultTargetKey ,
2281- "Test requires Go 1.22+ for automatic toolchain management" )
2277+ // Skip on distros with Go versions below 1.21 that can't handle automatic toolchain management
2278+ skip .If (t , testConfig .GoVersion == "" || version .Compare ("go" + testConfig .GoVersion , "go1.21" ) < 0 ,
2279+ "Test requires Go 1.21+ for automatic toolchain management" )
22822280
22832281 // Start with go.mod and go.work both at go 1.18
2284- // Use a replace directive that may bump go.mod version
22852282 // Verify that go.work stays in sync with go.mod
22862283 pg := dalec .ProgressGroup ("Setup test context" )
22872284 contextSt := llb .Scratch ().
2288- File (llb .Mkfile ("/go.mod" , 0644 , []byte ("module example.com/test\n \n go 1.18\n \n require golang.org/x/crypto v0.30 .0\n " )), pg ).
2285+ File (llb .Mkfile ("/go.mod" , 0644 , []byte ("module example.com/test\n \n go 1.18\n \n require go.etcd.io/etcd/client/v3 v3.5 .0\n " )), pg ).
22892286 File (llb .Mkfile ("/go.work" , 0644 , []byte ("go 1.18\n \n use .\n " )), pg ).
22902287 File (llb .Mkfile ("/main.go" , 0644 , []byte (`package main
22912288import (
22922289 "fmt"
2293- _ "golang.org/x/crypto/bcrypt "
2290+ _ "go.etcd.io/etcd/client/v3 "
22942291)
22952292func main() {
22962293 fmt.Println("hello")
@@ -2315,8 +2312,8 @@ func main() {
23152312 Gomod : & dalec.GeneratorGomod {
23162313 Edits : & dalec.GomodEdits {
23172314 Replace : []dalec.GomodReplace {
2318- // This may cause go.mod version to be bumped depending on the Go toolchain
2319- {
Original :
"golang.org/x/crypto " ,
Update :
"golang.org/x/[email protected] " },
2315+ // v3.5.14 requires go 1.21, which will bump go.mod from 1.18 to 1.21
2316+ {
Original :
"go.etcd.io/etcd/client/v3 " ,
Update :
"go.etcd.io/etcd/client/[email protected] " },
23202317 },
23212318 },
23222319 },
@@ -2331,8 +2328,8 @@ func main() {
23312328 },
23322329 Build : dalec.ArtifactBuild {
23332330 Steps : []dalec.BuildStep {
2334- {Command : "grep -F 'replace golang.org/x/crypto ' ./src/go.mod" },
2335- {Command : "grep -F 'golang.org/x/crypto v0.45.0 ' ./src/go.mod" },
2331+ {Command : "grep -F 'replace go.etcd.io/etcd/client/v3 ' ./src/go.mod" },
2332+ {Command : "grep -F 'go.etcd.io/etcd/client/v3 v3.5.14 ' ./src/go.mod" },
23362333 // Verify go.work exists
23372334 {Command : "test -f ./src/go.work" },
23382335 // Verify the go versions in go.mod and go.work match exactly
0 commit comments