Don't require engine connection for farm

Don't require the need to connect to an engine/podman
machine when doing the farm create, ls, rm, and update
commands.
Connection to the engine is required for the farm build
command.

[NO NEW TESTS NEEDED]

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
This commit is contained in:
Urvashi Mohnani
2024-01-29 11:22:51 -05:00
parent 2ba3605108
commit 3136f0fca0
4 changed files with 36 additions and 25 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/validate"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
@ -16,12 +17,14 @@ var (
The "podman system connection add --farm" command can be used to add a new connection to a new or existing farm.` The "podman system connection add --farm" command can be used to add a new connection to a new or existing farm.`
createCommand = &cobra.Command{ createCommand = &cobra.Command{
Use: "create NAME [CONNECTIONS...]", Use: "create NAME [CONNECTIONS...]",
Args: cobra.MinimumNArgs(1), Args: cobra.MinimumNArgs(1),
Short: "Create a new farm", Short: "Create a new farm",
Long: farmCreateDescription, Long: farmCreateDescription,
RunE: create, PersistentPreRunE: validate.NoOp,
ValidArgsFunction: completion.AutocompleteNone, RunE: create,
PersistentPostRunE: validate.NoOp,
ValidArgsFunction: completion.AutocompleteNone,
Example: `podman farm create myfarm connection1 Example: `podman farm create myfarm connection1
podman farm create myfarm`, podman farm create myfarm`,
} }

View File

@ -20,13 +20,15 @@ var (
List all available farms. The output of the farms can be filtered List all available farms. The output of the farms can be filtered
and the output format can be changed to JSON or a user specified Go template.` and the output format can be changed to JSON or a user specified Go template.`
lsCommand = &cobra.Command{ lsCommand = &cobra.Command{
Use: "list [options]", Use: "list [options]",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Args: validate.NoArgs, Args: validate.NoArgs,
Short: "List all existing farms", Short: "List all existing farms",
Long: farmLsDescription, Long: farmLsDescription,
RunE: list, PersistentPreRunE: validate.NoOp,
ValidArgsFunction: completion.AutocompleteNone, RunE: list,
PersistentPostRunE: validate.NoOp,
ValidArgsFunction: completion.AutocompleteNone,
} }
// Temporary struct to hold cli values. // Temporary struct to hold cli values.

View File

@ -7,6 +7,7 @@ import (
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/cmd/podman/common" "github.com/containers/podman/v4/cmd/podman/common"
"github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/validate"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -14,12 +15,14 @@ import (
var ( var (
farmRmDescription = `Remove one or more existing farms.` farmRmDescription = `Remove one or more existing farms.`
rmCommand = &cobra.Command{ rmCommand = &cobra.Command{
Use: "remove [options] [FARM...]", Use: "remove [options] [FARM...]",
Aliases: []string{"rm"}, Aliases: []string{"rm"},
Short: "Remove one or more farms", Short: "Remove one or more farms",
Long: farmRmDescription, Long: farmRmDescription,
RunE: rm, PersistentPreRunE: validate.NoOp,
ValidArgsFunction: common.AutoCompleteFarms, RunE: rm,
PersistentPostRunE: validate.NoOp,
ValidArgsFunction: common.AutoCompleteFarms,
Example: `podman farm rm myfarm1 myfarm2 Example: `podman farm rm myfarm1 myfarm2
podman farm rm --all`, podman farm rm --all`,
} }

View File

@ -8,6 +8,7 @@ import (
"github.com/containers/common/pkg/config" "github.com/containers/common/pkg/config"
"github.com/containers/podman/v4/cmd/podman/common" "github.com/containers/podman/v4/cmd/podman/common"
"github.com/containers/podman/v4/cmd/podman/registry" "github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/validate"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
@ -15,12 +16,14 @@ import (
var ( var (
farmUpdateDescription = `Update an existing farm by adding a connection, removing a connection, or changing it to the default farm.` farmUpdateDescription = `Update an existing farm by adding a connection, removing a connection, or changing it to the default farm.`
updateCommand = &cobra.Command{ updateCommand = &cobra.Command{
Use: "update [options] FARM", Use: "update [options] FARM",
Short: "Update an existing farm", Short: "Update an existing farm",
Long: farmUpdateDescription, Long: farmUpdateDescription,
RunE: farmUpdate, PersistentPreRunE: validate.NoOp,
Args: cobra.ExactArgs(1), RunE: farmUpdate,
ValidArgsFunction: common.AutoCompleteFarms, PersistentPostRunE: validate.NoOp,
Args: cobra.ExactArgs(1),
ValidArgsFunction: common.AutoCompleteFarms,
Example: `podman farm update --add con1 farm1 Example: `podman farm update --add con1 farm1
podman farm update --remove con2 farm2 podman farm update --remove con2 farm2
podman farm update --default farm3`, podman farm update --default farm3`,