downloader

package
v1.225.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package downloader is a generated GoMock package.

Index

Constants

View Source
const GitPrefix = "git::"
View Source
const MaskedSecret = "REDACTED"

MaskedSecret is used internally for credential masking. We use "REDACTED" instead of "***" because url.UserPassword() would URL-encode. "***" as "%2A%2A%2A", making URLs harder to read. We post-process the output to replace "REDACTED" with "***" for traditional credential masking appearance.

View Source
const (

	// MinRateLimitRemaining is the minimum remaining rate limit before pre-check waits.
	MinRateLimitRemaining = 5
)

Variables

This section is empty.

Functions

func RedactSource added in v1.225.0

func RedactSource(source string) string

RedactSource removes credentials and query strings before a source reaches a lock, workdir receipt, log, or SBOM.

func TreeSHA256 added in v1.225.0

func TreeSHA256(root string) (string, error)

TreeSHA256 hashes a directory's portable file manifest and bytes. It is the fallback identity for archives and local paths, never a replacement for a stronger Git or OCI identity.

Types

type ClientFactory

type ClientFactory interface {
	NewClient(ctx context.Context, src, dest string, mode ClientMode) (DownloadClient, error)
}

ClientFactory abstracts the creation of a downloader client for better testability.

type ClientMode

type ClientMode int

ClientMode represents different modes for downloading (file, dir, etc.)

const (
	ClientModeInvalid ClientMode = iota

	// ClientModeAny downloads anything it can. In this mode, dst must
	// be a directory. If src is a file, it is saved into the directory
	// with the basename of the URL. If src is a directory or archive,
	// it is unpacked directly into dst.
	ClientModeAny

	// Be a file path (doesn't have to exist). The src must point to a single
	// file. It is saved as dst.
	ClientModeFile

	// A directory path (doesn't have to exist). The src must point to an
	// archive or directory (such as in s3).
	ClientModeDir
)

type CustomGitDetector

type CustomGitDetector struct {
	// contains filtered or unexported fields
}

CustomGitDetector intercepts Git URLs (for GitHub, Bitbucket, GitLab, etc.) and transforms them into a proper URL for cloning, optionally injecting tokens.

func NewCustomGitDetector

func NewCustomGitDetector(atmosConfig *schema.AtmosConfiguration, source string) *CustomGitDetector

NewCustomGitDetector creates a new CustomGitDetector with the provided configuration and source URL.

func (*CustomGitDetector) Detect

func (d *CustomGitDetector) Detect(src, _ string) (string, bool, error)

Detect implements the getter.Detector interface for go-getter v1.

type CustomGitGetter

type CustomGitGetter struct {
	getter.GitGetter
	// RetryConfig specifies retry behavior for git operations.
	RetryConfig *schema.RetryConfig
	// RetryAuthErrors tolerates transient authentication failures by retrying them within a
	// bounded window. It is enabled ONLY when Atmos brokered a fresh GitHub token this
	// process (see pkg/auth/broker.HasBrokeredCredentials): a just-minted GitHub App
	// installation token can briefly return 401 before GitHub propagates it across its git
	// frontends. For ordinary static credentials this stays false so a wrong/expired token
	// fails fast instead of stalling.
	RetryAuthErrors bool
}

CustomGitGetter is a custom getter for git (git::) that removes symlinks. It also supports retry configuration for transient errors.

func (*CustomGitGetter) Get

func (c *CustomGitGetter) Get(dst string, url *url.URL) error

Get implements the custom getter logic removing symlinks.

func (*CustomGitGetter) GetCustom added in v1.189.0

func (g *CustomGitGetter) GetCustom(dst string, u *url.URL) error

type DownloadClient

type DownloadClient interface {
	Get() error
}

DownloadClient defines an interface for download operations.

type FetchMetadata added in v1.225.0

type FetchMetadata struct {
	ETag         string
	LastModified string
}

FetchMetadata is best-effort HTTP cache metadata captured during a fetch, for provenance only. It is never treated as a stronger identity than a real digest/checksum -- see ResolvedArtifact's own doc comment ("Cache metadata deliberately has no role in integrity verification").

type FileDownloader

