feat: implement container import
This commit is contained in:
		
							
								
								
									
										5
									
								
								cache/cache.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								cache/cache.go
									
									
									
									
										vendored
									
									
								
							| @@ -118,3 +118,8 @@ func PackageURL(dt distro.ID, orig string) (found bool, fileurl string) { | |||||||
| 	found = true | 	found = true | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func ContainerURL(name string) (path string) { | ||||||
|  | 	path, _ = url.JoinPath(URL, "containers", fmt.Sprintf("%s.tar.gz", name)) | ||||||
|  | 	return | ||||||
|  | } | ||||||
|   | |||||||
| @@ -79,6 +79,24 @@ func Images() (diis []Image, err error) { | |||||||
| 	return | 	return | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func Import(path, name string) (err error) { | ||||||
|  | 	exist := Container{name: name}.Exist() | ||||||
|  | 	if exist && UseCache { | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	cmd := exec.Command(Runtime, "import", path, name) | ||||||
|  | 	log.Debug().Msgf("%v", cmd) | ||||||
|  |  | ||||||
|  | 	raw, err := cmd.CombinedOutput() | ||||||
|  | 	if err != nil { | ||||||
|  | 		log.Error().Err(err).Msg(string(raw)) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  |  | ||||||
| type Volume struct { | type Volume struct { | ||||||
| 	Src, Dest string | 	Src, Dest string | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user