MCPcopy Create free account
hub / github.com/conforma/cli / resolveAndSetImageUrl

Function resolveAndSetImageUrl

internal/image/validate.go:204–228  ·  view source on GitHub ↗
(ctx context.Context, url string, asi *application_snapshot_image.ApplicationSnapshotImage)

Source from the content-addressed store, hash-verified

202}
203
204func resolveAndSetImageUrl(ctx context.Context, url string, asi *application_snapshot_image.ApplicationSnapshotImage) (string, error) {
205 // Ensure image URL contains a digest to avoid ambiguity in the next
206 // validation steps
207 ref, err := ParseAndResolve(ctx, url)
208 if err != nil {
209 log.Debugf("Failed to parse image url %s", url)
210 return "", err
211 }
212 // The original image reference may or may not have had a tag. If it didn't,
213 // the code above will set the tag to "latest". This is expected in some cases,
214 // e.g. image ref also does not include digest. However, in other cases, although
215 // harmless, it may cause confusion to users. The tag is cleared here to prevent
216 // such confusion and to further emphasize that the image is only accessed by digest
217 // from this point forward.
218 ref.Tag = ""
219 resolved := ref.String()
220 log.Debugf("Resolved image to %s", resolved)
221
222 if err := asi.SetImageURL(resolved); err != nil {
223 log.Debugf("Failed to set resolved image url %s", resolved)
224 return "", err
225 }
226
227 return resolved, nil
228}
229
230func determineAttestationTime(ctx context.Context, attestations []attestation.Attestation) *time.Time {
231 if len(attestations) == 0 {

Callers 1

ValidateImageFunction · 0.85

Calls 3

ParseAndResolveFunction · 0.85
SetImageURLMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected