image_import.go 736 B

123456789101112131415161718192021222324252627282930
  1. package client
  2. import (
  3. "io"
  4. "net/url"
  5. "golang.org/x/net/context"
  6. "github.com/docker/engine-api/types"
  7. )
  8. // ImageImport creates a new image based in the source options.
  9. // It returns the JSON content in the response body.
  10. func (cli *Client) ImageImport(ctx context.Context, options types.ImageImportOptions) (io.ReadCloser, error) {
  11. query := url.Values{}
  12. query.Set("fromSrc", options.SourceName)
  13. query.Set("repo", options.RepositoryName)
  14. query.Set("tag", options.Tag)
  15. query.Set("message", options.Message)
  16. for _, change := range options.Changes {
  17. query.Add("changes", change)
  18. }
  19. resp, err := cli.postRaw(ctx, "/images/create", query, options.Source, nil)
  20. if err != nil {
  21. return nil, err
  22. }
  23. return resp.body, nil
  24. }