Documentation
¶
Overview ¶
Package remote owns outbound HTTP for remote repositories. Callers must authorize the repository and path before consulting either cache or upstream.
Index ¶
- Constants
- Variables
- func GoResource(path, method string) (source.Resource, error)
- func MavenMetadata(ctx context.Context, service *source.Service, q source.Request, ...) (maven.SourceMetadata, error)
- func RegistryResource(image, operation, reference string) (source.Resource, error)
- func ResolveMavenSource(ctx context.Context, service *source.Service, items *item.Service, ...) (string, error)
- func SmartTrace(next http.Handler) http.Handler
- type Client
- type Discovery
- func (d *Discovery) Canonical() *layout.Layout
- func (d *Discovery) MapFile(upstream string) (string, bool, error)
- func (d *Discovery) MetadataResource(scope DiscoveryScope, upstream, variant string) (source.Resource, error)
- func (d *Discovery) Read(ctx context.Context, service *source.Service, q source.Request) (source.Result, error)
- func (d *Discovery) Revalidate(ctx context.Context) error
- func (d *Discovery) Scopes(values layout.Values) []DiscoveryScope
- func (d *Discovery) Upstream() *layout.Layout
- func (d *Discovery) VersionScope(group, module, version string) (DiscoveryScope, bool)
- type DiscoveryScope
- type FolderListing
- type GoSource
- type ListingBudget
- type ListingEntry
- type MappedFolderListing
- type MavenBackend
- type MavenEager
- type Options
- type Policy
- type Pool
- type Registry
- type RegistryContent
- type RegistryOptions
- type RegistryPool
- type Request
- type Resolver
- type ResolverOptions
- type Smart
- func (s *Smart) Close()
- func (s *Smart) Discover(ctx context.Context, q source.Request, permit source.Permit) (SmartPeer, error)
- func (s *Smart) Read(ctx context.Context, q source.Request, permit source.Permit) (source.Result, error)
- func (s *Smart) Status(ctx context.Context, key, path string) (SmartStatus, error)
- type SmartPeer
- type SmartRepresentationStatus
- type SmartStatus
- type SmartWorkStatus
Constants ¶
const MavenCompanionKind = "maven.remote-companion"
const SmartOriginHeader = "X-Artifactory-Originated"
Variables ¶
var ( ErrRegistryChallenge = errors.New("remote: invalid upstream registry authentication challenge") ErrRegistryDenied = errors.New("remote: upstream registry authentication denied") )
var ( ErrURL = errors.New("remote: invalid url or path") ErrRequest = errors.New("remote: request failed") ErrRedirect = errors.New("remote: redirect refused") ErrConfiguration = errors.New("remote: invalid transport configuration") ErrClosed = errors.New("remote: transport pool closed") ErrConnection = errors.New("remote: connection unavailable") ErrSecurity = errors.New("remote: transport security validation failed") )
var ErrBusy = errors.New("remote: remote retrieval capacity exhausted")
var ErrGoResponse = errors.New("remote: invalid upstream go module response")
Functions ¶
func GoResource ¶
GoResource separates the case-decoded storage/permission identity from the escaped GOPROXY target. Module ZIPs and go.mod files are immutable. Info, list and latest retain the existing format's metadata classification and remain authoritative upstream bytes, independent of downloaded cache items.
func MavenMetadata ¶
func MavenMetadata( ctx context.Context, service *source.Service, q source.Request, metadataPath string, ) (maven.SourceMetadata, error)
MavenMetadata reads source metadata for both token resolution and the #213 upstream-version consumer. It never populates a binary to discover a version.
func RegistryResource ¶
RegistryResource fixes cache and authorization paths independently of an upstream namespace prefix. Manifest Accept is canonical so supported clients share exact bytes; delivery separately checks each caller's accepted types.
func ResolveMavenSource ¶
func ResolveMavenSource( ctx context.Context, service *source.Service, items *item.Service, q source.Request, ) (string, error)
ResolveMavenSource uses authoritative metadata for Maven's changing version names. The caller must authorize the returned canonical path before fetching.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is immutable and safe for concurrent use. Every successful Do or Fetch transfers response-body ownership to the caller, including non-2xx responses.
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery retains an atomic layout/source snapshot. Upstream paths are traversal inputs only; consumers receive canonical paths after lossless translation and current authorization.
func NewDiscovery ¶
func (*Discovery) MapFile ¶
MapFile refuses lossy or ambiguous coordinates instead of keeping the raw upstream path. Non-artifact metadata/auxiliary names are not file results.
func (*Discovery) MetadataResource ¶
func (d *Discovery) MetadataResource( scope DiscoveryScope, upstream, variant string, ) (source.Resource, error)
MetadataResource separates the private cache/authority location from the upstream document. Callers must supply complete body validation before Read.
func (*Discovery) Read ¶
func (d *Discovery) Read( ctx context.Context, service *source.Service, q source.Request, ) (source.Result, error)
Read pins the identity before Service acquires the source. A layout edit between preparing the mapping and Service.Resolve cannot adopt a new source generation with old mapping rules, even before the first network request.
func (*Discovery) Scopes ¶
func (d *Discovery) Scopes(values layout.Values) []DiscoveryScope
Scopes derives authority from complete canonical directory components. A constraint present only in a filename cannot borrow a sibling file's grant.
func (*Discovery) VersionScope ¶
func (d *Discovery) VersionScope(group, module, version string) (DiscoveryScope, bool)
VersionScope proves a version-specific artifact directory without guessing an extension, classifier or POM. Filename-only versions need actual files.
type DiscoveryScope ¶
DiscoveryScope is a canonical query folder. Root requires actual root Read when the layout cannot encode the query's coordinates in a directory; a grant on an unrelated descendant cannot initiate that scan.
type FolderListing ¶
type FolderListing struct {
Entries []ListingEntry
// contains filtered or unexported fields
}
FolderListing retains current authority for every page and visible child. Call Revalidate immediately before disclosing the result, including HEAD.
func ListFolder ¶
func ListFolder(ctx context.Context, service *source.Service, q source.Request, folder string, budget *ListingBudget, ) (FolderListing, error)
ListFolder performs an explicit, nonrecursive source lookup. The entry point owns the documented listRemoteFolderItems policy; this source primitive does not infer an entry point from a caller-controlled parameter. CacheOnly is carried unchanged to every page.
func (FolderListing) Revalidate ¶
func (l FolderListing) Revalidate(ctx context.Context) error
type GoSource ¶
type GoSource struct {
Source interface {
Read(context.Context, source.Request) (source.Result, error)
}
}
GoSource is the GOPROXY reader for the P10 virtual resolver. It deliberately installs no native remote HTTP route and never falls back to a VCS or sumdb. Source must be the application's authority-fenced source service, not a raw transport or cache backend. Callers retain the result's delivery/usage hooks.
type ListingBudget ¶
type ListingBudget struct {
// contains filtered or unexported fields
}
ListingBudget bounds an entire browsing/search operation, including multiple folders. A zero value is ready to use; the caller must not share it concurrently.
type ListingEntry ¶
ListingEntry describes an upstream child, not a cached item. Listing never creates an item row or fetches the child's payload.
type MappedFolderListing ¶
type MappedFolderListing struct {
Files []ListingEntry
Folders []string `json:"-"`
Documents []string `json:"-"`
// contains filtered or unexported fields
}
MappedFolderListing exposes only authorized canonical files. Folders are private upstream traversal cursors, never public paths or permission grants. Documents contains non-artifact control-document cursors. Consumers must validate their identities and read them under a derived canonical scope.
func ListMappedFolder ¶
func ListMappedFolder(ctx context.Context, service *source.Service, q source.Request, discovery *Discovery, scope DiscoveryScope, upstreamFolder string, budget *ListingBudget, ) (MappedFolderListing, error)
ListMappedFolder uses one fixed canonical query scope for each bounded upstream page. It must never authorize an upstream lexical path, including subdirectories that the caller later traverses under that same query scope.
func (MappedFolderListing) Revalidate ¶
func (l MappedFolderListing) Revalidate(ctx context.Context) error
type MavenBackend ¶
type MavenBackend struct {
Policy *Policy
Eager func(context.Context, source.Request, source.Permit)
}
MavenBackend opts only Maven-family routes into format-aware source retrieval. Other adapters keep the shared policy's existing behavior.
func (*MavenBackend) PrepareUpload ¶
func (m *MavenBackend) PrepareUpload( ctx context.Context, q source.Request, permit source.Permit, opts Options, u *item.CacheUpload, ) error
PrepareUpload retrieves optional external checksum files only for a newly fetched representation. Warm cache hits need no sidecar requests; pass-thru additionally preserves each available upstream digest. Every auxiliary call uses the same guarded transport and deadline.
type MavenEager ¶
type MavenEager struct {
// contains filtered or unexported fields
}
MavenEager persists deduplicated companion work without retaining credentials. Two workers share the regular source admission limits. Pending/leased/parked jobs together are bounded to 256; failures park after three attempts. Shutdown returns interrupted leases so another process can safely resume them.
func NewMavenEager ¶
func (*MavenEager) Close ¶
func (e *MavenEager) Close()
type Options ¶
type Options struct {
ProxyURL *url.URL
TLSConfig *tls.Config
Revision string
Jar http.CookieJar
// CheckURL authorizes metadata-provided absolute destinations.
CheckURL func(context.Context, *url.URL) error
WrapTransport func(*http.Transport) (http.RoundTripper, func())
Prepare func(*http.Request) error
CheckRedirect func(*http.Request, []*http.Request) error
// MaxResponseHeaderBytes defaults to 1 MiB; tests can lower it.
MaxResponseHeaderBytes int64
}
Options contains resolved connection settings. Revision must change whenever externally resolved settings (proxy, trust, credentials) change. Prepare runs for initial requests and redirects, after the transport removes credentials from requests crossing origins. It must not forward downstream credentials.
type Policy ¶
type Policy struct {
Smart *Smart
// Fetch overrides only the protocol exchange. Authentication adapters retain
// the source identity and credential revision used by this cache operation.
Fetch func(context.Context, source.Request, source.Permit, Options, Request) (*http.Response, error)
// PrepareUpload performs bounded adapter work outside SQL, after the main
// response succeeds and before validation/publication. It uses the same
// transport security and cannot replace the final CheckCurrent fence.
PrepareUpload func(context.Context, source.Request, source.Permit, Options, *item.CacheUpload) error
Store store.Store
Blobs blob.Store
Items *item.Service
Pool *Pool
Options func(context.Context, repo.Config) (Options, error)
CheckCurrent func(context.Context, store.Store, source.Request, source.Permit, string) error
// Key is a stable keyring-derived HMAC key, never a logged cache identifier.
Key []byte
Now func() time.Time
MetadataLimit int64
// contains filtered or unexported fields
}
Policy implements the shared remote retrieval table. Authorization belongs to source.Service; CheckCurrent repeats it inside the short publication transaction and verifies the effective credential revision without network access.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool reuses a repository's connections until its configuration or resolved credential revision changes. Remove closes a deleted repository's idle clients; Close drains all idle clients during application shutdown. Active requests are owned by their caller contexts and may finish against the previous revision.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry authenticates read-only Distribution v2 requests. It is bound to one resolved repository revision; RegistryPool also fences its source incarnation. Native adapters own authorization, cache publication and digest validation.
func NewRegistry ¶
func NewRegistry(c repo.Config, opts RegistryOptions) (*Registry, error)
func (*Registry) Do ¶
Do addresses a registry resource relative to an image, for example Do(ctx, "team/image", Request{Method: "GET", Path: "manifests/latest"}). A request retries authentication at most once. All returned bodies are owned by the caller, including terminal non-authentication error statuses.
type RegistryContent ¶
type RegistryContent struct {
Policy *Policy
Pool *RegistryPool
Options func(context.Context, repo.Config) (RegistryOptions, error)
// contains filtered or unexported fields
}
RegistryContent installs Distribution authentication and validation on a fresh shared policy. The pool and resolver belong to the application lifetime.
func (*RegistryContent) Install ¶
func (c *RegistryContent) Install()
type RegistryOptions ¶
type RegistryOptions struct {
Transport Options
Now func() time.Time
// contains filtered or unexported fields
}
RegistryOptions comes from Resolver.RegistryOptions, never downstream headers. Now is an optional clock for deterministic expiry tests.
type RegistryPool ¶
type RegistryPool struct {
// contains filtered or unexported fields
}
RegistryPool owns token and connection lifetimes. A changed repository incarnation, source generation or credential revision starts an empty cache.
func (*RegistryPool) Client ¶
func (p *RegistryPool) Client( c repo.Config, identity types.SourceIdentity, opts RegistryOptions, ) (*Registry, error)
func (*RegistryPool) Close ¶
func (p *RegistryPool) Close()
func (*RegistryPool) Remove ¶
func (p *RegistryPool) Remove(key string)
type Request ¶
type Request struct {
// ExternalURL is a metadata/token-realm URL, never combined with Path/Query.
// It requires a resolved destination policy.
ExternalURL string
// CheckURL is a request-scoped restriction, never retained by the pooled client.
// It applies before the initial request and each redirected request is sent.
CheckURL func(context.Context, *url.URL) error
NoCrossOriginAuth bool
// GitLFSActionHeaders belong only to the exact, validated download action.
// They are never copied to a redirected request.
GitLFSActionHeaders http.Header
Method string
Path string
Query string
Header http.Header
Metadata bool
// Body is admitted only for closed format-owned metadata POST contracts.
Body []byte
// contains filtered or unexported fields
}
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func NewResolver ¶
func (*Resolver) Options ¶
Options reloads sealed secrets through the store, rather than treating an API's masked view as usable credentials. A stale non-secret configuration fails closed. Revision is a stable HMAC of source-affecting settings, not cache/access policy.
func (*Resolver) RegistryOptions ¶
RegistryOptions preserves the shared destination, proxy and TLS policy while keeping registry Basic credentials separate from ordinary HTTP Bearer mode.
type ResolverOptions ¶
type ResolverOptions struct {
// RevisionKey is trusted, stable application key material for installations
// without a master key. It never comes from a repository or HTTP request.
RevisionKey []byte
RootCAsPEM []byte
AllowedPrivateOrigins []string
LookupIP func(context.Context, string) ([]net.IPAddr, error)
}
ResolverOptions is trusted application configuration, never upstream metadata. RootCAsPEM augments system trust. AllowedPrivateOrigins grants exact additional authorities private-network access without authorizing credential forwarding. LookupIP is injectable for deterministic DNS/rebinding tests; nil uses net.Resolver.
type Smart ¶
type Smart struct {
// contains filtered or unexported fields
}
Smart adds authenticated discovery and bounded durable side effects to one shared policy. Registry and ordinary policies keep separate validators.
func (*Smart) Discover ¶
func (s *Smart) Discover( ctx context.Context, q source.Request, permit source.Permit, ) (SmartPeer, error)
Discover requires the caller's existing permit. Public adapters invoke it through RequireSmart and source.Service, never manufacture their own permit.
type SmartPeer ¶
type SmartPeer struct {
BaseURL string
Repository string
Class repo.Class
Version string
// contains filtered or unexported fields
}
SmartPeer identifies only the configured peer. Parsing it does not negotiate capabilities or grant network authority; callers use source.Service.Read. Class and Version are filled only by authenticated discovery.
func ParseSmartPeer ¶
ParseSmartPeer accepts repository endpoints, including the documented api/<package>/<repository> forms. Query-bearing and ambiguous endpoint paths cannot safely identify a different management API and are refused.
type SmartRepresentationStatus ¶
type SmartRepresentationStatus struct {
PropertiesCheckedAt time.Time `json:"properties_checked_at"`
OriginCheckedAt time.Time `json:"origin_checked_at"`
OriginAbsent *bool `json:"origin_absent,omitempty"`
Downloads int64 `json:"downloads"`
Claimed int64 `json:"claimed"`
Uncertain int64 `json:"uncertain"`
Work []SmartWorkStatus `json:"work"`
}
type SmartStatus ¶
type SmartStatus struct {
Repository string `json:"repository"`
Path string `json:"path"`
Representations []SmartRepresentationStatus `json:"representations"`
Truncated bool `json:"truncated"`
}
SmartStatus is an artifactweave diagnostic, not an Artifactory storage wire document. A zero origin timestamp means unknown, never confirmed absent.
Source Files
¶
- circuit.go
- client.go
- cocoapods_git.go
- cocoapods_git_pack.go
- credentials.go
- destination.go
- discovery.go
- fetch.go
- flight.go
- golang.go
- golang_zip.go
- listing.go
- listing_html.go
- listing_mapped.go
- listing_smart.go
- maven.go
- maven_eager.go
- module_location.go
- nuget_empty_feed.go
- policy.go
- pool.go
- protocol.go
- registry.go
- registry_challenge.go
- registry_children.go
- registry_content.go
- registry_descriptors.go
- registry_pages.go
- registry_token.go
- rules.go
- security.go
- smart.go
- smart_aql.go
- smart_discovery.go
- smart_peer.go
- smart_properties.go
- smart_queue.go
- smart_request.go
- smart_statistics.go
- smart_status.go
- smart_trace.go
- url.go