Documentation
¶
Overview ¶
Package imports provides functionality for processing stack imports, including support for remote imports from URLs via go-getter.
Index ¶
- func DownloadRemoteImport(atmosConfig *schema.AtmosConfiguration, uri string) (string, error)
- func HasSchemeSeparator(uri string) bool
- func IsGCSURI(uri string) bool
- func IsGitURI(uri string) bool
- func IsHTTPURI(uri string) bool
- func IsLocalPath(uri string) bool
- func IsRemote(uri string) bool
- func IsS3URI(uri string) bool
- func ProcessImportPath(atmosConfig *schema.AtmosConfiguration, basePath, importPath string) (string, error)
- func ResolveImportPaths(atmosConfig *schema.AtmosConfiguration, basePath string, importPaths []string) ([]string, error)
- type RemoteImportMatch
- type RemoteImporter
- type RemoteImporterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadRemoteImport ¶
func DownloadRemoteImport(atmosConfig *schema.AtmosConfiguration, uri string) (string, error)
DownloadRemoteImport is a convenience function that uses the global importer.
func HasSchemeSeparator ¶
HasSchemeSeparator checks if the URI contains a scheme separator. Examples:
- true: "https://github.com", "git::https://...", "s3::https://...".
- false: "github.com/repo", "./local/path", "components/terraform".
func IsGitURI ¶
IsGitURI checks if the URI appears to be a Git repository URL. Detection rules: 1. Explicit git:: prefix. 2. SCP-style URLs (git@github.com:owner/repo.git). 3. Known Git hosting platforms (github.com, gitlab.com, bitbucket.org) in host. 4. .git extension in path (not in host). 5. Azure DevOps _git/ pattern in path.
func IsLocalPath ¶
IsLocalPath checks if the URI is a local file system path. Examples:
- Local: "/absolute/path", "./relative/path", "../parent/path", "components/terraform".
- Remote: "github.com/owner/repo", "https://example.com", "git.company.com/repo".
func IsRemote ¶
IsRemote returns true if the URI is a remote URL that should be downloaded. This is the inverse of IsLocalPath.
func IsS3URI ¶
IsS3URI checks if the URI is an S3 URI. Go-getter supports both explicit s3:: prefix and auto-detected .amazonaws.com URLs.
func ProcessImportPath ¶
func ProcessImportPath(atmosConfig *schema.AtmosConfiguration, basePath, importPath string) (string, error)
ProcessImportPath resolves an import path (local or remote) to a local file path. For local paths, it joins with basePath. For remote URLs, it downloads and returns the temp file path.
func ResolveImportPaths ¶
func ResolveImportPaths(atmosConfig *schema.AtmosConfiguration, basePath string, importPaths []string) ([]string, error)
ResolveImportPaths resolves multiple import paths, returning local file paths. This is a convenience function for batch processing.
Types ¶
type RemoteImportMatch ¶
RemoteImportMatch is a resolved remote stack import ready for local processing.
func ResolveRemoteImport ¶
func ResolveRemoteImport(atmosConfig *schema.AtmosConfiguration, uri string) ([]RemoteImportMatch, error)
ResolveRemoteImport is a convenience function that uses the global importer.
func ResolveRemoteImportNested ¶
func ResolveRemoteImportNested(atmosConfig *schema.AtmosConfiguration, uri, nestedImports, ttl string) ([]RemoteImportMatch, error)
ResolveRemoteImportNested is a convenience function that uses the global importer. The ttl controls cross-run reuse of the cloned source repo for git subdir imports (see ensureSourceDir); an empty ttl refreshes the clone once per invocation.
type RemoteImporter ¶
type RemoteImporter struct {
// contains filtered or unexported fields
}
RemoteImporter handles downloading stack imports from remote URLs.
func NewRemoteImporter ¶
func NewRemoteImporter(atmosConfig *schema.AtmosConfiguration, opts ...RemoteImporterOption) (*RemoteImporter, error)
NewRemoteImporter creates a new RemoteImporter.
func (*RemoteImporter) ClearCache ¶
func (r *RemoteImporter) ClearCache() error
ClearCache removes all cached imports.
func (*RemoteImporter) Download ¶
func (r *RemoteImporter) Download(uri string) (string, error)
Download fetches a remote import and returns the local path. Downloads are cached by URL hash to avoid redundant downloads. Uses file locking and atomic writes for safe concurrent access.
func (*RemoteImporter) Resolve ¶
func (r *RemoteImporter) Resolve(uri string) ([]RemoteImportMatch, error)
Resolve fetches a remote import and returns all local stack files it resolves to.
The cached source clone is refreshed on every invocation (no cross-run reuse); use ResolveRemoteImportNested with a TTL when cross-run cache reuse is desired.
func (*RemoteImporter) ResolveNested ¶
func (r *RemoteImporter) ResolveNested(uri, nestedImports string) ([]RemoteImportMatch, error)
ResolveNested fetches a remote import and returns all local stack files it resolves to, preserving remote source context when nested imports should resolve remotely.
The cached source clone is refreshed on every invocation (no cross-run reuse); use ResolveRemoteImportNested with a TTL when cross-run cache reuse is desired.
type RemoteImporterOption ¶
type RemoteImporterOption func(*RemoteImporter)
RemoteImporterOption is a functional option for configuring RemoteImporter.
func WithCache ¶
func WithCache(c *cache.FileCache) RemoteImporterOption
WithCache sets a custom FileCache (useful for testing).
func WithDownloader ¶
func WithDownloader(d downloader.FileDownloader) RemoteImporterOption
WithDownloader sets a custom downloader (useful for testing).