Skip to content

Commit

Permalink
client: Fix image aliases in relay mode
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Nov 22, 2024
1 parent 33c9a8e commit 333c349
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/incus_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ func (r *ProtocolIncus) CopyImage(source ImageServer, image api.Image, args *Ima
imagePost.Public = args.Public
imagePost.Profiles = image.Profiles

imagePost.Aliases = args.Aliases
if args.CopyAliases {
imagePost.Aliases = image.Aliases
if args.Aliases != nil {
Expand Down Expand Up @@ -880,6 +881,19 @@ func (r *ProtocolIncus) CopyImage(source ImageServer, image api.Image, args *Ima
rop.err = remoteOperationError("Failed to copy image", nil)
return
}

// Apply the aliases.
for _, entry := range imagePost.Aliases {
alias := api.ImageAliasesPost{}
alias.Name = entry.Name
alias.Target = image.Fingerprint

err := r.CreateImageAlias(alias)
if err != nil {
rop.err = remoteOperationError("Failed to add alias", nil)
return
}
}
}()

return &rop, nil
Expand Down

0 comments on commit 333c349

Please sign in to comment.