(task *task.Task, client *client.Client, imageName string)
| 1746 | } |
| 1747 | |
| 1748 | func pullImages(task *task.Task, client *client.Client, imageName string) error { |
| 1749 | dockerCli := docker.NewClientWithExist(client) |
| 1750 | options := image.PullOptions{} |
| 1751 | repos, _ := imageRepoRepo.List() |
| 1752 | if len(repos) != 0 { |
| 1753 | for _, repo := range repos { |
| 1754 | if strings.HasPrefix(imageName, repo.DownloadUrl) && repo.Auth { |
| 1755 | authConfig := registry.AuthConfig{ |
| 1756 | Username: repo.Username, |
| 1757 | Password: repo.Password, |
| 1758 | } |
| 1759 | encodedJSON, err := json.Marshal(authConfig) |
| 1760 | if err != nil { |
| 1761 | return err |
| 1762 | } |
| 1763 | authStr := base64.URLEncoding.EncodeToString(encodedJSON) |
| 1764 | options.RegistryAuth = authStr |
| 1765 | } |
| 1766 | } |
| 1767 | } else { |
| 1768 | hasAuth, authStr := loadAuthInfo(imageName) |
| 1769 | if hasAuth { |
| 1770 | options.RegistryAuth = authStr |
| 1771 | } |
| 1772 | } |
| 1773 | return dockerCli.PullImageWithProcessAndOptions(task, imageName, options) |
| 1774 | } |
| 1775 | |
| 1776 | func loadCpuAndMem(client *client.Client, containerItem string) dto.ContainerListStats { |
| 1777 | data := dto.ContainerListStats{ |
no test coverage detected