list-images: add --datadir override for e.g. custom repositories
This commit adds a `--datadir` override that allows overriding the default search paths for e.g. the custom repositories. In practise only repository overrides are supported because that is the only data stored there.
This commit is contained in:
parent
56f9c6969c
commit
2719f3f727
6 changed files with 54 additions and 14 deletions
|
|
@ -14,6 +14,11 @@ var (
|
|||
osStderr io.Writer = os.Stderr
|
||||
)
|
||||
|
||||
type cmdlineOpts struct {
|
||||
dataDir string
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
func cmdListImages(cmd *cobra.Command, args []string) error {
|
||||
filter, err := cmd.Flags().GetStringArray("filter")
|
||||
if err != nil {
|
||||
|
|
@ -23,8 +28,16 @@ func cmdListImages(cmd *cobra.Command, args []string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dataDir, err := cmd.Flags().GetString("datadir")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return listImages(osStdout, output, filter)
|
||||
opts := &cmdlineOpts{
|
||||
out: osStdout,
|
||||
dataDir: dataDir,
|
||||
}
|
||||
return listImages(output, filter, opts)
|
||||
}
|
||||
|
||||
func run() error {
|
||||
|
|
@ -42,6 +55,7 @@ Image-builder builds operating system images for a range of predefined
|
|||
operating sytsems like centos and RHEL with easy customizations support.`,
|
||||
SilenceErrors: true,
|
||||
}
|
||||
rootCmd.PersistentFlags().String("datadir", "", `Override the default data direcotry for e.g. custom repositories/*.json data`)
|
||||
rootCmd.SetOut(osStdout)
|
||||
rootCmd.SetErr(osStderr)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue