(ctx context.Context, input NewDockerPullExecutorInput)
| 76 | } |
| 77 | |
| 78 | func getImagePullOptions(ctx context.Context, input NewDockerPullExecutorInput) (client.ImagePullOptions, error) { |
| 79 | imagePullOptions := client.ImagePullOptions{} |
| 80 | if input.Platform != "" { |
| 81 | parts := strings.SplitN(input.Platform, "/", 2) |
| 82 | if len(parts) == 2 { |
| 83 | imagePullOptions.Platforms = []specs.Platform{{OS: parts[0], Architecture: parts[1]}} |
| 84 | } |
| 85 | } |
| 86 | logger := common.Logger(ctx) |
| 87 | |
| 88 | if input.Username != "" && input.Password != "" { |
| 89 | logger.Debugf("using authentication for docker pull") |
| 90 | |
| 91 | authConfig := registry.AuthConfig{ |
| 92 | Username: input.Username, |
| 93 | Password: input.Password, |
| 94 | } |
| 95 | |
| 96 | encodedJSON, err := json.Marshal(authConfig) |
| 97 | if err != nil { |
| 98 | return imagePullOptions, err |
| 99 | } |
| 100 | |
| 101 | imagePullOptions.RegistryAuth = base64.URLEncoding.EncodeToString(encodedJSON) |
| 102 | } else { |
| 103 | authConfig, err := LoadDockerAuthConfig(ctx, input.Image) |
| 104 | if err != nil { |
| 105 | return imagePullOptions, err |
| 106 | } |
| 107 | if authConfig.Username == "" && authConfig.Password == "" { |
| 108 | return imagePullOptions, nil |
| 109 | } |
| 110 | logger.Info("using DockerAuthConfig authentication for docker pull") |
| 111 | |
| 112 | encodedJSON, err := json.Marshal(authConfig) |
| 113 | if err != nil { |
| 114 | return imagePullOptions, err |
| 115 | } |
| 116 | |
| 117 | imagePullOptions.RegistryAuth = base64.URLEncoding.EncodeToString(encodedJSON) |
| 118 | } |
| 119 | |
| 120 | return imagePullOptions, nil |
| 121 | } |
| 122 | |
| 123 | func cleanImage(ctx context.Context, image string) string { |
| 124 | ref, err := reference.ParseAnyReference(image) |
searching dependent graphs…