mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Move the --farm flag to farm build command
The option `farm` which is used to specify the farm to be used, is moved to farm build command from farm command. closes #20752 Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
This commit is contained in:
@ -19,6 +19,7 @@ type buildOptions struct {
|
|||||||
buildOptions common.BuildFlagsWrapper
|
buildOptions common.BuildFlagsWrapper
|
||||||
local bool
|
local bool
|
||||||
platforms []string
|
platforms []string
|
||||||
|
farm string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -55,6 +56,16 @@ func init() {
|
|||||||
buildCommand.PersistentFlags().StringSliceVar(&buildOpts.platforms, platformsFlag, nil, "Build only on farm nodes that match the given platforms")
|
buildCommand.PersistentFlags().StringSliceVar(&buildOpts.platforms, platformsFlag, nil, "Build only on farm nodes that match the given platforms")
|
||||||
|
|
||||||
common.DefineBuildFlags(buildCommand, &buildOpts.buildOptions, true)
|
common.DefineBuildFlags(buildCommand, &buildOpts.buildOptions, true)
|
||||||
|
|
||||||
|
podmanConfig := registry.PodmanConfig()
|
||||||
|
|
||||||
|
farmFlagName := "farm"
|
||||||
|
// If remote, don't read the client's containers.conf file
|
||||||
|
defaultFarm := ""
|
||||||
|
if !registry.IsRemote() {
|
||||||
|
defaultFarm = podmanConfig.ContainersConfDefaultsRO.Farms.Default
|
||||||
|
}
|
||||||
|
flags.StringVar(&buildOpts.farm, farmFlagName, defaultFarm, "Farm to use for builds")
|
||||||
}
|
}
|
||||||
|
|
||||||
func build(cmd *cobra.Command, args []string) error {
|
func build(cmd *cobra.Command, args []string) error {
|
||||||
@ -98,8 +109,8 @@ func build(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultFarm := cfg.Farms.Default
|
defaultFarm := cfg.Farms.Default
|
||||||
if farmCmd.Flags().Changed("farm") {
|
if cmd.Flags().Changed("farm") {
|
||||||
f, err := farmCmd.Flags().GetString("farm")
|
f, err := cmd.Flags().GetString("farm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -16,27 +16,9 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// Temporary struct to hold cli values.
|
|
||||||
farmOpts = struct {
|
|
||||||
Farm string
|
|
||||||
}{}
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registry.Commands = append(registry.Commands, registry.CliCommand{
|
registry.Commands = append(registry.Commands, registry.CliCommand{
|
||||||
Command: farmCmd,
|
Command: farmCmd,
|
||||||
})
|
})
|
||||||
farmCmd.Hidden = true
|
farmCmd.Hidden = true
|
||||||
|
|
||||||
flags := farmCmd.Flags()
|
|
||||||
podmanConfig := registry.PodmanConfig()
|
|
||||||
|
|
||||||
farmFlagName := "farm"
|
|
||||||
// If remote, don't read the client's containers.conf file
|
|
||||||
defaultFarm := ""
|
|
||||||
if !registry.IsRemote() {
|
|
||||||
defaultFarm = podmanConfig.ContainersConfDefaultsRO.Farms.Default
|
|
||||||
}
|
|
||||||
flags.StringVarP(&farmOpts.Farm, farmFlagName, "f", defaultFarm, "Farm to use for builds")
|
|
||||||
}
|
}
|
||||||
|
7
docs/source/markdown/options/farm.md
Normal file
7
docs/source/markdown/options/farm.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
####> This option file is used in:
|
||||||
|
####> podman farm build
|
||||||
|
####> If file is edited, make sure the changes
|
||||||
|
####> are applicable to all of those.
|
||||||
|
#### **--farm**
|
||||||
|
|
||||||
|
This option specifies the name of the farm to be used in the build process.
|
@ -89,6 +89,10 @@ It does not affect _/etc/resolv.conf_ in the final image.
|
|||||||
|
|
||||||
@@option env.image
|
@@option env.image
|
||||||
|
|
||||||
|
@@option farm
|
||||||
|
|
||||||
|
This option specifies the name of the farm to be used in the build process.
|
||||||
|
|
||||||
@@option file
|
@@option file
|
||||||
|
|
||||||
@@option force-rm
|
@@option force-rm
|
||||||
@ -214,9 +218,9 @@ Build only on farm nodes that match the given platforms.
|
|||||||
```
|
```
|
||||||
$ podman farm build --local -t name -f /path/to/containerfile .
|
$ podman farm build --local -t name -f /path/to/containerfile .
|
||||||
|
|
||||||
$ podman farm --farm build myfarm -t name .
|
$ podman farm build --farm myfarm -t name .
|
||||||
|
|
||||||
$ podman farm --farm myfarm build --cleanup -t name .
|
$ podman farm build --farm myfarm --cleanup -t name .
|
||||||
|
|
||||||
$ podman farm build --platforms arm64,amd64 --cleanup -t name .
|
$ podman farm build --platforms arm64,amd64 --cleanup -t name .
|
||||||
```
|
```
|
||||||
|
@ -17,7 +17,7 @@ load helpers.bash
|
|||||||
empty_farm="empty-farm"
|
empty_farm="empty-farm"
|
||||||
# create an empty farm
|
# create an empty farm
|
||||||
run_podman farm create $empty_farm
|
run_podman farm create $empty_farm
|
||||||
run_podman farm --farm $empty_farm build -t $iname $PODMAN_TMPDIR
|
run_podman farm build --farm $empty_farm -t $iname $PODMAN_TMPDIR
|
||||||
assert "$output" =~ "Local builder ready"
|
assert "$output" =~ "Local builder ready"
|
||||||
|
|
||||||
# get the system architecture
|
# get the system architecture
|
||||||
|
Reference in New Issue
Block a user