Go API documentation
github.com/rotari-dev/rotari/internal/artifactsource
Overview
package artifactsource // import "github.com/rotari-dev/rotari/internal/artifactsource"
Package artifactsource reads the configuration files that artifact discovery
inspects. It is the only file access discovery performs: it reads regular
files only, never blocks on a FIFO or device, and bounds how much it reads.
Symbolic links are followed, because configuration files are often linked; the
target must be a regular file. Reading runs as the job's own user, and discovery
records only the path references it classifies, never the contents.
Variables
var ErrNotRegular = errors.New("not a regular file")
ErrNotRegular is returned for a directory, FIFO, device, or socket.
Functions
func Read(path string) ([]byte, error)
Read returns the contents of the regular file at path, or an error when it
is not a regular file or is larger than artifact.MaxSourceBytes.
Types
type Cache struct {
// Has unexported fields.
}
Cache parses each configuration file once per version for one run,
so the tasks of an array, the members of a matrix, and retries that
name the same file share one parse. A version is the file's path, size,
and modification time; a file that changes during the run is parsed again.
Parse results are cached with their errors. Read errors are not, since the
stat that finds them is cheap. A Cache is safe for concurrent use.
func NewCache() *Cache
NewCache returns an empty Cache.
func (cache *Cache) References(path string) ([]artifact.ConfigReference, error)
References returns the references in the configuration file at path, parsing
it only when this version has not been parsed before. A file that is not
regular or is larger than artifact.MaxSourceBytes is rejected from its stat,
without being read. It is an artifact.ConfigReader.
func (cache *Cache) Script(path string) ([]byte, error)
Script returns the contents of the shell script at path, reading it only
when this version has not been read before. Shell source is parsed again
for each attempt, because PATH-E1 expands it with the attempt's values.
It is an artifact.SourceReader.