mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 06:28:13 +01:00
Fix registry timeout context (#221)
Image closer not required while fetching tags
This commit is contained in:
@@ -9,7 +9,7 @@ regopts:
|
|||||||
- name: "myregistry"
|
- name: "myregistry"
|
||||||
username: fii
|
username: fii
|
||||||
password: bor
|
password: bor
|
||||||
timeout: 5s
|
timeout: 30s
|
||||||
- name: "docker.io"
|
- name: "docker.io"
|
||||||
selector: image
|
selector: image
|
||||||
username: foo
|
username: foo
|
||||||
@@ -128,13 +128,13 @@ Use content of secret file as registry password if `password` not defined.
|
|||||||
|
|
||||||
### `timeout`
|
### `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"
|
!!! example "Config file"
|
||||||
```yaml
|
```yaml
|
||||||
regopts:
|
regopts:
|
||||||
- name: "myregistry"
|
- name: "myregistry"
|
||||||
timeout: 10s
|
timeout: 30s
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! abstract "Environment variables"
|
!!! abstract "Environment variables"
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ func TestLoadFile(t *testing.T) {
|
|||||||
Username: "foo",
|
Username: "foo",
|
||||||
Password: "bar",
|
Password: "bar",
|
||||||
InsecureTLS: utl.NewFalse(),
|
InsecureTLS: utl.NewFalse(),
|
||||||
Timeout: utl.NewDuration(10 * time.Second),
|
Timeout: utl.NewDuration(0),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "docker.io/crazymax",
|
Name: "docker.io/crazymax",
|
||||||
@@ -187,7 +187,7 @@ func TestLoadFile(t *testing.T) {
|
|||||||
UsernameFile: "./fixtures/run_secrets_username",
|
UsernameFile: "./fixtures/run_secrets_username",
|
||||||
PasswordFile: "./fixtures/run_secrets_password",
|
PasswordFile: "./fixtures/run_secrets_password",
|
||||||
InsecureTLS: utl.NewFalse(),
|
InsecureTLS: utl.NewFalse(),
|
||||||
Timeout: utl.NewDuration(10 * time.Second),
|
Timeout: utl.NewDuration(0),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Providers: &model.Providers{
|
Providers: &model.Providers{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type RegOpt struct {
|
|||||||
Password string `yaml:"password,omitempty" json:"password,omitempty" validate:"omitempty"`
|
Password string `yaml:"password,omitempty" json:"password,omitempty" validate:"omitempty"`
|
||||||
PasswordFile string `yaml:"passwordFile,omitempty" json:"passwordFile,omitempty" validate:"omitempty,file"`
|
PasswordFile string `yaml:"passwordFile,omitempty" json:"passwordFile,omitempty" validate:"omitempty,file"`
|
||||||
InsecureTLS *bool `yaml:"insecureTLS,omitempty" json:"insecureTLS,omitempty" validate:"required"`
|
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
|
// RegOpt selector constants
|
||||||
@@ -44,7 +44,7 @@ func (s *RegOpt) GetDefaults() *RegOpt {
|
|||||||
func (s *RegOpt) SetDefaults() {
|
func (s *RegOpt) SetDefaults() {
|
||||||
s.Selector = RegOptSelectorName
|
s.Selector = RegOptSelectorName
|
||||||
s.InsecureTLS = utl.NewFalse()
|
s.InsecureTLS = utl.NewFalse()
|
||||||
s.Timeout = utl.NewDuration(10 * time.Second)
|
s.Timeout = utl.NewDuration(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select returns a registry based on its selector
|
// Select returns a registry based on its selector
|
||||||
|
|||||||
@@ -32,13 +32,7 @@ func (c *Client) Tags(opts TagsOptions) (*Tags, error) {
|
|||||||
return nil, errors.Wrap(err, "Cannot parse reference")
|
return nil, errors.Wrap(err, "Cannot parse reference")
|
||||||
}
|
}
|
||||||
|
|
||||||
imgCloser, err := imgRef.NewImage(ctx, c.sysCtx)
|
tags, err := docker.GetRepositoryTags(ctx, c.sysCtx, imgRef)
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "Cannot create image closer")
|
|
||||||
}
|
|
||||||
defer imgCloser.Close()
|
|
||||||
|
|
||||||
tags, err := docker.GetRepositoryTags(ctx, c.sysCtx, imgCloser.Reference())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user