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
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
|
|
@ -33,7 +34,12 @@ func MockOsStderr(new io.Writer) (restore func()) {
|
|||
|
||||
func MockNewRepoRegistry(f func() (*reporegistry.RepoRegistry, error)) (restore func()) {
|
||||
saved := newRepoRegistry
|
||||
newRepoRegistry = f
|
||||
newRepoRegistry = func(dataDir string) (*reporegistry.RepoRegistry, error) {
|
||||
if dataDir != "" {
|
||||
panic(fmt.Sprintf("cannot use custom dataDir %v in mock", dataDir))
|
||||
}
|
||||
return f()
|
||||
}
|
||||
return func() {
|
||||
newRepoRegistry = saved
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue