mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 13:11:30 +00:00
Move docker build to client
This commit is contained in:
@@ -140,8 +140,10 @@ func (srv *Server) ImagesViz(out io.Writer) error {
|
||||
}
|
||||
|
||||
func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
|
||||
var allImages map[string]*Image
|
||||
var err error
|
||||
var (
|
||||
allImages map[string]*Image
|
||||
err error
|
||||
)
|
||||
if all {
|
||||
allImages, err = srv.runtime.graph.Map()
|
||||
} else {
|
||||
@@ -150,7 +152,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var outs []ApiImages = []ApiImages{} //produce [] when empty instead of 'null'
|
||||
outs := []ApiImages{} //produce [] when empty instead of 'null'
|
||||
for name, repository := range srv.runtime.repositories.Repositories {
|
||||
if filter != "" && name != filter {
|
||||
continue
|
||||
@@ -653,15 +655,6 @@ func (srv *Server) ContainerCreate(config *Config) (string, error) {
|
||||
return container.ShortId(), nil
|
||||
}
|
||||
|
||||
func (srv *Server) ImageCreateFromFile(dockerfile io.Reader, out io.Writer) error {
|
||||
img, err := NewBuilder(srv.runtime).Build(dockerfile, out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(out, "%s\n", img.ShortId())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) ContainerRestart(name string, t int) error {
|
||||
if container := srv.runtime.Get(name); container != nil {
|
||||
if err := container.Restart(t); err != nil {
|
||||
@@ -722,6 +715,36 @@ func (srv *Server) ImageDelete(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) ImageGetCached(imgId string, config *Config) (*Image, error) {
|
||||
|
||||
// Retrieve all images
|
||||
images, err := srv.runtime.graph.All()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Store the tree in a map of map (map[parentId][childId])
|
||||
imageMap := make(map[string]map[string]struct{})
|
||||
for _, img := range images {
|
||||
if _, exists := imageMap[img.Parent]; !exists {
|
||||
imageMap[img.Parent] = make(map[string]struct{})
|
||||
}
|
||||
imageMap[img.Parent][img.Id] = struct{}{}
|
||||
}
|
||||
|
||||
// Loop on the children of the given image and check the config
|
||||
for elem := range imageMap[imgId] {
|
||||
img, err := srv.runtime.graph.Get(elem)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if CompareConfig(&img.ContainerConfig, config) {
|
||||
return img, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (srv *Server) ContainerStart(name string) error {
|
||||
if container := srv.runtime.Get(name); container != nil {
|
||||
if err := container.Start(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user