type FileDownloader interface {
	// Fetch fetches content from a given source and saves it to the destination
	Fetch(src, dest string, mode ClientMode, timeout time.Duration) error

	// FetchAndAutoParse downloads a remote file, detects its format, and parses it
	FetchAndAutoParse(src string) (any, error)

	// FetchAndParseByExtension downloads a remote file and parses it based on its extension
	FetchAndParseByExtension(src string) (any, error)

	// FetchAndParseRaw downloads a remote file and always returns it as a raw string
	FetchAndParseRaw(src string) (any, error)

	// FetchData fetches content from a given source and returns it as a byte slice
	FetchData(src string) ([]byte, error)

	// FetchAtomic downloads a file atomically to the destination.
	// Uses temp file + fsync + atomic rename to prevent partial downloads.
	FetchAtomic(src, dest string, mode ClientMode, timeout time.Duration) error

	// FetchWithMetadata fetches like Fetch, additionally returning best-effort HTTP cache
	// metadata (ETag/Last-Modified) captured from the response. It is empty for non-HTTP
	// sources (git, OCI, local) or when the underlying client doesn't expose any.
	FetchWithMetadata(src, dest string, mode ClientMode, timeout time.Duration) (FetchMetadata, error)
}

FileDownloader handles downloading files and directories from various sources without exposing the underlying implementation.

func NewFileDownloader

func NewFileDownloader(factory ClientFactory) FileDownloader

NewFileDownloader initializes a FileDownloader with dependency injection.

func NewGoGetterDownloader

func NewGoGetterDownloader(atmosConfig *schema.AtmosConfiguration, opts ...GoGetterOption) FileDownloader

NewGoGetterDownloader creates a new go-getter based downloader.

type GoGetterOption added in v1.203.0

type GoGetterOption func(*goGetterClientFactory)

GoGetterOption configures the go-getter downloader.

func WithHTTPClient added in v1.203.0

func WithHTTPClient(client *http.Client) GoGetterOption

WithHTTPClient sets a custom HTTP client for HTTP/HTTPS requests. This is useful for testing with mock servers or custom transport configurations.

func WithRetryConfig added in v1.203.0

func WithRetryConfig(retryConfig *schema.RetryConfig) GoGetterOption

WithRetryConfig sets the retry configuration for git operations.

type MockClientFactory

type MockClientFactory struct {
	// contains filtered or unexported fields
}

MockClientFactory is a mock of ClientFactory interface.

func NewMockClientFactory

func NewMockClientFactory(ctrl *gomock.Controller) *MockClientFactory

NewMockClientFactory creates a new mock instance.

func (*MockClientFactory) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClientFactory) NewClient

func (m *MockClientFactory) NewClient(ctx context.Context, src, dest string, mode ClientMode) (DownloadClient, error)

NewClient mocks base method.

type MockClientFactoryMockRecorder

type MockClientFactoryMockRecorder struct {
	// contains filtered or unexported fields
}

MockClientFactoryMockRecorder is the mock recorder for MockClientFactory.

func (*MockClientFactoryMockRecorder) NewClient

func (mr *MockClientFactoryMockRecorder) NewClient(ctx, src, dest, mode any) *gomock.Call

NewClient indicates an expected call of NewClient.

type MockDownloadClient

type MockDownloadClient struct {
	// contains filtered or unexported fields
}

MockDownloadClient is a mock of DownloadClient interface.

func NewMockDownloadClient

func NewMockDownloadClient(ctrl *gomock.Controller) *MockDownloadClient

NewMockDownloadClient creates a new mock instance.

func (*MockDownloadClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDownloadClient) Get

func (m *MockDownloadClient) Get() error

Get mocks base method.

type MockDownloadClientMockRecorder

type MockDownloadClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockDownloadClientMockRecorder is the mock recorder for MockDownloadClient.

func (*MockDownloadClientMockRecorder) Get

Get indicates an expected call of Get.

type MockFileDownloader

type MockFileDownloader struct {
	// contains filtered or unexported fields
}

MockFileDownloader is a mock of FileDownloader interface.

func NewMockFileDownloader

func NewMockFileDownloader(ctrl *gomock.Controller) *MockFileDownloader

NewMockFileDownloader creates a new mock instance.

func (*MockFileDownloader) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFileDownloader) Fetch

