mirror of https://github.com/docker/buildx.git
				
				
				
			build: avoid compatability error when attestations disabled
We should avoid erroring with attestations support compatability errors when a user has specified --provenance=false. A user may wish to enable --provenance=false that works across buildkit versions, but currently it will fail on old versions - this patch fixes this, to silently ignore the provenance flag for this check if it's set to disabled. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
		
							parent
							
								
									fb27e3f919
								
							
						
					
					
						commit
						15a80b56b5
					
				| 
						 | 
				
			
			@ -588,18 +588,22 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if len(opt.Attests) > 0 {
 | 
			
		||||
		if !bopts.LLBCaps.Contains(apicaps.CapID("exporter.image.attestations")) {
 | 
			
		||||
			return nil, nil, errors.Errorf("attestations are not supported by the current buildkitd")
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range opt.Attests {
 | 
			
		||||
			if v == nil {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
			so.FrontendAttrs[k] = *v
 | 
			
		||||
	attests := make(map[string]string)
 | 
			
		||||
	for k, v := range opt.Attests {
 | 
			
		||||
		if v != nil {
 | 
			
		||||
			attests[k] = *v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if _, ok := opt.Attests["attest:provenance"]; !ok {
 | 
			
		||||
	supportsAttestations := bopts.LLBCaps.Contains(apicaps.CapID("exporter.image.attestations"))
 | 
			
		||||
	if len(attests) > 0 {
 | 
			
		||||
		if !supportsAttestations {
 | 
			
		||||
			return nil, nil, errors.Errorf("attestations are not supported by the current buildkitd")
 | 
			
		||||
		}
 | 
			
		||||
		for k, v := range attests {
 | 
			
		||||
			so.FrontendAttrs[k] = v
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if _, ok := opt.Attests["attest:provenance"]; !ok && supportsAttestations {
 | 
			
		||||
		so.FrontendAttrs["attest:provenance"] = "mode=min,inline-only=true"
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue