feat(db): allow passing registry options (#5226)

* feat(db): allow passing registry options

Signed-off-by: Michel Meyer <meyer_michel@outlook.com>

* feat(db): pass cli registry options to javaDB

---------

Signed-off-by: Michel Meyer <meyer_michel@outlook.com>
This commit is contained in:
Michel Meyer
2023-09-27 15:17:11 +02:00
committed by GitHub
parent 5b4652d796
commit 908a4914c7
4 changed files with 15 additions and 15 deletions

View File

@@ -26,11 +26,11 @@ const (
var updater *Updater
type Updater struct {
repo string
dbDir string
skip bool
quiet bool
insecure bool
repo string
dbDir string
skip bool
quiet bool
registryOption ftypes.RegistryOptions
}
func (u *Updater) Update() error {
@@ -54,7 +54,7 @@ func (u *Updater) Update() error {
// TODO: support remote options
var a *oci.Artifact
if a, err = oci.NewArtifact(u.repo, u.quiet, ftypes.RegistryOptions{Insecure: u.insecure}); err != nil {
if a, err = oci.NewArtifact(u.repo, u.quiet, u.registryOption); err != nil {
return xerrors.Errorf("oci error: %w", err)
}
if err = a.Download(context.Background(), dbDir, oci.DownloadOption{MediaType: mediaType}); err != nil {
@@ -79,13 +79,13 @@ func (u *Updater) Update() error {
return nil
}
func Init(cacheDir string, javaDBRepository string, skip, quiet, insecure bool) {
func Init(cacheDir string, javaDBRepository string, skip, quiet bool, registryOption ftypes.RegistryOptions) {
updater = &Updater{
repo: fmt.Sprintf("%s:%d", javaDBRepository, db.SchemaVersion),
dbDir: filepath.Join(cacheDir, "java-db"),
skip: skip,
quiet: quiet,
insecure: insecure,
repo: fmt.Sprintf("%s:%d", javaDBRepository, db.SchemaVersion),
dbDir: filepath.Join(cacheDir, "java-db"),
skip: skip,
quiet: quiet,
registryOption: registryOption,
}
}