func (m *MockFileDownloader) Fetch(src, dest string, mode ClientMode, timeout time.Duration) error

Fetch mocks base method.

func (*MockFileDownloader) FetchAndAutoParse

func (m *MockFileDownloader) FetchAndAutoParse(src string) (any, error)

FetchAndAutoParse mocks base method.

func (*MockFileDownloader) FetchAndParseByExtension added in v1.191.0

func (m *MockFileDownloader) FetchAndParseByExtension(src string) (any, error)

FetchAndParseByExtension mocks base method.

func (*MockFileDownloader) FetchAndParseRaw added in v1.191.0

func (m *MockFileDownloader) FetchAndParseRaw(src string) (any, error)

FetchAndParseRaw mocks base method.

func (*MockFileDownloader) FetchAtomic added in v1.203.0

func (m *MockFileDownloader) FetchAtomic(src, dest string, mode ClientMode, timeout time.Duration) error

FetchAtomic mocks base method.

func (*MockFileDownloader) FetchData added in v1.174.0

func (m *MockFileDownloader) FetchData(src string) ([]byte, error)

FetchData mocks base method.

func (*MockFileDownloader) FetchWithMetadata added in v1.225.0

func (m *MockFileDownloader) FetchWithMetadata(src, dest string, mode ClientMode, timeout time.Duration) (FetchMetadata, error)

FetchWithMetadata mocks base method.

type MockFileDownloaderMockRecorder

type MockFileDownloaderMockRecorder struct {
	// contains filtered or unexported fields
}

MockFileDownloaderMockRecorder is the mock recorder for MockFileDownloader.

func (*MockFileDownloaderMockRecorder) Fetch

func (mr *MockFileDownloaderMockRecorder) Fetch(src, dest, mode, timeout any) *gomock.Call

Fetch indicates an expected call of Fetch.

func (*MockFileDownloaderMockRecorder) FetchAndAutoParse

func (mr *MockFileDownloaderMockRecorder) FetchAndAutoParse(src any) *gomock.Call

FetchAndAutoParse indicates an expected call of FetchAndAutoParse.

func (*MockFileDownloaderMockRecorder) FetchAndParseByExtension added in v1.191.0

func (mr *MockFileDownloaderMockRecorder) FetchAndParseByExtension(src any) *gomock.Call

FetchAndParseByExtension indicates an expected call of FetchAndParseByExtension.

func (*MockFileDownloaderMockRecorder) FetchAndParseRaw added in v1.191.0

func (mr *MockFileDownloaderMockRecorder) FetchAndParseRaw(src any) *gomock.Call

FetchAndParseRaw indicates an expected call of FetchAndParseRaw.

func (*MockFileDownloaderMockRecorder) FetchAtomic added in v1.203.0

func (mr *MockFileDownloaderMockRecorder) FetchAtomic(src, dest, mode, timeout any) *gomock.Call

FetchAtomic indicates an expected call of FetchAtomic.

func (*MockFileDownloaderMockRecorder) FetchData added in v1.174.0

func (mr *MockFileDownloaderMockRecorder) FetchData(src any) *gomock.Call

FetchData indicates an expected call of FetchData.

func (*MockFileDownloaderMockRecorder) FetchWithMetadata added in v1.225.0

func (mr *MockFileDownloaderMockRecorder) FetchWithMetadata(src, dest, mode, timeout any) *gomock.Call

FetchWithMetadata indicates an expected call of FetchWithMetadata.

type ResolvedArtifact added in v1.225.0

type ResolvedArtifact struct {
	Declared string
	Resolved string
	Kind     string
	Identity string
	ETag     string
	Modified string
}

ResolvedArtifact is immutable provenance captured at the common download boundary. Declared and Resolved never contain URL credentials or queries. Cache metadata deliberately has no role in integrity verification.

func ResolveArtifact added in v1.225.0

func ResolveArtifact(ctx context.Context, config *schema.AtmosConfiguration, declared, stagedPath string) (ResolvedArtifact, error)

ResolveArtifact derives the strongest available immutable identity for an already staged artifact. OCI sources resolve to the registry manifest digest; Git staging directories resolve to HEAD; all other staged/local directories use a deterministic content-tree SHA-256 fallback.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL