feature!: support for setting HTTP User-Agent header (#157)
* feature!: support for setting HTTP User-Agent header * fix lint * fix e2e * refactor: move http.go to internal/util/useragent package and rename functions to Get and Set * Move packages and use attest version
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package tuf
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
@@ -75,7 +76,7 @@ func NewDockerDefaultClientOptions(tufPath string) *ClientOptions {
|
||||
}
|
||||
|
||||
// NewClient creates a new TUF client.
|
||||
func NewClient(opts *ClientOptions) (*Client, error) {
|
||||
func NewClient(ctx context.Context, opts *ClientOptions) (*Client, error) {
|
||||
var tufSource Source
|
||||
if strings.HasPrefix(opts.MetadataSource, "https://") || strings.HasPrefix(opts.MetadataSource, "http://") {
|
||||
tufSource = HTTPSource
|
||||
@@ -119,7 +120,7 @@ func NewClient(opts *ClientOptions) (*Client, error) {
|
||||
cfg.RemoteTargetsURL = opts.TargetsSource
|
||||
|
||||
if tufSource == OCISource {
|
||||
cfg.Fetcher, err = NewRegistryFetcher(cfg)
|
||||
cfg.Fetcher, err = NewRegistryFetcher(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create registry fetcher: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user