1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package network
import (
"github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/spf13/cobra"
)
var (
networkExistsDescription = `If the named network exists, podman network exists exits with 0, otherwise the exit code will be 1.`
networkExistsCommand = &cobra.Command{
Use: "exists NETWORK",
Short: "network exists",
Long: networkExistsDescription,
RunE: networkExists,
Example: `podman network exists net1`,
Args: cobra.ExactArgs(1),
ValidArgsFunction: common.AutocompleteNetworks,
}
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: networkExistsCommand,
Parent: networkCmd,
})
}
func networkExists(cmd *cobra.Command, args []string) error {
response, err := registry.ContainerEngine().NetworkExists(registry.GetContext(), args[0])
if err != nil {
return err
}
if !response.Value {
registry.SetExitCode(1)
}
return nil
}
|