Documentation
¶
Overview ¶
Package pxe aims to implement the PXE specification.
Index ¶
- Variables
- func GetFile(uri string, wd *url.URL) (io.Reader, error)
- func LazyGetFile(uri string, wd *url.URL) (io.Reader, error)
- func NewLazyOpener(open func() (io.Reader, error)) io.Reader
- func RegisterScheme(scheme string, fs FileScheme)
- type CachedFileScheme
- type CachingReader
- type Config
- type Entry
- type FileScheme
- type HTTPClient
- type LazyOpener
- type LocalFileClient
- type Schemes
- type TFTPClient
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConfigNotFound is returned when no suitable configuration file // was found by AppendFile. ErrConfigNotFound = errors.New("configuration file was not found") // ErrDefaultEntryNotFound is returned when the configuration file // names a default label that is not part of the configuration. ErrDefaultEntryNotFound = errors.New("default label not found in configuration") )
var ( // DefaultHTTPClient is the default HTTP FileScheme. // // It is not recommended to use this for HTTPS. We recommend creating an // http.Client that accepts only a private pool of certificates. DefaultHTTPClient = NewHTTPClient(http.DefaultClient) // DefaultTFTPClient is the default TFTP FileScheme. DefaultTFTPClient FileScheme // DefaultSchemes are the schemes supported by PXE by default. DefaultSchemes Schemes )
var ( // ErrNoSuchScheme is returned by Schemes.GetFile and // Schemes.LazyGetFile if there is no registered FileScheme // implementation for the given URI scheme. ErrNoSuchScheme = errors.New("no such scheme") )
Functions ¶
func LazyGetFile ¶
LazyGetFile calls LazyGetFile on DefaultSchemes. See Schemes.LazyGetFile.
func NewLazyOpener ¶
NewLazyOpener returns a lazy io.Reader based on `open`.
func RegisterScheme ¶
func RegisterScheme(scheme string, fs FileScheme)
RegisterScheme calls DefaultSchemes.Register.
Types ¶
type CachedFileScheme ¶
type CachedFileScheme struct {
// contains filtered or unexported fields
}
CachedFileScheme implements FileScheme and caches files downloaded from a FileScheme.
type CachingReader ¶
type CachingReader struct {
// contains filtered or unexported fields
}
CachingReader is a lazily caching wrapper of an io.Reader.
The wrapped io.Reader is only read from on demand, not upfront.
func NewCachingReader ¶
func NewCachingReader(r io.Reader) *CachingReader
NewCachingReader buffers reads from r.
r is only read from when Read() is called.
func (*CachingReader) NewReader ¶
func (cr *CachingReader) NewReader() io.Reader
NewReader returns a new io.Reader that reads cr from offset 0.
type Config ¶
type Config struct { // Entries is a map of label name -> label configuration. Entries map[string]*Entry // DefaultEntry is the default label key to use. // // If DefaultEntry is non-empty, the label is guaranteed to exist in // `Entries`. DefaultEntry string // contains filtered or unexported fields }
Config encapsulates a parsed Syslinux configuration file.
See http://www.syslinux.org/wiki/index.php?title=Config for the configuration file specification.
TODO: Tear apart parser internals from Config.
func NewConfig ¶
NewConfig returns a new PXE parser using working directory `wd` and default schemes.
See NewConfigWithSchemes for more details.
func NewConfigWithSchemes ¶
NewConfigWithSchemes returns a new PXE parser using working directory `wd` and schemes `s`.
If a path encountered in a configuration file is relative instead of a full URI, `wd` is used as the "working directory" of that relative path; the resulting URI is roughly `wd.String()/path`.
`s` is used to get files referred to by URIs.
func ParseConfigFile ¶
ParseConfigFile parses a PXE/Syslinux configuration as specified in http://www.syslinux.org/wiki/index.php?title=Config
Currently, only the APPEND, INCLUDE, KERNEL, LABEL, DEFAULT, and INITRD directives are partially supported.
`wd` is the default scheme, host, and path for any files named as a relative path. The default path for config files is assumed to be `wd.Path`/pxelinux.cfg/.
func (*Config) AppendFile ¶
AppendFile parses the config file downloaded from `uri` and adds it to `c`.
func (*Config) FindConfigFile ¶
FindConfigFile probes for config files based on the Mac and IP given.
type Entry ¶
type Entry struct { // Kernel is the kernel for this label. Kernel io.Reader // Initrd is the initial ramdisk for this label. Initrd io.Reader // Cmdline is the list of kernel command line parameters. Cmdline string }
Entry encapsulates a Syslinux "label" config directive.
type FileScheme ¶
type FileScheme interface { // GetFile returns a reader that gives the contents of `u`. // // It may do so by downloading `u` and placing it in a buffer, or by // returning an io.Reader that downloads the file. GetFile(u *url.URL) (io.Reader, error) }
FileScheme represents the implementation of a URI scheme and gives access to downloading files of that scheme.
For example, an http FileScheme implementation would download files using the HTTP protocol.
func NewCachedFileScheme ¶
func NewCachedFileScheme(fs FileScheme) FileScheme
NewCachedFileScheme returns a caching wrapper for the given FileScheme `fs`.
func NewTFTPClient ¶
func NewTFTPClient(c *tftp.Client) FileScheme
NewTFTPClient returns a new TFTP client based on the given tftp.Client.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient implements FileScheme for HTTP files.
func NewHTTPClient ¶
func NewHTTPClient(c *http.Client) *HTTPClient
NewHTTPClient returns a new HTTP FileScheme based on the given http.Client.
type LazyOpener ¶
type LazyOpener struct {
// contains filtered or unexported fields
}
LazyOpener is a lazy io.Reader.
LazyOpener will use a given open function to derive an io.Reader when Read is first called on the LazyOpener.
type LocalFileClient ¶
type LocalFileClient struct{}
LocalFileClient implements FileScheme for files on disk.
type Schemes ¶
type Schemes map[string]FileScheme
Schemes is a map of URI scheme identifier -> implementation that can download a file for that scheme.
func (Schemes) GetFile ¶
GetFile downloads the file with the given `uri`. `uri.Scheme` is used to select the FileScheme via `s`.
If `s` does not contain a FileScheme for `uri.Scheme`, ErrNoSuchScheme is returned.
If `uri` is just a relative path and not a full URI, `wd` is used as the "working directory" of that relative path; the resulting URI is roughly `path.Join(wd.String(), uri)`.
func (Schemes) LazyGetFile ¶
LazyGetFile returns a reader that will download the file given by `uri` when Read is called, based on `uri`s scheme. See Schemes.GetFile for more details.
func (Schemes) Register ¶
func (s Schemes) Register(scheme string, fs FileScheme)
Register registers a scheme identified by `scheme` to be `fs`.
type TFTPClient ¶
type TFTPClient struct {
// contains filtered or unexported fields
}
TFTPClient implements FileScheme for TFTP files.