Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Add support import#98

Merged
aluzzardi merged 3 commits into
samalba:masterfrom
jimmyxian:add-import
May 5, 2015
Merged

Add support import#98
aluzzardi merged 3 commits into
samalba:masterfrom
jimmyxian:add-import

Conversation

@jimmyxian

Copy link
Copy Markdown

Implement swarm import (issue: docker-archive/classicswarm#631), need this interface
Test code:

package main

import (
    "github.com/samalba/dockerclient"
    "os"
    "fmt"
    "io/ioutil"
)

func main() {
    // Init the client
    docker, _ := dockerclient.NewDockerClient("unix:///var/run/docker.sock", nil)

    file, _ := os.Open("/home/busybox.tar")
    reader, _ := docker.ImportImage("", "mybusybox", "abc", file)

    data, _ := ioutil.ReadAll(reader)
    fmt.Printf("%s", data)
}

Test Result:

[root@localhost samalba]# go run test.go 
{"status":"b14b8a22f2e03d1ac7c4dff8ce73fc763ec158dcfbc86fcc9090a205b5e4bc69"}
[root@localhost samalba]# 
[root@localhost samalba]# docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
mybusybox                          abc                 b14b8a22f2e0        3 seconds ago       2.43 MB

Signed-off-by: Xian Chaobo xianchaobo@huawei.com

Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
@jimmyxian

Copy link
Copy Markdown
Author

ping @vieux @ehazlett @aluzzardi

Comment thread dockerclient.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this and doRequest? Can the two be refactored so they share most of the same code?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doStreamRequest: the input and output is using io.Reader and io.Writer. it can work streamly.
doRequest: the input and output is byte[]. if we send a request, we have to wait all the response. it can not work streamly.

Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
@jimmyxian

Copy link
Copy Markdown
Author

ping @aluzzardi
Updated by the comments

Comment thread dockerclient.go Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use nil instead of []byte{}?

@donhcd

donhcd commented May 1, 2015

Copy link
Copy Markdown
Collaborator

LGTM after addressing nit

Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
@jimmyxian

Copy link
Copy Markdown
Author

ping @donhcd @aluzzardi
Modified it and check again,thks

@donhcd

donhcd commented May 4, 2015

Copy link
Copy Markdown
Collaborator

👍

@donhcd

donhcd commented May 4, 2015

Copy link
Copy Markdown
Collaborator

ping @vieux @abronan @aluzzardi @ehazlett

@aluzzardi

Copy link
Copy Markdown
Collaborator

LGTM

aluzzardi added a commit that referenced this pull request May 5, 2015
@aluzzardi aluzzardi merged commit 9f98218 into samalba:master May 5, 2015
@vieux

vieux commented May 5, 2015

Copy link
Copy Markdown
Contributor

LGTM

@jimmyxian jimmyxian deleted the add-import branch May 12, 2015 12:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants