Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteTemporaryDir(path string) error
- func DeleteTemporaryFile(path string) error
- func DeregisterInternalURL(path string)
- func Download(context contextpkg.Context, url URL, temporaryPathPattern string) (*os.File, error)
- func DownloadTo(context contextpkg.Context, url URL, path string) error
- func GetFormat(path string) string
- func GetPath(url URL) (string, error)
- func GetTemporaryPathPattern(key string) string
- func IsNotFound(err error) bool
- func IsNotImplemented(err error) bool
- func IsValidTarballArchiveFormat(archiveFormat string) bool
- func OpenFirstTarballInTarball(reader io.Reader) (io.Reader, error)
- func ReadBytes(context contextpkg.Context, url URL) ([]byte, error)
- func ReadString(context contextpkg.Context, url URL) (string, error)
- func ReadToInternalURLsFromFS(context contextpkg.Context, fs fspkg.FS, root string, ...) error
- func RegisterInternalURL(path string, content any) error
- func Size(context contextpkg.Context, url URL) (int64, error)
- func ToNetURL(url URL) (*neturlpkg.URL, error)
- func URLPathToFilePath(path string) string
- func UpdateInternalURL(path string, content any)
- type Context
- func (self *Context) GetCredentials(host string) *Credentials
- func (self *Context) GetHTTPRoundTripper(host string) http.RoundTripper
- func (self *Context) GetLocalPath(context contextpkg.Context, url URL) (string, error)
- func (self *Context) GetMapping(fromUrl string) (string, bool)
- func (self *Context) Map(fromUrl string, toUrl string)
- func (self *Context) NewAnyOrFileURL(urlOrPath string) URL
- func (self *Context) NewDockerURL(neturl *neturlpkg.URL) *DockerURL
- func (self *Context) NewFileURL(filePath string) *FileURL
- func (self *Context) NewGitURL(path string, repositoryUrl string) *GitURL
- func (self *Context) NewInternalURL(path string) *InternalURL
- func (self *Context) NewMockURL(scheme string, path string, content any) *MockURL
- func (self *Context) NewNetworkURL(neturl *neturlpkg.URL) *NetworkURL
- func (self *Context) NewURL(url string) (URL, error)
- func (self *Context) NewValidAnyOrFileURL(context contextpkg.Context, urlOrPath string, origins []URL) (URL, error)
- func (self *Context) NewValidDockerURL(neturl *neturlpkg.URL) (*DockerURL, error)
- func (self *Context) NewValidFileURL(filePath string) (*FileURL, error)
- func (self *Context) NewValidGitURL(path string, repositoryUrl string) (*GitURL, error)
- func (self *Context) NewValidInternalURL(path string) (*InternalURL, error)
- func (self *Context) NewValidNetworkURL(neturl *neturlpkg.URL) (*NetworkURL, error)
- func (self *Context) NewValidURL(context contextpkg.Context, urlOrPath string, origins []URL) (URL, error)
- func (self *Context) NewWorkingDirFileURL() (*FileURL, error)
- func (self *Context) OpenFile(context contextpkg.Context, url URL) (*os.File, error)
- func (self *Context) ParseGitURL(url string) (*GitURL, error)
- func (self *Context) ParseTarballURL(url string) (*TarballURL, error)
- func (self *Context) ParseValidGitURL(url string) (*GitURL, error)
- func (self *Context) ParseValidTarballURL(context contextpkg.Context, url string) (*TarballURL, error)
- func (self *Context) ParseValidZipURL(context contextpkg.Context, url string) (*ZipURL, error)
- func (self *Context) ParseZipURL(url string) (*ZipURL, error)
- func (self *Context) ReadToInternalURL(path string, reader io.Reader) (*InternalURL, error)
- func (self *Context) ReadToInternalURLFromStdin(context contextpkg.Context, format string) (*InternalURL, error)
- func (self *Context) Release() error
- func (self *Context) SetCredentials(host string, username string, password string, token string)
- func (self *Context) SetHTTPRoundTripper(host string, httpRoundTripper http.RoundTripper)
- type Credentials
- type DockerURL
- func (self *DockerURL) Context() *Context
- func (self *DockerURL) Format() string
- func (self *DockerURL) Key() string
- func (self *DockerURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *DockerURL) Origin() URL
- func (self *DockerURL) Relative(path string) URL
- func (self *DockerURL) RemoteOptions(context contextpkg.Context) []remote.Option
- func (self *DockerURL) String() string
- func (self *DockerURL) WriteFirstLayer(context contextpkg.Context, writer io.Writer) error
- func (self *DockerURL) WriteTarball(context contextpkg.Context, writer io.Writer) error
- type FileURL
- func (self *FileURL) Context() *Context
- func (self *FileURL) Format() string
- func (self *FileURL) Key() string
- func (self *FileURL) NewValidRelativeFileURL(filePath string) (*FileURL, error)
- func (self *FileURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *FileURL) Origin() URL
- func (self *FileURL) Relative(path string) URL
- func (self *FileURL) String() string
- type FirstTarballInTarballDecoder
- type GitURL
- func (self *GitURL) Context() *Context
- func (self *GitURL) Format() string
- func (self *GitURL) Key() string
- func (self *GitURL) NewValidRelativeGitURL(path string) (*GitURL, error)
- func (self *GitURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *GitURL) OpenRepository() (*git.Repository, error)
- func (self *GitURL) Origin() URL
- func (self *GitURL) Relative(path string) URL
- func (self *GitURL) String() string
- type InternalURL
- func (self *InternalURL) Context() *Context
- func (self *InternalURL) Format() string
- func (self *InternalURL) Key() string
- func (self *InternalURL) NewValidRelativeInternalURL(path string) (*InternalURL, error)
- func (self *InternalURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *InternalURL) Origin() URL
- func (self *InternalURL) Relative(path string) URL
- func (self *InternalURL) SetContent(content any)
- func (self *InternalURL) String() string
- type InternalURLProvider
- type MockURL
- func (self *MockURL) Context() *Context
- func (self *MockURL) Format() string
- func (self *MockURL) Key() string
- func (self *MockURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *MockURL) Origin() URL
- func (self *MockURL) Relative(path string) URL
- func (self *MockURL) String() string
- type NetworkURL
- func (self *NetworkURL) Context() *Context
- func (self *NetworkURL) Format() string
- func (self *NetworkURL) Key() string
- func (self *NetworkURL) NewValidRelativeNetworkURL(path string) (*NetworkURL, error)
- func (self *NetworkURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *NetworkURL) Origin() URL
- func (self *NetworkURL) Relative(path string) URL
- func (self *NetworkURL) String() string
- type NotFound
- type NotImplemented
- type TarballEntryReader
- type TarballReader
- type TarballURL
- func (self *TarballURL) Context() *Context
- func (self *TarballURL) Format() string
- func (self *TarballURL) Key() string
- func (self *TarballURL) NewValidRelativeTarballURL(context contextpkg.Context, path string) (*TarballURL, error)
- func (self *TarballURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *TarballURL) OpenArchive(context contextpkg.Context) (*TarballReader, error)
- func (self *TarballURL) Origin() URL
- func (self *TarballURL) Relative(path string) URL
- func (self *TarballURL) String() string
- type URL
- type ZipEntryReader
- type ZipReader
- type ZipURL
- func (self *ZipURL) Context() *Context
- func (self *ZipURL) Format() string
- func (self *ZipURL) Key() string
- func (self *ZipURL) NewValidRelativeZipURL(context contextpkg.Context, path string) (*ZipURL, error)
- func (self *ZipURL) Open(context contextpkg.Context) (io.ReadCloser, error)
- func (self *ZipURL) OpenArchive(context contextpkg.Context) (*ZipReader, error)
- func (self *ZipURL) Origin() URL
- func (self *ZipURL) Relative(path string) URL
- func (self *ZipURL) String() string
Constants ¶
const PathSeparator = string(filepath.Separator)
Variables ¶
var TARBALL_ARCHIVE_FORMATS = []string{"tar", "tar.gz"}
Functions ¶
func DeleteTemporaryDir ¶
func DeleteTemporaryFile ¶
func DeregisterInternalURL ¶
func DeregisterInternalURL(path string)
func DownloadTo ¶
func DownloadTo(context contextpkg.Context, url URL, path string) error
func GetTemporaryPathPattern ¶ added in v0.2.4
func IsNotFound ¶
func IsNotImplemented ¶ added in v0.2.8
func OpenFirstTarballInTarball ¶ added in v0.2.2
func ReadString ¶
func ReadString(context contextpkg.Context, url URL) (string, error)
func ReadToInternalURLsFromFS ¶ added in v0.2.7
func RegisterInternalURL ¶
`content` can be []byte or an InternalURLProvider. Other types will be converted to string and then to []byte.
func URLPathToFilePath ¶ added in v0.2.1
func UpdateInternalURL ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() *Context
func (*Context) GetCredentials ¶
func (self *Context) GetCredentials(host string) *Credentials
Not thread-safe
func (*Context) GetHTTPRoundTripper ¶
func (self *Context) GetHTTPRoundTripper(host string) http.RoundTripper
Not thread-safe
func (*Context) GetLocalPath ¶
Will download the file to the local temporary directory if not already locally available
func (*Context) NewAnyOrFileURL ¶ added in v0.3.1
Parses the argument as *either* an absolute URL *or* a file path.
In essence attempts to parse the URL via [NewURL] and if that fails treats the URL as a file path and returns a *FileURL.
To support relative URLs, see [NewValidAnyOrFileURL].
On Windows note that if there happens to be a drive that has the same name as a supported URL scheme (e.g. "http") then callers would have to provide a full file URL, e.g. instead of "http:\Dir\file" provide "file:///http:/Dir/file", otherwise it will be parsed as a URL of that scheme.
func (*Context) NewDockerURL ¶ added in v0.2.0
func (*Context) NewFileURL ¶ added in v0.2.0
Note that the argument is treated as an OS file path (using backslashes on Windows).
Directories *must* be suffixed with an OS path separator.
func (*Context) NewInternalURL ¶ added in v0.2.0
func (self *Context) NewInternalURL(path string) *InternalURL
func (*Context) NewMockURL ¶ added in v0.2.9
func (*Context) NewNetworkURL ¶ added in v0.2.0
func (self *Context) NewNetworkURL(neturl *neturlpkg.URL) *NetworkURL
func (*Context) NewURL ¶ added in v0.2.0
Parses the argument as an absolute URL.
To support relative URLs, see [NewValidURL].
If you are expecting either a URL *or* a file path, consider [NewAnyOrFileURL].
func (*Context) NewValidAnyOrFileURL ¶ added in v0.3.1
func (self *Context) NewValidAnyOrFileURL(context contextpkg.Context, urlOrPath string, origins []URL) (URL, error)
Parses the argument as an absolute URL *or* an absolute file path *or* a relative path. Relative paths support ".." and ".", with the returned URL path being absolute.
The returned URL is "valid", meaning that during this call it was possible to call Open on it. Of course this can't guarantee that future calls to Open will succeed.
Relative URLs are tested against the origins argument in order. The first valid URL will be returned and the remaining origins will be ignored.
func (*Context) NewValidDockerURL ¶ added in v0.2.0
func (*Context) NewValidFileURL ¶ added in v0.2.0
Note that the argument is treated as an OS file path (using backslashes on Windows).
If the path is a directory, it will automatically be suffixed with an OS path separator if it doesn't already have one.
func (*Context) NewValidGitURL ¶ added in v0.2.0
func (*Context) NewValidInternalURL ¶ added in v0.2.0
func (self *Context) NewValidInternalURL(path string) (*InternalURL, error)
func (*Context) NewValidNetworkURL ¶ added in v0.2.0
func (self *Context) NewValidNetworkURL(neturl *neturlpkg.URL) (*NetworkURL, error)
func (*Context) NewValidURL ¶ added in v0.2.0
func (self *Context) NewValidURL(context contextpkg.Context, urlOrPath string, origins []URL) (URL, error)
Parses the argument as *either* an absolute URL *or* a relative path. Relative paths support ".." and ".", with the returned URL path being absolute.
The returned URL is "valid", meaning that during this call it was possible to call Open on it. Of course this can't guarantee that future calls to Open will succeed.
Relative URLs are tested against the origins argument in order. The first valid URL will be returned and the remaining origins will be ignored.
If you are expecting either a URL *or* a file path, consider [NewValidAnyOrFileURL].
func (*Context) NewWorkingDirFileURL ¶ added in v0.3.0
func (*Context) ParseGitURL ¶ added in v0.2.0
func (*Context) ParseTarballURL ¶ added in v0.2.0
func (self *Context) ParseTarballURL(url string) (*TarballURL, error)
func (*Context) ParseValidGitURL ¶ added in v0.2.0
func (*Context) ParseValidTarballURL ¶ added in v0.2.0
func (self *Context) ParseValidTarballURL(context contextpkg.Context, url string) (*TarballURL, error)
func (*Context) ParseValidZipURL ¶ added in v0.2.0
func (*Context) ParseZipURL ¶ added in v0.2.0
func (*Context) ReadToInternalURL ¶ added in v0.2.0
func (*Context) ReadToInternalURLFromStdin ¶ added in v0.2.0
func (self *Context) ReadToInternalURLFromStdin(context contextpkg.Context, format string) (*InternalURL, error)
func (*Context) SetCredentials ¶
Not thread-safe
func (*Context) SetHTTPRoundTripper ¶
func (self *Context) SetHTTPRoundTripper(host string, httpRoundTripper http.RoundTripper)
Not thread-safe
type Credentials ¶
type DockerURL ¶
func (*DockerURL) Open ¶
func (self *DockerURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*DockerURL) RemoteOptions ¶
func (self *DockerURL) RemoteOptions(context contextpkg.Context) []remote.Option
func (*DockerURL) WriteFirstLayer ¶ added in v0.2.2
func (*DockerURL) WriteTarball ¶
type FileURL ¶
type FileURL struct { Path string // contains filtered or unexported fields }
func (*FileURL) NewValidRelativeFileURL ¶ added in v0.2.0
Note that the argument is treated as an OS file path (using backslashes on Windows).
func (*FileURL) Open ¶
func (self *FileURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
type FirstTarballInTarballDecoder ¶ added in v0.2.2
type FirstTarballInTarballDecoder struct {
// contains filtered or unexported fields
}
func NewFirstTarballInTarballDecoder ¶ added in v0.2.2
func NewFirstTarballInTarballDecoder(reader io.Reader) *FirstTarballInTarballDecoder
func (*FirstTarballInTarballDecoder) Decode ¶ added in v0.2.2
func (self *FirstTarballInTarballDecoder) Decode() io.Reader
func (*FirstTarballInTarballDecoder) Drain ¶ added in v0.2.2
func (self *FirstTarballInTarballDecoder) Drain()
type GitURL ¶
type GitURL struct { Path string RepositoryURL string Reference string Username string Password string // contains filtered or unexported fields }
func (*GitURL) NewValidRelativeGitURL ¶ added in v0.2.0
func (*GitURL) Open ¶
func (self *GitURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*GitURL) OpenRepository ¶
type InternalURL ¶
type InternalURL struct { Path string Content any // []byte or InternalURLProvider // contains filtered or unexported fields }
func (*InternalURL) NewValidRelativeInternalURL ¶ added in v0.2.0
func (self *InternalURL) NewValidRelativeInternalURL(path string) (*InternalURL, error)
func (*InternalURL) Open ¶
func (self *InternalURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*InternalURL) SetContent ¶
func (self *InternalURL) SetContent(content any)
func (*InternalURL) String ¶
func (self *InternalURL) String() string
URL interface fmt.Stringer interface
type InternalURLProvider ¶ added in v0.2.4
type InternalURLProvider interface {
OpenPath(context contextpkg.Context, path string) (io.ReadCloser, error)
}
type MockURL ¶ added in v0.2.9
type MockURL struct { Scheme string Path string Content any // []byte or InternalURLProvider // contains filtered or unexported fields }
func (*MockURL) Open ¶ added in v0.2.9
func (self *MockURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
type NetworkURL ¶
func (*NetworkURL) NewValidRelativeNetworkURL ¶ added in v0.2.0
func (self *NetworkURL) NewValidRelativeNetworkURL(path string) (*NetworkURL, error)
func (*NetworkURL) Open ¶
func (self *NetworkURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*NetworkURL) String ¶
func (self *NetworkURL) String() string
URL interface fmt.Stringer interface
type NotImplemented ¶ added in v0.2.8
type NotImplemented struct {
Message string
}
func NewNotImplemented ¶ added in v0.2.8
func NewNotImplemented(message string) *NotImplemented
func NewNotImplementedf ¶ added in v0.2.8
func NewNotImplementedf(format string, arg ...any) *NotImplemented
func (*NotImplemented) Error ¶ added in v0.2.8
func (self *NotImplemented) Error() string
error interface
type TarballEntryReader ¶
type TarballEntryReader struct {
TarballReader *TarballReader
}
func NewTarballEntryReader ¶
func NewTarballEntryReader(tarballReader *TarballReader) *TarballEntryReader
func (*TarballEntryReader) Close ¶
func (self *TarballEntryReader) Close() error
io.Closer interface
type TarballReader ¶
type TarballReader struct { TarReader *tar.Reader ArchiveReader io.ReadCloser CompressionReader io.ReadCloser }
func NewTarballReader ¶
func NewTarballReader(reader *tar.Reader, archiveReader io.ReadCloser, compressionReader io.ReadCloser) *TarballReader
func OpenTarballFromFile ¶
func OpenTarballFromFile(file *os.File) (*TarballReader, error)
func (*TarballReader) Open ¶
func (self *TarballReader) Open(path string) (*TarballEntryReader, error)
type TarballURL ¶
func NewTarballURL ¶
func NewTarballURL(path string, archiveUrl URL, archiveFormat string) *TarballURL
func NewValidTarballURL ¶
func NewValidTarballURL(context contextpkg.Context, path string, archiveUrl URL, archiveFormat string) (*TarballURL, error)
func (*TarballURL) NewValidRelativeTarballURL ¶ added in v0.2.0
func (self *TarballURL) NewValidRelativeTarballURL(context contextpkg.Context, path string) (*TarballURL, error)
func (*TarballURL) Open ¶
func (self *TarballURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*TarballURL) OpenArchive ¶
func (self *TarballURL) OpenArchive(context contextpkg.Context) (*TarballReader, error)
func (*TarballURL) String ¶
func (self *TarballURL) String() string
URL interface fmt.Stringer interface
type URL ¶
type URL interface { // Returns a string representation of the URL that can be used by [NewURL] to // recreate this URL. String() string // Format of the URL content's default representation. // // Should return "yaml", "json", "xml", etc., or an empty string if the format // is unknown. Format() string // Returns the equivalent of a "base directory" for the URL. // // The origin can be used in two ways: // // 1. You can call Relative on it to get a sibling URL to this one (relative to // the same "base directory"). // 2. You can use it in the origins list argument of [NewValidURL] for the same // purpose. // // Note that the origin might not be a valid URL in itself, e.g. you might not // be able to call Open on it. Origin() URL // Parses the argument as a path relative to this URL. That means this this // URL is treated as a "directory". // // Returns an absolute URL. Relative(path string) URL // Returns a string that uniquely identifies this URL. // // Useful as map keys. Key() string // Opens the URL for reading. // // It is the caller's responsibility to Close the reader. Open(context contextpkg.Context) (io.ReadCloser, error) // The context used to create this URL. Context() *Context }
type ZipEntryReader ¶
type ZipEntryReader struct { EntryReader io.ReadCloser ZipReader *ZipReader }
func NewZipEntryReader ¶
func NewZipEntryReader(entryReader io.ReadCloser, zipReader *ZipReader) *ZipEntryReader
type ZipURL ¶
func NewValidZipURL ¶
func (*ZipURL) NewValidRelativeZipURL ¶ added in v0.2.0
func (*ZipURL) Open ¶
func (self *ZipURL) Open(context contextpkg.Context) (io.ReadCloser, error)
URL interface
func (*ZipURL) OpenArchive ¶
func (self *ZipURL) OpenArchive(context contextpkg.Context) (*ZipReader, error)