MCPcopy
hub / github.com/lxc/incus / getSourceImageConnectionInfo

Method getSourceImageConnectionInfo

client/incus.go:547–590  ·  view source on GitHub ↗

getSourceImageConnectionInfo returns the connection information for the source image. The returned `info` is nil if the source image is local. In this process, the `instSrc` is also updated with the minimal source fields.

(source ImageServer, image api.Image, instSrc *api.InstanceSource)

Source from the content-addressed store, hash-verified

545// The returned `info` is nil if the source image is local. In this process, the `instSrc`
546// is also updated with the minimal source fields.
547func (r *ProtocolIncus) getSourceImageConnectionInfo(source ImageServer, image api.Image, instSrc *api.InstanceSource) (info *ConnectionInfo, err error) {
548 // Set the minimal source fields
549 instSrc.Type = "image"
550
551 // Optimization for the local image case
552 if r.isSameServer(source) {
553 // Always use fingerprints for local case
554 instSrc.Fingerprint = image.Fingerprint
555 instSrc.Alias = ""
556 return nil, nil
557 }
558
559 // Minimal source fields for remote image
560 instSrc.Mode = "pull"
561
562 // If we have an alias and the image is public, use that
563 if instSrc.Alias != "" && image.Public {
564 instSrc.Fingerprint = ""
565 } else {
566 instSrc.Fingerprint = image.Fingerprint
567 instSrc.Alias = ""
568 }
569
570 // Get source server connection information
571 info, err = source.GetConnectionInfo()
572 if err != nil {
573 return nil, err
574 }
575
576 instSrc.Protocol = info.Protocol
577 instSrc.Certificate = info.Certificate
578
579 // Generate secret token if needed
580 if !image.Public {
581 secret, err := source.GetImageSecret(image.Fingerprint)
582 if err != nil {
583 return nil, err
584 }
585
586 instSrc.Secret = secret
587 }
588
589 return info, nil
590}

Callers 2

Calls 3

isSameServerMethod · 0.95
GetConnectionInfoMethod · 0.65
GetImageSecretMethod · 0.65

Tested by

no test coverage detected