| 47 | } |
| 48 | |
| 49 | func (d Docker) Pull(ctx context.Context, image, user, password string) (string, error) { |
| 50 | authConfig := types.AuthConfig{ |
| 51 | Username: user, |
| 52 | Password: password, |
| 53 | } |
| 54 | encodedJSON, err := json.Marshal(authConfig) |
| 55 | if err != nil { |
| 56 | return "", err |
| 57 | } |
| 58 | |
| 59 | authStr := base64.URLEncoding.EncodeToString(encodedJSON) |
| 60 | reader, err := d.client.ImagePull(ctx, image, types.ImagePullOptions{RegistryAuth: authStr}) |
| 61 | if err != nil { |
| 62 | return "", err |
| 63 | } |
| 64 | buf := new(bytes.Buffer) |
| 65 | _, _ = buf.ReadFrom(reader) |
| 66 | return buf.String(), nil |
| 67 | } |
| 68 | |
| 69 | func (d Docker) Import(ctx context.Context, file string, image string) (string, error) { |
| 70 | f, err := os.Open(file) |