mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 08:56:05 +08:00 
			
		
		
		
	In #20538, I was asked to consider refactoring the new OCI pull code from within the generic machine directory. This is something I had tried when originally coding it but it became apparent that a much larger refactor to prevent circular deps was needed. Because I did not want to pollute the initial PR with that refactor, I asked for the PR to merge first. This is the refactor that needed to be done. Signed-off-by: Brent Baude <bbaude@redhat.com>
		
			
				
	
	
		
			37 lines
		
	
	
		
			520 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			520 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package compression
 | 
						|
 | 
						|
import "strings"
 | 
						|
 | 
						|
type ImageCompression int64
 | 
						|
 | 
						|
const (
 | 
						|
	Xz ImageCompression = iota
 | 
						|
	Zip
 | 
						|
	Gz
 | 
						|
	Bz2
 | 
						|
)
 | 
						|
 | 
						|
func KindFromFile(path string) ImageCompression {
 | 
						|
	switch {
 | 
						|
	case strings.HasSuffix(path, Bz2.String()):
 | 
						|
		return Bz2
 | 
						|
	case strings.HasSuffix(path, Gz.String()):
 | 
						|
		return Gz
 | 
						|
	case strings.HasSuffix(path, Zip.String()):
 | 
						|
		return Zip
 | 
						|
	}
 | 
						|
	return Xz
 | 
						|
}
 | 
						|
 | 
						|
func (c ImageCompression) String() string {
 | 
						|
	switch c {
 | 
						|
	case Gz:
 | 
						|
		return "gz"
 | 
						|
	case Zip:
 | 
						|
		return "zip"
 | 
						|
	case Bz2:
 | 
						|
		return "bz2"
 | 
						|
	}
 | 
						|
	return "xz"
 | 
						|
}
 |