|
|
@ -87,7 +87,16 @@ func NewClient(options ...ClientOption) (*Client, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
client.authorizer = authClient
|
|
|
|
client.authorizer = authClient
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resolverFn := client.resolver // copy for avoiding recursive call
|
|
|
|
client.resolver = func(ref registry.Reference) (remotes.Resolver, error) {
|
|
|
|
client.resolver = func(ref registry.Reference) (remotes.Resolver, error) {
|
|
|
|
|
|
|
|
if resolverFn != nil {
|
|
|
|
|
|
|
|
// validate if the resolverFn returns a valid resolver
|
|
|
|
|
|
|
|
if resolver, err := resolverFn(ref); resolver != nil && err == nil {
|
|
|
|
|
|
|
|
return resolver, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
headers := http.Header{}
|
|
|
|
headers := http.Header{}
|
|
|
|
headers.Set("User-Agent", version.GetUserAgent())
|
|
|
|
headers.Set("User-Agent", version.GetUserAgent())
|
|
|
|
dockerClient, ok := client.authorizer.(*dockerauth.Client)
|
|
|
|
dockerClient, ok := client.authorizer.(*dockerauth.Client)
|
|
|
@ -117,6 +126,7 @@ func NewClient(options ...ClientOption) (*Client, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return resolver, nil
|
|
|
|
return resolver, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// allocate a cache if option is set
|
|
|
|
// allocate a cache if option is set
|
|
|
|
var cache registryauth.Cache
|
|
|
|
var cache registryauth.Cache
|
|
|
|
if client.enableCache {
|
|
|
|
if client.enableCache {
|
|
|
@ -199,6 +209,15 @@ func ClientOptPlainHTTP() ClientOption {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ClientOptResolver returns a function that sets the resolver setting on a client options set
|
|
|
|
|
|
|
|
func ClientOptResolver(resolver remotes.Resolver) ClientOption {
|
|
|
|
|
|
|
|
return func(client *Client) {
|
|
|
|
|
|
|
|
client.resolver = func(ref registry.Reference) (remotes.Resolver, error) {
|
|
|
|
|
|
|
|
return resolver, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
|
// LoginOption allows specifying various settings on login
|
|
|
|
// LoginOption allows specifying various settings on login
|
|
|
|
LoginOption func(*loginOperation)
|
|
|
|
LoginOption func(*loginOperation)
|
|
|
@ -287,21 +306,21 @@ type (
|
|
|
|
|
|
|
|
|
|
|
|
// PullResult is the result returned upon successful pull.
|
|
|
|
// PullResult is the result returned upon successful pull.
|
|
|
|
PullResult struct {
|
|
|
|
PullResult struct {
|
|
|
|
Manifest *descriptorPullSummary `json:"manifest"`
|
|
|
|
Manifest *DescriptorPullSummary `json:"manifest"`
|
|
|
|
Config *descriptorPullSummary `json:"config"`
|
|
|
|
Config *DescriptorPullSummary `json:"config"`
|
|
|
|
Chart *descriptorPullSummaryWithMeta `json:"chart"`
|
|
|
|
Chart *DescriptorPullSummaryWithMeta `json:"chart"`
|
|
|
|
Prov *descriptorPullSummary `json:"prov"`
|
|
|
|
Prov *DescriptorPullSummary `json:"prov"`
|
|
|
|
Ref string `json:"ref"`
|
|
|
|
Ref string `json:"ref"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
descriptorPullSummary struct {
|
|
|
|
DescriptorPullSummary struct {
|
|
|
|
Data []byte `json:"-"`
|
|
|
|
Data []byte `json:"-"`
|
|
|
|
Digest string `json:"digest"`
|
|
|
|
Digest string `json:"digest"`
|
|
|
|
Size int64 `json:"size"`
|
|
|
|
Size int64 `json:"size"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
descriptorPullSummaryWithMeta struct {
|
|
|
|
DescriptorPullSummaryWithMeta struct {
|
|
|
|
descriptorPullSummary
|
|
|
|
DescriptorPullSummary
|
|
|
|
Meta *chart.Metadata `json:"meta"`
|
|
|
|
Meta *chart.Metadata `json:"meta"`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -404,16 +423,16 @@ func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result := &PullResult{
|
|
|
|
result := &PullResult{
|
|
|
|
Manifest: &descriptorPullSummary{
|
|
|
|
Manifest: &DescriptorPullSummary{
|
|
|
|
Digest: manifest.Digest.String(),
|
|
|
|
Digest: manifest.Digest.String(),
|
|
|
|
Size: manifest.Size,
|
|
|
|
Size: manifest.Size,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Config: &descriptorPullSummary{
|
|
|
|
Config: &DescriptorPullSummary{
|
|
|
|
Digest: configDescriptor.Digest.String(),
|
|
|
|
Digest: configDescriptor.Digest.String(),
|
|
|
|
Size: configDescriptor.Size,
|
|
|
|
Size: configDescriptor.Size,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Chart: &descriptorPullSummaryWithMeta{},
|
|
|
|
Chart: &DescriptorPullSummaryWithMeta{},
|
|
|
|
Prov: &descriptorPullSummary{},
|
|
|
|
Prov: &DescriptorPullSummary{},
|
|
|
|
Ref: parsedRef.String(),
|
|
|
|
Ref: parsedRef.String(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var getManifestErr error
|
|
|
|
var getManifestErr error
|
|
|
|