// Get retrieves the manifest with digest `dgst`. func (r *repository) Get(ctx context.Context, dgst digest.Digest, options ...distribution.ManifestServiceOption) (distribution.Manifest, error) { if err := r.checkPendingErrors(ctx); err != nil { return nil, err } if _, err := r.getImageStreamImage(dgst); err != nil { context.GetLogger(r.ctx).Errorf("error retrieving ImageStreamImage %s/%s@%s: %v", r.namespace, r.name, dgst.String(), err) return nil, err } image, err := r.getImage(dgst) if err != nil { context.GetLogger(r.ctx).Errorf("error retrieving image %s: %v", dgst.String(), err) return nil, err } ref := imageapi.DockerImageReference{Namespace: r.namespace, Name: r.name, Registry: r.registryAddr} if managed := image.Annotations[imageapi.ManagedByOpenShiftAnnotation]; managed == "true" { // Repository without a registry part is refers to repository containing locally managed images. // Such an entry is retrieved, checked and set by blobDescriptorService operating only on local blobs. ref.Registry = "" } else { // Repository with a registry points to remote repository. This is used by pullthrough middleware. ref = ref.DockerClientDefaults().AsRepository() } manifest, err := r.manifestFromImageWithCachedLayers(image, ref.Exact()) return manifest, err }
func autoConvert_v1_DockerImageReference_To_api_DockerImageReference(in *DockerImageReference, out *api.DockerImageReference, s conversion.Scope) error { out.Registry = in.Registry out.Namespace = in.Namespace out.Name = in.Name out.Tag = in.Tag out.ID = in.ID return nil }
func autoConvert_v1_DockerImageReference_To_api_DockerImageReference(in *DockerImageReference, out *image_api.DockerImageReference, s conversion.Scope) error { if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found { defaulting.(func(*DockerImageReference))(in) } out.Registry = in.Registry out.Namespace = in.Namespace out.Name = in.Name out.Tag = in.Tag out.ID = in.ID return nil }
// Search searches in the Docker registry for images that match terms func (r DockerRegistrySearcher) Search(precise bool, terms ...string) (ComponentMatches, []error) { componentMatches := ComponentMatches{} var errs []error for _, term := range terms { var ( ref imageapi.DockerImageReference err error ) if term != "*" { ref, err = imageapi.ParseDockerImageReference(term) if err != nil { continue } } else { ref = imageapi.DockerImageReference{Name: term} } glog.V(4).Infof("checking Docker registry for %q, allow-insecure=%v", ref.String(), r.AllowInsecure) connection, err := r.Client.Connect(ref.Registry, r.AllowInsecure) if err != nil { if dockerregistry.IsRegistryNotFound(err) { errs = append(errs, err) continue } errs = append(errs, fmt.Errorf("can't connect to %q: %v", ref.Registry, err)) continue } image, err := connection.ImageByTag(ref.Namespace, ref.Name, ref.Tag) if err != nil { if dockerregistry.IsNotFound(err) { if dockerregistry.IsTagNotFound(err) { glog.V(4).Infof("tag not found: %v", err) } continue } errs = append(errs, fmt.Errorf("can't connect to %q: %v", ref.Registry, err)) continue } if len(ref.Tag) == 0 { ref.Tag = imageapi.DefaultImageTag } if len(ref.Registry) == 0 { ref.Registry = "Docker Hub" } glog.V(4).Infof("found image: %#v", image) dockerImage := &imageapi.DockerImage{} if err = kapi.Scheme.Convert(&image.Image, dockerImage, nil); err != nil { errs = append(errs, err) continue } match := &ComponentMatch{ Value: term, Argument: fmt.Sprintf("--docker-image=%q", term), Name: term, Description: descriptionFor(dockerImage, term, ref.Registry, ref.Tag), Score: 0, Image: dockerImage, ImageTag: ref.Tag, Insecure: r.AllowInsecure, Meta: map[string]string{"registry": ref.Registry}, } glog.V(2).Infof("Adding %s as component match for %q with score %v", match.Description, term, match.Score) componentMatches = append(componentMatches, match) } return componentMatches, errs }