|
|
@ -84,7 +84,7 @@ func getContainers(cmd *cobra.Command, toComplete string, cType completeType, st
|
|
|
|
containers, err := engine.ContainerList(registry.GetContext(), listOpts)
|
|
|
|
containers, err := engine.ContainerList(registry.GetContext(), listOpts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, c := range containers {
|
|
|
|
for _, c := range containers {
|
|
|
@ -119,7 +119,7 @@ func getPods(cmd *cobra.Command, toComplete string, cType completeType, statuses
|
|
|
|
pods, err := engine.PodPs(registry.GetContext(), listOpts)
|
|
|
|
pods, err := engine.PodPs(registry.GetContext(), listOpts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, pod := range pods {
|
|
|
|
for _, pod := range pods {
|
|
|
@ -149,7 +149,7 @@ func getVolumes(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellCom
|
|
|
|
volumes, err := engine.VolumeList(registry.GetContext(), lsOpts)
|
|
|
|
volumes, err := engine.VolumeList(registry.GetContext(), lsOpts)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, v := range volumes {
|
|
|
|
for _, v := range volumes {
|
|
|
@ -172,7 +172,7 @@ func getImages(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellComp
|
|
|
|
images, err := engine.List(registry.GetContext(), listOptions)
|
|
|
|
images, err := engine.List(registry.GetContext(), listOptions)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, image := range images {
|
|
|
|
for _, image := range images {
|
|
|
@ -215,7 +215,7 @@ func getRegistries() ([]string, cobra.ShellCompDirective) {
|
|
|
|
regs, err := registries.GetRegistries()
|
|
|
|
regs, err := registries.GetRegistries()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return regs, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
return regs, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -232,7 +232,7 @@ func getNetworks(cmd *cobra.Command, toComplete string) ([]string, cobra.ShellCo
|
|
|
|
networks, err := engine.NetworkList(registry.Context(), networkListOptions)
|
|
|
|
networks, err := engine.NetworkList(registry.Context(), networkListOptions)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, n := range networks {
|
|
|
|
for _, n := range networks {
|
|
|
@ -464,6 +464,18 @@ func AutocompleteCpCommand(cmd *cobra.Command, args []string, toComplete string)
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteNetworkConnectCmd - Autocomplete podman network connect/disconnect command args.
|
|
|
|
|
|
|
|
func AutocompleteNetworkConnectCmd(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
if len(args) == 0 {
|
|
|
|
|
|
|
|
return getNetworks(cmd, toComplete)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(args) == 1 {
|
|
|
|
|
|
|
|
return getContainers(cmd, toComplete, completeDefault)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// don't complete more than 2 args
|
|
|
|
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteSystemConnections - Autocomplete system connections.
|
|
|
|
// AutocompleteSystemConnections - Autocomplete system connections.
|
|
|
|
func AutocompleteSystemConnections(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
func AutocompleteSystemConnections(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
if !validCurrentCmdLine(cmd, args, toComplete) {
|
|
|
|
if !validCurrentCmdLine(cmd, args, toComplete) {
|
|
|
@ -473,7 +485,7 @@ func AutocompleteSystemConnections(cmd *cobra.Command, args []string, toComplete
|
|
|
|
cfg, err := config.ReadCustomConfig()
|
|
|
|
cfg, err := config.ReadCustomConfig()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for k, v := range cfg.Engine.ServiceDestinations {
|
|
|
|
for k, v := range cfg.Engine.ServiceDestinations {
|
|
|
@ -621,7 +633,8 @@ func AutocompleteUserFlag(cmd *cobra.Command, args []string, toComplete string)
|
|
|
|
// but at this point we don't know the image.
|
|
|
|
// but at this point we don't know the image.
|
|
|
|
file, err := os.Open("/etc/group")
|
|
|
|
file, err := os.Open("/etc/group")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
|
|
|
@ -637,7 +650,8 @@ func AutocompleteUserFlag(cmd *cobra.Command, args []string, toComplete string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err = scanner.Err(); err != nil {
|
|
|
|
if err = scanner.Err(); err != nil {
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return groups, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
return groups, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -646,7 +660,8 @@ func AutocompleteUserFlag(cmd *cobra.Command, args []string, toComplete string)
|
|
|
|
// but at this point we don't know the image.
|
|
|
|
// but at this point we don't know the image.
|
|
|
|
file, err := os.Open("/etc/passwd")
|
|
|
|
file, err := os.Open("/etc/passwd")
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
cobra.CompErrorln(err.Error())
|
|
|
|
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer file.Close()
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
|
|
|
@ -661,7 +676,7 @@ func AutocompleteUserFlag(cmd *cobra.Command, args []string, toComplete string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err = scanner.Err(); err != nil {
|
|
|
|
if err = scanner.Err(); err != nil {
|
|
|
|
return nil, cobra.ShellCompDirectiveError
|
|
|
|
return nil, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return users, cobra.ShellCompDirectiveNoSpace
|
|
|
|
return users, cobra.ShellCompDirectiveNoSpace
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -695,8 +710,22 @@ func AutocompleteJSONFormat(cmd *cobra.Command, args []string, toComplete string
|
|
|
|
// AutocompleteEventFilter - Autocomplete event filter flag options.
|
|
|
|
// AutocompleteEventFilter - Autocomplete event filter flag options.
|
|
|
|
// -> "container=", "event=", "image=", "pod=", "volume=", "type="
|
|
|
|
// -> "container=", "event=", "image=", "pod=", "volume=", "type="
|
|
|
|
func AutocompleteEventFilter(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
func AutocompleteEventFilter(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
filters := []string{"container=", "event=", "image=", "pod=", "volume=", "type="}
|
|
|
|
eventTypes := func(_ string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
return filters, cobra.ShellCompDirectiveNoSpace
|
|
|
|
return []string{"attach", "checkpoint", "cleanup", "commit", "create", "exec",
|
|
|
|
|
|
|
|
"export", "import", "init", "kill", "mount", "pause", "prune", "remove",
|
|
|
|
|
|
|
|
"restart", "restore", "start", "stop", "sync", "unmount", "unpause",
|
|
|
|
|
|
|
|
"pull", "push", "save", "tag", "untag", "refresh", "renumber",
|
|
|
|
|
|
|
|
}, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
kv := keyValueCompletion{
|
|
|
|
|
|
|
|
"container=": func(s string) ([]string, cobra.ShellCompDirective) { return getContainers(cmd, s, completeDefault) },
|
|
|
|
|
|
|
|
"image=": func(s string) ([]string, cobra.ShellCompDirective) { return getImages(cmd, s) },
|
|
|
|
|
|
|
|
"pod=": func(s string) ([]string, cobra.ShellCompDirective) { return getPods(cmd, s, completeDefault) },
|
|
|
|
|
|
|
|
"volume=": func(s string) ([]string, cobra.ShellCompDirective) { return getVolumes(cmd, s) },
|
|
|
|
|
|
|
|
"event=": eventTypes,
|
|
|
|
|
|
|
|
"type=": eventTypes,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteSystemdRestartOptions - Autocomplete systemd restart options.
|
|
|
|
// AutocompleteSystemdRestartOptions - Autocomplete systemd restart options.
|
|
|
@ -846,3 +875,47 @@ func AutocompletePodPsFilters(cmd *cobra.Command, args []string, toComplete stri
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteImageFilters - Autocomplete image ls --filter options.
|
|
|
|
|
|
|
|
func AutocompleteImageFilters(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
getBool := func(_ string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
return []string{"true", "false"}, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
getImg := func(s string) ([]string, cobra.ShellCompDirective) { return getImages(cmd, s) }
|
|
|
|
|
|
|
|
kv := keyValueCompletion{
|
|
|
|
|
|
|
|
"before=": getImg,
|
|
|
|
|
|
|
|
"since=": getImg,
|
|
|
|
|
|
|
|
"label=": nil,
|
|
|
|
|
|
|
|
"reference=": nil,
|
|
|
|
|
|
|
|
"dangling=": getBool,
|
|
|
|
|
|
|
|
"readonly=": getBool,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteNetworkFilters - Autocomplete network ls --filter options.
|
|
|
|
|
|
|
|
func AutocompleteNetworkFilters(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
kv := keyValueCompletion{
|
|
|
|
|
|
|
|
"name=": func(s string) ([]string, cobra.ShellCompDirective) { return getNetworks(cmd, s) },
|
|
|
|
|
|
|
|
"plugin=": nil,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AutocompleteVolumeFilters - Autocomplete volume ls --filter options.
|
|
|
|
|
|
|
|
func AutocompleteVolumeFilters(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
local := func(_ string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
return []string{"local"}, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
kv := keyValueCompletion{
|
|
|
|
|
|
|
|
"name=": func(s string) ([]string, cobra.ShellCompDirective) { return getVolumes(cmd, s) },
|
|
|
|
|
|
|
|
"driver=": local,
|
|
|
|
|
|
|
|
"scope=": local,
|
|
|
|
|
|
|
|
"label=": nil,
|
|
|
|
|
|
|
|
"opt=": nil,
|
|
|
|
|
|
|
|
"dangling=": func(_ string) ([]string, cobra.ShellCompDirective) {
|
|
|
|
|
|
|
|
return []string{"true", "false"}, cobra.ShellCompDirectiveNoFileComp
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return completeKeyValues(toComplete, kv)
|
|
|
|
|
|
|
|
}
|
|
|
|