Merge pull request #2339 from mtrmac/tarball-autocomplete

Don't offer the tarball: transport in completions
This commit is contained in:
Daniel J Walsh 2024-05-28 09:59:17 -04:00 committed by GitHub
commit 08e80b74a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,7 @@
package main
import (
"github.com/containers/image/v5/tarball"
"github.com/containers/image/v5/transports"
"github.com/spf13/cobra"
)
@ -10,7 +11,12 @@ func autocompleteSupportedTransports(cmd *cobra.Command, args []string, toComple
tps := transports.ListNames()
suggestions := make([]string, 0, len(tps))
for _, tp := range tps {
suggestions = append(suggestions, tp+":")
// ListNames is generally expected to filter out deprecated transports.
// tarball: is not deprecated, but it is only usable from a Go caller (using tarball.ConfigUpdater),
// so dont offer it on the CLI.
if tp != tarball.Transport.Name() {
suggestions = append(suggestions, tp+":")
}
}
return suggestions, cobra.ShellCompDirectiveNoFileComp
}