Browse code

vendor: update buildkit to v0.20.0-rc2

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2025/02/14 12:17:43
Showing 18 changed files
... ...
@@ -545,7 +545,9 @@ func getLabels(opt Opt, labels map[string]string) map[string]string {
545 545
 }
546 546
 
547 547
 func getCDIManager(specDirs []string) (*cdidevices.Manager, error) {
548
-	// TODO: intentionally not returning nil here on empty specDirs as not handled in all code-paths yet
548
+	if len(specDirs) == 0 {
549
+		return nil, nil
550
+	}
549 551
 	cdiCache, err := func() (*cdi.Cache, error) {
550 552
 		cdiCache, err := cdi.NewCache(
551 553
 			cdi.WithSpecDirs(specDirs...),
... ...
@@ -63,7 +63,7 @@ require (
63 63
 	github.com/miekg/dns v1.1.61
64 64
 	github.com/mistifyio/go-zfs/v3 v3.0.1
65 65
 	github.com/mitchellh/copystructure v1.2.0
66
-	github.com/moby/buildkit v0.20.0-rc1.0.20250212151618-2f7007eec399
66
+	github.com/moby/buildkit v0.20.0-rc2
67 67
 	github.com/moby/docker-image-spec v1.3.1
68 68
 	github.com/moby/ipvs v1.1.0
69 69
 	github.com/moby/locker v1.0.1
... ...
@@ -187,7 +187,7 @@ require (
187 187
 	github.com/mitchellh/reflectwalk v1.0.2 // indirect
188 188
 	github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
189 189
 	github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626 // indirect
190
-	github.com/package-url/packageurl-go v0.1.1-0.20220428063043-89078438f170 // indirect
190
+	github.com/package-url/packageurl-go v0.1.1 // indirect
191 191
 	github.com/pelletier/go-toml/v2 v2.2.3 // indirect
192 192
 	github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 // indirect
193 193
 	github.com/philhofer/fwd v1.1.2 // indirect
... ...
@@ -29,8 +29,8 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 h1:mlmW46Q0B79I+Aj4a
29 29
 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0/go.mod h1:PXe2h+LKcWTX9afWdZoHyODqR4fBa5boUM/8uJfZ0Jo=
30 30
 github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg=
31 31
 github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
32
-github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
33
-github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
32
+github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ=
33
+github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
34 34
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
35 35
 github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
36 36
 github.com/Graylog2/go-gelf v0.0.0-20191017102106-1550ee647df0 h1:cOjLyhBhe91glgZZNbQUg9BJC57l6BiSKov0Ivv7k0U=
... ...
@@ -383,8 +383,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
383 383
 github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
384 384
 github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
385 385
 github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
386
-github.com/moby/buildkit v0.20.0-rc1.0.20250212151618-2f7007eec399 h1:5D+c0/9DQkncvcLqFGYu7it8riR9kTonRIQpgUUg6r4=
387
-github.com/moby/buildkit v0.20.0-rc1.0.20250212151618-2f7007eec399/go.mod h1:mtRqVBkksyvFm+ljU1u+cigDh36TdFvlEGfz/XbYTiI=
386
+github.com/moby/buildkit v0.20.0-rc2 h1:QjACghvG0pSAp7dk9aQMYWioDEOljDWyyoUjyg35qfg=
387
+github.com/moby/buildkit v0.20.0-rc2/go.mod h1:kMXf90l/f3zygRK8bYbyetfyzoJYntb6Bpi2VsLfXgQ=
388 388
 github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
389 389
 github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
390 390
 github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ=
... ...
@@ -449,8 +449,8 @@ github.com/opencontainers/runtime-tools v0.9.1-0.20221107090550-2e043c6bd626/go.
449 449
 github.com/opencontainers/selinux v1.9.1/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI=
450 450
 github.com/opencontainers/selinux v1.11.1 h1:nHFvthhM0qY8/m+vfhJylliSshm8G1jJ2jDMcgULaH8=
451 451
 github.com/opencontainers/selinux v1.11.1/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
452
-github.com/package-url/packageurl-go v0.1.1-0.20220428063043-89078438f170 h1:DiLBVp4DAcZlBVBEtJpNWZpZVq0AEeCY7Hqk8URVs4o=
453
-github.com/package-url/packageurl-go v0.1.1-0.20220428063043-89078438f170/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c=
452
+github.com/package-url/packageurl-go v0.1.1 h1:KTRE0bK3sKbFKAk3yy63DpeskU7Cvs/x/Da5l+RtzyU=
453
+github.com/package-url/packageurl-go v0.1.1/go.mod h1:uQd4a7Rh3ZsVg5j0lNyAfyxIeGde9yrlhjF78GzeW0c=
454 454
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
455 455
 github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
456 456
 github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
... ...
@@ -39,6 +39,7 @@ const (
39 39
 	attrTimeout    = "timeout"
40 40
 	attrToken      = "token"
41 41
 	attrURL        = "url"
42
+	attrURLV2      = "url_v2"
42 43
 	attrRepository = "repository"
43 44
 	attrGHToken    = "ghtoken"
44 45
 	attrAPIVersion = "version"
... ...
@@ -79,6 +80,12 @@ func getConfig(attrs map[string]string) (*Config, error) {
79 79
 		}
80 80
 		apiVersionInt = int(i)
81 81
 	}
82
+	if apiVersionInt != 1 {
83
+		if v, ok := attrs[attrURLV2]; ok {
84
+			url = v
85
+			apiVersionInt = 2
86
+		}
87
+	}
82 88
 	// best effort on old clients
83 89
 	if apiVersionInt == 0 {
84 90
 		if strings.Contains(url, "results-receiver.actions.githubusercontent.com") {
... ...
@@ -19,12 +19,13 @@ func CheckInvalidPlatforms[T comparable](ctx context.Context, res *result.Result
19 19
 		return nil, err
20 20
 	}
21 21
 
22
-	if req.Request != "" {
23
-		return nil, nil
24
-	}
25
-
26
-	if _, ok := res.Metadata[exptypes.ExporterPlatformsKey]; len(res.Refs) > 0 && !ok {
27
-		return nil, errors.Errorf("build result contains multiple refs without platforms mapping")
22
+	if _, ok := res.Metadata[exptypes.ExporterPlatformsKey]; !ok {
23
+		if len(res.Refs) > 0 {
24
+			return nil, errors.Errorf("build result contains multiple refs without platforms mapping")
25
+		} else if res.IsEmpty() {
26
+			// No results and no exporter key. Don't run this check.
27
+			return nil, nil
28
+		}
28 29
 	}
29 30
 
30 31
 	isMap := len(res.Refs) > 0
... ...
@@ -1443,18 +1443,14 @@ func dispatchCopy(d *dispatchState, cfg copyConfig) error {
1443 1443
 			}
1444 1444
 			chopt.Mode = os.FileMode(p)
1445 1445
 		} else {
1446
-			if featureCopyChmodNonOctalEnabled {
1447
-				if _, err := mode.Parse(cfg.chmod); err != nil {
1448
-					var ne *strconv.NumError
1449
-					if errors.As(err, &ne) {
1450
-						return nonOctalErr // return nonOctalErr for compatibility if the value looks numeric
1451
-					}
1452
-					return err
1446
+			if _, err := mode.Parse(cfg.chmod); err != nil {
1447
+				var ne *strconv.NumError
1448
+				if errors.As(err, &ne) {
1449
+					return nonOctalErr // return nonOctalErr for compatibility if the value looks numeric
1453 1450
 				}
1454
-				chopt.ModeStr = cfg.chmod
1455
-			} else {
1456
-				return nonOctalErr
1451
+				return err
1457 1452
 			}
1453
+			chopt.ModeStr = cfg.chmod
1458 1454
 		}
1459 1455
 	}
1460 1456
 
... ...
@@ -5,8 +5,12 @@ package dockerfile2llb
5 5
 import (
6 6
 	"github.com/moby/buildkit/client/llb"
7 7
 	"github.com/moby/buildkit/frontend/dockerfile/instructions"
8
+	"github.com/pkg/errors"
8 9
 )
9 10
 
10
-func dispatchRunDevices(_ *instructions.RunCommand) ([]llb.RunOption, error) {
11
+func dispatchRunDevices(c *instructions.RunCommand) ([]llb.RunOption, error) {
12
+	if len(instructions.GetDevices(c)) > 0 {
13
+		return nil, errors.Errorf("device feature is only supported in Dockerfile frontend 1.14.0-labs or later")
14
+	}
11 15
 	return nil, nil
12 16
 }
13 17
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-//go:build !dfcopychmodnonoctal
2
-
3
-package dockerfile2llb
4
-
5
-var featureCopyChmodNonOctalEnabled = false
6 1
deleted file mode 100644
... ...
@@ -1,5 +0,0 @@
1
-//go:build dfcopychmodnonoctal
2
-
3
-package dockerfile2llb
4
-
5
-var featureCopyChmodNonOctalEnabled = true
... ...
@@ -199,16 +199,18 @@ func (e *ExecOp) CacheMap(ctx context.Context, g session.Group, index int) (*sol
199 199
 		cm.Deps[i].PreprocessFunc = unlazyResultFunc
200 200
 	}
201 201
 
202
-	for _, d := range e.op.CdiDevices {
203
-		setup, ok := e.w.CDIManager().OnDemandInstaller(d.Name)
204
-		if ok {
205
-			prev := cm.Deps[0].PreprocessFunc
206
-			cm.Deps[0].PreprocessFunc = func(ctx context.Context, r solver.Result, g session.Group) error {
207
-				if err := prev(ctx, r, g); err != nil {
208
-					return err
202
+	if e.w != nil && e.w.CDIManager() != nil {
203
+		for _, d := range e.op.CdiDevices {
204
+			setup, ok := e.w.CDIManager().OnDemandInstaller(d.Name)
205
+			if ok {
206
+				prev := cm.Deps[0].PreprocessFunc
207
+				cm.Deps[0].PreprocessFunc = func(ctx context.Context, r solver.Result, g session.Group) error {
208
+					if err := prev(ctx, r, g); err != nil {
209
+						return err
210
+					}
211
+					// we could pass glibc/musl type in here based on rootfs to get correct dynamic libs
212
+					return setup(ctx)
209 213
 				}
210
-				// we could pass glibc/musl type in here based on rootfs to get correct dynamic libs
211
-				return setup(ctx)
212 214
 			}
213 215
 		}
214 216
 	}
... ...
@@ -27,7 +27,6 @@ var qemuArchMap = map[string]string{
27 27
 	"riscv64": "riscv64",
28 28
 	"arm":     "arm",
29 29
 	"s390x":   "s390x",
30
-	"ppc64":   "ppc64",
31 30
 	"ppc64le": "ppc64le",
32 31
 	"386":     "i386",
33 32
 }
... ...
@@ -463,7 +463,7 @@ func init() {
463 463
 
464 464
 	Caps.Init(apicaps.Cap{
465 465
 		ID:      CapRemoteCacheAzBlob,
466
-		Enabled: false,
466
+		Enabled: true,
467 467
 		Status:  apicaps.CapStatusExperimental,
468 468
 	})
469 469
 
... ...
@@ -110,6 +110,20 @@ func (r *Result[T]) EachRef(fn func(T) error) (err error) {
110 110
 	return err
111 111
 }
112 112
 
113
+// IsEmpty returns true if this result does not refer to
114
+// any references.
115
+func (r *Result[T]) IsEmpty() bool {
116
+	r.mu.Lock()
117
+	defer r.mu.Unlock()
118
+
119
+	if len(r.Refs) > 0 {
120
+		return false
121
+	}
122
+
123
+	var zero T
124
+	return r.Ref == zero
125
+}
126
+
113 127
 // EachRef iterates over references in both a and b.
114 128
 // a and b are assumed to be of the same size and map their references
115 129
 // to the same set of keys
... ...
@@ -18,7 +18,7 @@ var (
18 18
 
19 19
 var (
20 20
 	UserCNIConfigPath = DefaultCNIConfigPath
21
-	CDISpecDirs       []string
21
+	CDISpecDirs       = []string{filepath.Join(os.Getenv("ProgramData"), "buildkitd", "cdi")}
22 22
 )
23 23
 
24 24
 func UserAddress() string {
... ...
@@ -1,12 +1,8 @@
1 1
 .PHONY: test clean lint
2 2
 
3 3
 test:
4
-	curl -L https://raw.githubusercontent.com/package-url/purl-spec/master/test-suite-data.json -o testdata/test-suite-data.json
5 4
 	go test -v -cover ./...
6 5
 
7
-clean:
8
-	find . -name "test-suite-data.json" | xargs rm -f
9
-
10 6
 lint:
11 7
 	go get -u golang.org/x/lint/golint
12 8
 	golint -set_exit_status
... ...
@@ -59,16 +59,16 @@ Testing using the normal ``go test`` command. Using ``make test`` will pull the
59 59
 
60 60
 ```
61 61
 $ make test
62
-curl -L https://raw.githubusercontent.com/package-url/purl-test-suite/master/test-suite-data.json -o testdata/test-suite-data.json
63
-  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
64
-                                 Dload  Upload   Total   Spent    Left  Speed
65
-100  7181  100  7181    0     0   1202      0  0:00:05  0:00:05 --:--:--  1611
66 62
 go test -v -cover ./...
67 63
 === RUN   TestFromStringExamples
68 64
 --- PASS: TestFromStringExamples (0.00s)
69 65
 === RUN   TestToStringExamples
70 66
 --- PASS: TestToStringExamples (0.00s)
67
+=== RUN   TestStringer
68
+--- PASS: TestStringer (0.00s)
69
+=== RUN   TestQualifiersMapConversion
70
+--- PASS: TestQualifiersMapConversion (0.00s)
71 71
 PASS
72
-coverage: 94.7% of statements
73
-ok      github.com/package-url/packageurl-go    0.002s
72
+coverage: 90.7% of statements
73
+ok      github.com/package-url/packageurl-go    0.004s  coverage: 90.7% of statements
74 74
 ```
... ...
@@ -89,6 +89,10 @@ var (
89 89
 	TypeRPM = "rpm"
90 90
 	// TypeSwift is pkg:swift purl
91 91
 	TypeSwift = "swift"
92
+	// TypeHuggingface is pkg:huggingface purl.
93
+	TypeHuggingface = "huggingface"
94
+	// TypeMLflow is pkg:mlflow purl.
95
+	TypeMLFlow = "mlflow"
92 96
 )
93 97
 
94 98
 // Qualifier represents a single key=value qualifier in the package url
... ...
@@ -283,7 +287,7 @@ func FromString(purl string) (PackageURL, error) {
283 283
 	remainder = nextSplit[1]
284 284
 
285 285
 	index = strings.LastIndex(remainder, "/")
286
-	name := typeAdjustName(purlType, remainder[index+1:])
286
+	name := typeAdjustName(purlType, remainder[index+1:], qualifiers)
287 287
 	version := ""
288 288
 
289 289
 	atIndex := strings.Index(name, "@")
... ...
@@ -292,7 +296,7 @@ func FromString(purl string) (PackageURL, error) {
292 292
 		if err != nil {
293 293
 			return PackageURL{}, fmt.Errorf("failed to unescape purl version: %s", err)
294 294
 		}
295
-		version = v
295
+		version = typeAdjustVersion(purlType, v)
296 296
 
297 297
 		unecapeName, err := url.PathUnescape(name[:atIndex])
298 298
 		if err != nil {
... ...
@@ -342,7 +346,7 @@ func FromString(purl string) (PackageURL, error) {
342 342
 // See https://github.com/package-url/purl-spec#known-purl-types
343 343
 func typeAdjustNamespace(purlType, ns string) string {
344 344
 	switch purlType {
345
-	case TypeBitbucket, TypeDebian, TypeGithub, TypeGolang, TypeNPM, TypeRPM:
345
+	case TypeBitbucket, TypeDebian, TypeGithub, TypeGolang, TypeNPM, TypeRPM, TypeComposer:
346 346
 		return strings.ToLower(ns)
347 347
 	}
348 348
 	return ns
... ...
@@ -350,16 +354,48 @@ func typeAdjustNamespace(purlType, ns string) string {
350 350
 
351 351
 // Make any purl type-specific adjustments to the parsed name.
352 352
 // See https://github.com/package-url/purl-spec#known-purl-types
353
-func typeAdjustName(purlType, name string) string {
353
+func typeAdjustName(purlType, name string, qualifiers Qualifiers) string {
354
+	quals := qualifiers.Map()
354 355
 	switch purlType {
355
-	case TypeBitbucket, TypeDebian, TypeGithub, TypeGolang, TypeNPM:
356
+	case TypeBitbucket, TypeDebian, TypeGithub, TypeGolang, TypeNPM, TypeComposer:
356 357
 		return strings.ToLower(name)
357 358
 	case TypePyPi:
358 359
 		return strings.ToLower(strings.ReplaceAll(name, "_", "-"))
360
+	case TypeMLFlow:
361
+		return adjustMlflowName(name, quals)
359 362
 	}
360 363
 	return name
361 364
 }
362 365
 
366
+// Make any purl type-specific adjustments to the parsed version.
367
+// See https://github.com/package-url/purl-spec#known-purl-types
368
+func typeAdjustVersion(purlType, version string) string {
369
+	switch purlType {
370
+	case TypeHuggingface:
371
+		return strings.ToLower(version)
372
+	}
373
+	return version
374
+}
375
+
376
+// https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#mlflow
377
+func adjustMlflowName(name string, qualifiers map[string]string) string {
378
+	if repo, ok := qualifiers["repository_url"]; ok {
379
+		if strings.Contains(repo, "azureml") {
380
+			// Azure ML is case-sensitive and must be kept as-is
381
+			return name
382
+		} else if strings.Contains(repo, "databricks") {
383
+			// Databricks is case-insensitive and must be lowercased
384
+			return strings.ToLower(name)
385
+		} else {
386
+			// Unknown repository type, keep as-is
387
+			return name
388
+		}
389
+	} else {
390
+		// No repository qualifier given, keep as-is
391
+		return name
392
+	}
393
+}
394
+
363 395
 // validQualifierKey validates a qualifierKey against our QualifierKeyPattern.
364 396
 func validQualifierKey(key string) bool {
365 397
 	return QualifierKeyPattern.MatchString(key)
... ...
@@ -755,7 +755,7 @@ github.com/mitchellh/hashstructure/v2
755 755
 # github.com/mitchellh/reflectwalk v1.0.2
756 756
 ## explicit
757 757
 github.com/mitchellh/reflectwalk
758
-# github.com/moby/buildkit v0.20.0-rc1.0.20250212151618-2f7007eec399
758
+# github.com/moby/buildkit v0.20.0-rc2
759 759
 ## explicit; go 1.22.0
760 760
 github.com/moby/buildkit/api/services/control
761 761
 github.com/moby/buildkit/api/types
... ...
@@ -1068,7 +1068,7 @@ github.com/opencontainers/runtime-tools/validate/capabilities
1068 1068
 github.com/opencontainers/selinux/go-selinux
1069 1069
 github.com/opencontainers/selinux/go-selinux/label
1070 1070
 github.com/opencontainers/selinux/pkg/pwalkdir
1071
-# github.com/package-url/packageurl-go v0.1.1-0.20220428063043-89078438f170
1071
+# github.com/package-url/packageurl-go v0.1.1
1072 1072
 ## explicit; go 1.17
1073 1073
 github.com/package-url/packageurl-go
1074 1074
 # github.com/pelletier/go-toml v1.9.5