mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 18:13:42 +08:00 
			
		
		
		
	full diff: -36ef4d8c0d...f098008783-d5c1d785b0...5ae9b23c40Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package pb
 | 
						|
 | 
						|
import (
 | 
						|
	ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
 | 
						|
)
 | 
						|
 | 
						|
func (p *Platform) Spec() ocispecs.Platform {
 | 
						|
	result := ocispecs.Platform{
 | 
						|
		OS:           p.OS,
 | 
						|
		Architecture: p.Architecture,
 | 
						|
		Variant:      p.Variant,
 | 
						|
		OSVersion:    p.OSVersion,
 | 
						|
	}
 | 
						|
	if p.OSFeatures != nil {
 | 
						|
		result.OSFeatures = append([]string{}, p.OSFeatures...)
 | 
						|
	}
 | 
						|
	return result
 | 
						|
}
 | 
						|
 | 
						|
func PlatformFromSpec(p ocispecs.Platform) Platform {
 | 
						|
	result := Platform{
 | 
						|
		OS:           p.OS,
 | 
						|
		Architecture: p.Architecture,
 | 
						|
		Variant:      p.Variant,
 | 
						|
		OSVersion:    p.OSVersion,
 | 
						|
	}
 | 
						|
	if p.OSFeatures != nil {
 | 
						|
		result.OSFeatures = append([]string{}, p.OSFeatures...)
 | 
						|
	}
 | 
						|
	return result
 | 
						|
}
 | 
						|
 | 
						|
func ToSpecPlatforms(p []Platform) []ocispecs.Platform {
 | 
						|
	out := make([]ocispecs.Platform, 0, len(p))
 | 
						|
	for _, pp := range p {
 | 
						|
		out = append(out, pp.Spec())
 | 
						|
	}
 | 
						|
	return out
 | 
						|
}
 | 
						|
 | 
						|
func PlatformsFromSpec(p []ocispecs.Platform) []Platform {
 | 
						|
	out := make([]Platform, 0, len(p))
 | 
						|
	for _, pp := range p {
 | 
						|
		out = append(out, PlatformFromSpec(pp))
 | 
						|
	}
 | 
						|
	return out
 | 
						|
}
 |