MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / pullImages

Function pullImages

agent/app/service/container.go:1748–1774  ·  view source on GitHub ↗
(task *task.Task, client *client.Client, imageName string)

Source from the content-addressed store, hash-verified

1746}
1747
1748func 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
1776func loadCpuAndMem(client *client.Client, containerItem string) dto.ContainerListStats {
1777 data := dto.ContainerListStats{

Callers 4

stepRecreateContainerFunction · 0.85
ContainerCreateMethod · 0.85
ContainerUpdateMethod · 0.85
ContainerUpgradeMethod · 0.85

Calls 3

loadAuthInfoFunction · 0.85
ListMethod · 0.65

Tested by

no test coverage detected