Documentation
¶
Overview ¶
Package resource provides abstractions for downloading remote resources from various sources (OCI registries, S3, HTTP/HTTPS).
Index ¶
Constants ¶
const ( // SourceTypeHTTPS represents an HTTPS resource source. SourceTypeHTTPS = "https" // SourceTypeHTTP represents an HTTP resource source. SourceTypeHTTP = "http" )
const ( // SourceTypeS3 represents an S3-compatible object storage source. SourceTypeS3 = "s3" // SourceTypeGCS represents a Google Cloud Storage source. SourceTypeGCS = "gcs" )
const (
// SourceTypeOCIImage represents an OCI image resource source.
SourceTypeOCIImage = "oci-image"
)
Variables ¶
This section is empty.
Functions ¶
func DecryptData ¶
DecryptData decrypts AES-256-GCM encrypted data. The encrypted data format is: nonce (12 bytes) || ciphertext+tag.
Types ¶
type Downloader ¶
type Downloader interface {
// Download fetches a resource from the given URL and writes it to destPath.
// For OCI images, destPath is a directory. For S3/HTTP, destPath is a file path.
Download(ctx context.Context, url string, destPath string) error
// Type returns the source type identifier (e.g., "oci-image", "s3", "https", "http").
Type() string
}
Downloader defines the interface for downloading resources from a remote source.
type GCSDownloader ¶
type GCSDownloader struct{}
GCSDownloader downloads resources from Google Cloud Storage.
func NewGCSDownloader ¶
func NewGCSDownloader() *GCSDownloader
NewGCSDownloader creates a new GCS downloader.
func (*GCSDownloader) Download ¶
Download fetches a resource from a GCS URL (gs://bucket/key) and writes it to destPath.
func (*GCSDownloader) Type ¶
func (g *GCSDownloader) Type() string
Type returns the source type identifier.
type HTTPDownloader ¶
type HTTPDownloader struct {
// contains filtered or unexported fields
}
HTTPDownloader downloads resources via HTTP/HTTPS.
func NewHTTPDownloader ¶
func NewHTTPDownloader() *HTTPDownloader
NewHTTPDownloader creates a new HTTP downloader (insecure, for testing).
func NewHTTPSDownloader ¶
func NewHTTPSDownloader() *HTTPDownloader
NewHTTPSDownloader creates a new HTTPS downloader.
func (*HTTPDownloader) Download ¶
Download fetches a resource from an HTTP/HTTPS URL and writes it to destPath.
func (*HTTPDownloader) Type ¶
func (h *HTTPDownloader) Type() string
Type returns the source type identifier.
type OCIClient ¶
type OCIClient interface {
PullAndDecrypt(ctx context.Context, source oci.ResourceSource, destDir string) error
ToDockerArchive(ctx context.Context, ociDir, destFile string) error
}
OCIClient defines the interface for OCI image operations.
type OCIDownloader ¶
type OCIDownloader struct {
// contains filtered or unexported fields
}
OCIDownloader adapts OCIClient to the Downloader interface. For OCI images, destPath is a directory where the OCI layout is written.
func NewOCIDownloader ¶
func NewOCIDownloader(client OCIClient) *OCIDownloader
NewOCIDownloader creates a new OCI downloader wrapping an OCI client.
func (*OCIDownloader) Client ¶
func (o *OCIDownloader) Client() OCIClient
Client returns the underlying OCIClient for OCI-specific operations like ToDockerArchive that aren't part of the generic Downloader interface.
func (*OCIDownloader) Download ¶
Download pulls an OCI image to the destination directory. Note: For OCI images, encryption/decryption is handled by Skopeo + CoCo Keyprovider transparently via ocicrypt, so this just does the pull.
func (*OCIDownloader) Type ¶
func (o *OCIDownloader) Type() string
Type returns the source type identifier.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps source type strings to Downloader implementations.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new empty downloader registry.
func (*Registry) Get ¶
func (r *Registry) Get(sourceType string) (Downloader, error)
Get retrieves a downloader for the given source type.
func (*Registry) Register ¶
func (r *Registry) Register(d Downloader)
Register adds a downloader to the registry for its declared type.
func (*Registry) SupportedTypes ¶
SupportedTypes returns a list of all registered source types.
type S3Downloader ¶
type S3Downloader struct {
// contains filtered or unexported fields
}
S3Downloader downloads resources from S3-compatible object storage. It uses the Google Cloud Storage client library with S3-compatible endpoints or can be configured for MinIO/AWS S3 via environment variables.
func NewS3Downloader ¶
func NewS3Downloader(endpoint string) *S3Downloader
NewS3Downloader creates a new S3 downloader. If endpoint is empty, standard AWS S3 environment credentials/config are used.
func (*S3Downloader) Download ¶
Download fetches a resource from an S3 URL (s3://bucket/key) and writes it to destPath.
func (*S3Downloader) Type ¶
func (s *S3Downloader) Type() string
Type returns the source type identifier.