Skip to content

Commit d304ec7

Browse files
committed
incus: Fix completion for image alias create
When there was no remote part in the alias, remote names was included in the fingerprint completions which was wrong. Signed-off-by: montag451 <[email protected]>
1 parent 2203d80 commit d304ec7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmd/incus/image_alias.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,17 @@ func (c *cmdImageAliasCreate) Command() *cobra.Command {
8282
}
8383

8484
fingerprints, directives := c.global.cmpImageFingerprints(toComplete)
85-
for i, f := range fingerprints {
86-
fingerprints[i], _ = strings.CutPrefix(f, remote+":")
85+
fingerprintsNoRemote := make([]string, 0, len(fingerprints))
86+
for _, f := range fingerprints {
87+
if strings.HasSuffix(f, ":") {
88+
continue
89+
}
90+
91+
f, _ = strings.CutPrefix(f, remote+":")
92+
fingerprintsNoRemote = append(fingerprintsNoRemote, f)
8793
}
8894

89-
return fingerprints, directives
95+
return fingerprintsNoRemote, directives &^ cobra.ShellCompDirectiveNoSpace
9096
}
9197

9298
return cmd

0 commit comments

Comments
 (0)