0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-04-11 06:01:21 +00:00

Fix registry timeout context ()

Image closer not required while fetching tags
This commit is contained in:
CrazyMax 2020-11-14 16:41:59 +01:00
parent 4382de80d6
commit f7c14b4805
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
4 changed files with 8 additions and 14 deletions
docs/config
internal
pkg/registry

View file

@ -9,7 +9,7 @@ regopts:
- name: "myregistry"
username: fii
password: bor
timeout: 5s
timeout: 30s
- name: "docker.io"
selector: image
username: foo
@ -128,13 +128,13 @@ Use content of secret file as registry password if `password` not defined.
### `timeout`
Timeout is the maximum amount of time for the TCP connection to establish. (default `10s`)
Timeout is the maximum amount of time for the TCP connection to establish. (default `0` ; no timeout)
!!! example "Config file"
```yaml
regopts:
- name: "myregistry"
timeout: 10s
timeout: 30s
```
!!! abstract "Environment variables"

View file

@ -179,7 +179,7 @@ func TestLoadFile(t *testing.T) {
Username: "foo",
Password: "bar",
InsecureTLS: utl.NewFalse(),
Timeout: utl.NewDuration(10 * time.Second),
Timeout: utl.NewDuration(0),
},
{
Name: "docker.io/crazymax",
@ -187,7 +187,7 @@ func TestLoadFile(t *testing.T) {
UsernameFile: "./fixtures/run_secrets_username",
PasswordFile: "./fixtures/run_secrets_password",
InsecureTLS: utl.NewFalse(),
Timeout: utl.NewDuration(10 * time.Second),
Timeout: utl.NewDuration(0),
},
},
Providers: &model.Providers{

View file

@ -21,7 +21,7 @@ type RegOpt struct {
Password string `yaml:"password,omitempty" json:"password,omitempty" validate:"omitempty"`
PasswordFile string `yaml:"passwordFile,omitempty" json:"passwordFile,omitempty" validate:"omitempty,file"`
InsecureTLS *bool `yaml:"insecureTLS,omitempty" json:"insecureTLS,omitempty" validate:"required"`
Timeout *time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty" validate:"required"`
Timeout *time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}
// RegOpt selector constants
@ -44,7 +44,7 @@ func (s *RegOpt) GetDefaults() *RegOpt {
func (s *RegOpt) SetDefaults() {
s.Selector = RegOptSelectorName
s.InsecureTLS = utl.NewFalse()
s.Timeout = utl.NewDuration(10 * time.Second)
s.Timeout = utl.NewDuration(0)
}
// Select returns a registry based on its selector

View file

@ -32,13 +32,7 @@ func (c *Client) Tags(opts TagsOptions) (*Tags, error) {
return nil, errors.Wrap(err, "Cannot parse reference")
}
imgCloser, err := imgRef.NewImage(ctx, c.sysCtx)
if err != nil {
return nil, errors.Wrap(err, "Cannot create image closer")
}
defer imgCloser.Close()
tags, err := docker.GetRepositoryTags(ctx, c.sysCtx, imgCloser.Reference())
tags, err := docker.GetRepositoryTags(ctx, c.sysCtx, imgRef)
if err != nil {
return nil, err
}