Transfer: Registry: Enable plain HTTP

Currenlty transfer service doesn't handle plain HTTP connection.
This commit fixes this issue by propagating
`(core/remotes/docker/config).HostOptions.DefaultScheme` from client to the
transfer service.
This commit also fixes ctr to use this feature for "--plain-http" flag.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
Kohei Tokunaga
2024-03-28 21:54:46 +09:00
parent 0807efb9ef
commit 4332794384
6 changed files with 91 additions and 46 deletions

View File

@@ -132,7 +132,11 @@ command. As part of this process, we do the following:
sopts = append(sopts, image.WithAllMetadata)
}
reg, err := registry.NewOCIRegistry(ctx, ref, registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir")))
opts := []registry.Opt{registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir"))}
if context.Bool("plain-http") {
opts = append(opts, registry.WithDefaultScheme("http"))
}
reg, err := registry.NewOCIRegistry(ctx, ref, opts...)
if err != nil {
return err
}

View File

@@ -104,7 +104,11 @@ var pushCommand = &cli.Command{
if local == "" {
local = ref
}
reg, err := registry.NewOCIRegistry(ctx, ref, registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir")))
opts := []registry.Opt{registry.WithCredentials(ch), registry.WithHostDir(context.String("hosts-dir"))}
if context.Bool("plain-http") {
opts = append(opts, registry.WithDefaultScheme("http"))
}
reg, err := registry.NewOCIRegistry(ctx, ref, opts...)
if err != nil {
return err
}