mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 09:17:49 +08:00
build: forward all build opts everywhere
All build options should be passed everywhere - the frontend and the backend of buildkit should both be able to see all attestations, as well as all other opts: e.g. epoch settings, and no-cache. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
662738a7e5
commit
a8f689c223
@ -37,7 +37,6 @@ import (
|
||||
"github.com/moby/buildkit/client"
|
||||
"github.com/moby/buildkit/client/llb"
|
||||
"github.com/moby/buildkit/exporter/containerimage/exptypes"
|
||||
"github.com/moby/buildkit/frontend/attestations"
|
||||
gateway "github.com/moby/buildkit/frontend/gateway/client"
|
||||
"github.com/moby/buildkit/session"
|
||||
"github.com/moby/buildkit/session/upload/uploadprovider"
|
||||
@ -1113,11 +1112,13 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
|
||||
|
||||
req := gateway.SolveRequest{
|
||||
Frontend: so.Frontend,
|
||||
FrontendOpt: so.FrontendAttrs,
|
||||
FrontendInputs: frontendInputs,
|
||||
FrontendOpt: make(map[string]string),
|
||||
}
|
||||
for k, v := range so.FrontendAttrs {
|
||||
req.FrontendOpt[k] = v
|
||||
}
|
||||
so.Frontend = ""
|
||||
so.FrontendAttrs = attestations.Filter(so.FrontendAttrs)
|
||||
so.FrontendInputs = nil
|
||||
|
||||
ch, done := progress.NewChannel(pw)
|
||||
|
81
vendor/github.com/moby/buildkit/frontend/attestations/parse.go
generated
vendored
81
vendor/github.com/moby/buildkit/frontend/attestations/parse.go
generated
vendored
@ -1,81 +0,0 @@
|
||||
package attestations
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
KeyTypeSbom = "sbom"
|
||||
KeyTypeProvenance = "provenance"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultSBOMGenerator = "docker/buildkit-syft-scanner:stable-1"
|
||||
)
|
||||
|
||||
func Filter(v map[string]string) map[string]string {
|
||||
attests := make(map[string]string)
|
||||
for k, v := range v {
|
||||
if strings.HasPrefix(k, "attest:") {
|
||||
attests[k] = v
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(k, "build-arg:BUILDKIT_ATTEST_") {
|
||||
attests[k] = v
|
||||
continue
|
||||
}
|
||||
}
|
||||
return attests
|
||||
}
|
||||
|
||||
func Validate(values map[string]map[string]string) (map[string]map[string]string, error) {
|
||||
for k := range values {
|
||||
if k != KeyTypeSbom && k != KeyTypeProvenance {
|
||||
return nil, errors.Errorf("unknown attestation type %q", k)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
func Parse(values map[string]string) (map[string]map[string]string, error) {
|
||||
attests := make(map[string]string)
|
||||
for k, v := range values {
|
||||
if strings.HasPrefix(k, "attest:") {
|
||||
attests[strings.ToLower(strings.TrimPrefix(k, "attest:"))] = v
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(k, "build-arg:BUILDKIT_ATTEST_") {
|
||||
attests[strings.ToLower(strings.TrimPrefix(k, "build-arg:BUILDKIT_ATTEST_"))] = v
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
out := make(map[string]map[string]string)
|
||||
for k, v := range attests {
|
||||
attrs := make(map[string]string)
|
||||
out[k] = attrs
|
||||
if k == KeyTypeSbom {
|
||||
attrs["generator"] = defaultSBOMGenerator
|
||||
}
|
||||
if v == "" {
|
||||
continue
|
||||
}
|
||||
csvReader := csv.NewReader(strings.NewReader(v))
|
||||
fields, err := csvReader.Read()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to parse %s", k)
|
||||
}
|
||||
for _, field := range fields {
|
||||
parts := strings.SplitN(field, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
parts = append(parts, "")
|
||||
}
|
||||
attrs[parts[0]] = parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
return Validate(out)
|
||||
}
|
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
@ -448,7 +448,6 @@ github.com/moby/buildkit/client/ociindex
|
||||
github.com/moby/buildkit/cmd/buildkitd/config
|
||||
github.com/moby/buildkit/exporter/containerimage/exptypes
|
||||
github.com/moby/buildkit/exporter/containerimage/image
|
||||
github.com/moby/buildkit/frontend/attestations
|
||||
github.com/moby/buildkit/frontend/gateway/client
|
||||
github.com/moby/buildkit/frontend/gateway/grpcclient
|
||||
github.com/moby/buildkit/frontend/gateway/pb
|
||||
|
Loading…
x
Reference in New Issue
Block a user