(ctx context.Context, instanceDigest *digest.Digest)
| 175 | } |
| 176 | |
| 177 | func (s *blobCacheSource) LayerInfosForCopy(ctx context.Context, instanceDigest *digest.Digest) ([]types.BlobInfo, error) { |
| 178 | signatures, err := s.source.GetSignaturesWithFormat(ctx, instanceDigest) |
| 179 | if err != nil { |
| 180 | return nil, fmt.Errorf("error checking if image %q has signatures: %w", transports.ImageName(s.reference), err) |
| 181 | } |
| 182 | canReplaceBlobs := len(signatures) == 0 |
| 183 | |
| 184 | infos, err := s.source.LayerInfosForCopy(ctx, instanceDigest) |
| 185 | if err != nil { |
| 186 | return nil, fmt.Errorf("error getting layer infos for copying image %q through cache: %w", transports.ImageName(s.reference), err) |
| 187 | } |
| 188 | if infos == nil { |
| 189 | img, err := image.FromUnparsedImage(ctx, &s.sys, image.UnparsedInstance(s.source, instanceDigest)) |
| 190 | if err != nil { |
| 191 | return nil, fmt.Errorf("error opening image to get layer infos for copying image %q through cache: %w", transports.ImageName(s.reference), err) |
| 192 | } |
| 193 | infos = img.LayerInfos() |
| 194 | } |
| 195 | |
| 196 | if canReplaceBlobs && s.reference.compress != types.PreserveOriginal { |
| 197 | replacedInfos := make([]types.BlobInfo, 0, len(infos)) |
| 198 | for _, info := range infos { |
| 199 | info, err = s.layerInfoForCopy(info) |
| 200 | if err != nil { |
| 201 | return nil, err |
| 202 | } |
| 203 | replacedInfos = append(replacedInfos, info) |
| 204 | } |
| 205 | infos = replacedInfos |
| 206 | } |
| 207 | |
| 208 | return infos, nil |
| 209 | } |
| 210 | |
| 211 | // SupportsGetBlobAt() returns true if GetBlobAt (BlobChunkAccessor) is supported. |
| 212 | func (s *blobCacheSource) SupportsGetBlobAt() bool { |
nothing calls this directly
no test coverage detected