container: explicitly set LocalName
Set the LocalName for the spec using a separate argument in the NewSpec() constructor instead of reusing the `source` arg. The name is already available in the calling scope in the client's Resolve() method. If the LocalName is an empty string, default to the remote (source) reference. This is a change from the previous behaviour which only used the base source.Name(). The full source corresponds to the user-provided source value, which includes any specified tag or digest. The `name` argument which is used in the `Resolve()` function should always correspond to the user-provided container name.
This commit is contained in:
parent
8b1375bee0
commit
f9e3d8659d
2 changed files with 7 additions and 5 deletions
|
|
@ -500,7 +500,7 @@ func (cl *Client) Resolve(ctx context.Context, name string) (Spec, error) {
|
|||
return Spec{}, err
|
||||
}
|
||||
|
||||
spec := NewSpec(cl.Target, ids.Manifest, ids.Config, cl.GetTLSVerify(), ids.ListManifest.String())
|
||||
spec := NewSpec(cl.Target, ids.Manifest, ids.Config, cl.GetTLSVerify(), ids.ListManifest.String(), name)
|
||||
|
||||
return spec, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,16 @@ type Spec struct {
|
|||
// NewSpec creates a new Spec from the essential information.
|
||||
// It also converts is the transition point from container
|
||||
// specific types (digest.Digest) to generic types (string).
|
||||
func NewSpec(source reference.Named, digest, imageID digest.Digest, tlsVerify *bool, listDigest string) Spec {
|
||||
name := source.Name()
|
||||
func NewSpec(source reference.Named, digest, imageID digest.Digest, tlsVerify *bool, listDigest string, localName string) Spec {
|
||||
if localName == "" {
|
||||
localName = source.String()
|
||||
}
|
||||
return Spec{
|
||||
Source: name,
|
||||
Source: source.Name(),
|
||||
Digest: digest.String(),
|
||||
TLSVerify: tlsVerify,
|
||||
ImageID: imageID.String(),
|
||||
LocalName: name,
|
||||
LocalName: localName,
|
||||
ListDigest: listDigest,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue