Transfer: Registry: Enable to use registry configuration diretory

Currently transfer service isn't aware of configurations of hosts directory and
ctr's `--hosts-dir` doesn't work.
This commit fixes this issue by using `config.ConfigureHosts` instead of
`docker.ConfigureDefaultRegistries`.
This commit also fixes ctr to use this feature for "--hosts-dir" flag.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
Kohei Tokunaga
2024-02-29 15:26:59 +09:00
parent 7f0f49b438
commit 7a3b7fba59
6 changed files with 124 additions and 63 deletions

View File

@@ -132,7 +132,10 @@ command. As part of this process, we do the following:
sopts = append(sopts, image.WithAllMetadata)
}
reg := registry.NewOCIRegistry(ref, nil, ch)
reg, err := registry.NewOCIRegistry(ctx, ref, registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir")))
if err != nil {
return err
}
is := image.NewStore(ref, sopts...)
pf, done := ProgressHandler(ctx, os.Stdout)

View File

@@ -104,7 +104,10 @@ var pushCommand = &cli.Command{
if local == "" {
local = ref
}
reg := registry.NewOCIRegistry(ref, nil, ch)
reg, err := registry.NewOCIRegistry(ctx, ref, registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir")))
if err != nil {
return err
}
is := image.NewStore(local)
pf, done := ProgressHandler(ctx, os.Stdout)