instructions

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: MIT, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(ast *parser.Node, lint *linter.Linter) (stages []Stage, metaArgs []ArgCommand, err error)

Parse a GGUFPackerfile into a collection of buildable stages. metaArgs is a collection of ARG instructions that occur before the first FROM.

func ParseInstructionWithLinter

func ParseInstructionWithLinter(node *parser.Node, lint *linter.Linter) (v interface{}, err error)

Types

type AddCommand

type AddCommand struct {
	SourcesAndDest
	Chown           string
	Chmod           string
	Link            bool
	ExcludePatterns []string
	KeepGitDir      bool // whether to keep .git dir, only meaningful for git sources
	Checksum        string
	// contains filtered or unexported fields
}

AddCommand adds files from the provided sources to the target destination.

ADD foo /path

ADD supports tarball and remote URL handling, which may not always be desired - if you do not wish to have this automatic handling, use COPY.

func (*AddCommand) Expand

func (c *AddCommand) Expand(expander SingleWordExpander) error

func (*AddCommand) Location

func (c *AddCommand) Location() []parser.Range

Location of the command in source

func (*AddCommand) Name

func (c *AddCommand) Name() string

Name of the command

func (*AddCommand) String

func (c *AddCommand) String() string

type ArgCommand

type ArgCommand struct {
	Args []KeyValuePairOptional
	// contains filtered or unexported fields
}

ArgCommand adds the specified variable to the list of variables that can be passed to the builder using the --build-arg flag for expansion and substitution.

ARG name[=value]

func (*ArgCommand) Expand

func (c *ArgCommand) Expand(expander SingleWordExpander) error

func (*ArgCommand) Location

func (c *ArgCommand) Location() []parser.Range

Location of the command in source

func (*ArgCommand) Name

func (c *ArgCommand) Name() string

Name of the command

func (*ArgCommand) String

func (c *ArgCommand) String() string

type BFlags

type BFlags = instructions.BFlags

BFlags contains all flags information for the builder

func NewBFlagsWithArgs

func NewBFlagsWithArgs(args []string) *BFlags

NewBFlagsWithArgs returns the new BFlags struct with Args set to args

type CatCommand

type CatCommand struct {
	SourcesAndDest
	// contains filtered or unexported fields
}

CatCommand concatenate content to a file.

CAT "hi" /path

func (*CatCommand) Location

func (c *CatCommand) Location() []parser.Range

Location of the command in source

func (*CatCommand) Name

func (c *CatCommand) Name() string

Name of the command

func (*CatCommand) String

func (c *CatCommand) String() string

type CmdCommand

type CmdCommand struct {
	Args      []string
	Model     *CmdParameter
	Drafter   *CmdParameter
	Projector *CmdParameter
	Adapters  []CmdParameter
	// contains filtered or unexported fields
}

CmdCommand sets the default command to run in the container on start.

CMD ["-m", "model.gguf"]  # echo hi

func (*CmdCommand) Expand

func (c *CmdCommand) Expand(expander SingleWordExpander) error

func (*CmdCommand) Location

func (c *CmdCommand) Location() []parser.Range

Location of the command in source

func (*CmdCommand) Name

func (c *CmdCommand) Name() string

Name of the command

func (*CmdCommand) String

func (c *CmdCommand) String() string

type CmdParameter

type CmdParameter struct {
	Type  string
	Value string
	Index int
}

CmdParameter represents a parameter to a CMD.

type Command

type Command = instructions.Command

Command interface is implemented by every possible command in a GGUFPackerfile.

The interface only exposes the minimal common elements shared between every command, while more detailed information per-command can be extracted using runtime type analysis, e.g. type-switches.

type ConvertCommand

type ConvertCommand struct {
	SourcesAndDest
	From      string
	Class     string
	Type      string
	BaseModel string
	// contains filtered or unexported fields
}

ConvertCommand converts a model to target type GGUF file.

CONVERT foo /path

func (*ConvertCommand) Expand

func (c *ConvertCommand) Expand(expander SingleWordExpander) error

func (*ConvertCommand) GetFrom

func (c *ConvertCommand) GetFrom() string

func (*ConvertCommand) Location

func (c *ConvertCommand) Location() []parser.Range

Location of the command in source

func (*ConvertCommand) Name

func (c *ConvertCommand) Name() string

Name of the command

func (*ConvertCommand) String

func (c *ConvertCommand) String() string

type CopyCommand

type CopyCommand struct {
	SourcesAndDest
	From            string
	Chown           string
	Chmod           string
	Link            bool
	ExcludePatterns []string
	Parents         bool // parents preserves directory structure
	// contains filtered or unexported fields
}

CopyCommand copies files from the provided sources to the target destination.

COPY foo /path

Same as 'ADD' but without the magic additional tarball and remote URL handling.

func (*CopyCommand) Expand

func (c *CopyCommand) Expand(expander SingleWordExpander) error

func (*CopyCommand) GetFrom

func (c *CopyCommand) GetFrom() string

func (*CopyCommand) Location

func (c *CopyCommand) Location() []parser.Range

Location of the command in source

func (*CopyCommand) Name

func (c *CopyCommand) Name() string

Name of the command

func (*CopyCommand) String

func (c *CopyCommand) String() string

type Flag

type Flag = instructions.Flag

Flag contains all information for a flag

type FromGetter

type FromGetter interface {
	GetFrom() string
}

FromGetter is an interface for commands that be able to parameterize with --from flag.

type KeyValuePair

type KeyValuePair = instructions.KeyValuePair

KeyValuePair represents an arbitrary named value.

This is useful for commands containing key-value maps that want to preserve the order of insertion, instead of map[string]string which does not.

type KeyValuePairOptional

type KeyValuePairOptional = instructions.KeyValuePairOptional

KeyValuePairOptional is identical to KeyValuePair, but allows for optional values.

type KeyValuePairs

type KeyValuePairs = instructions.KeyValuePairs

KeyValuePairs is a slice of KeyValuePair

type LabelCommand

type LabelCommand struct {
	Labels KeyValuePairs
	// contains filtered or unexported fields
}

LabelCommand sets an image label in the output

LABEL some json data describing the image

func (*LabelCommand) Expand

func (c *LabelCommand) Expand(expander SingleWordExpander) error

func (*LabelCommand) Location

func (c *LabelCommand) Location() []parser.Range

Location of the command in source

func (*LabelCommand) Name

func (c *LabelCommand) Name() string

Name of the command

func (*LabelCommand) String

func (c *LabelCommand) String() string

type PlatformSpecific

type PlatformSpecific = instructions.PlatformSpecific

PlatformSpecific adds platform checks to a command

type QuantizeCommand

type QuantizeCommand struct {
	SourcesAndDest
	From               string
	Type               string
	Imatrix            string
	IncludeWeights     []string
	ExcludeWeights     []string
	LeaveOutputTensor  bool
	Pure               bool
	OutputTensorType   string
	TokenEmbeddingType string
	// contains filtered or unexported fields
}

QuantizeCommand converts a GGUF file to target type GGUF file.

Quantize foo /path

func (*QuantizeCommand) Expand

func (c *QuantizeCommand) Expand(expander SingleWordExpander) error

func (*QuantizeCommand) GetFrom

func (c *QuantizeCommand) GetFrom() string

func (*QuantizeCommand) Location

func (c *QuantizeCommand) Location() []parser.Range

Location of the command in source

func (*QuantizeCommand) Name

func (c *QuantizeCommand) Name() string

Name of the command

func (*QuantizeCommand) String

func (c *QuantizeCommand) String() string

type SingleWordExpander

type SingleWordExpander = instructions.SingleWordExpander

SingleWordExpander is a provider for variable expansion where a single word corresponds to a single output.

type SourceContent

type SourceContent struct {
	Path   string // path to the file
	Data   string // string content from the file
	Expand bool   // whether to expand file contents
}

SourceContent represents an anonymous file object

type SourcesAndDest

type SourcesAndDest struct {
	DestPath       string          // destination to write output
	SourcePaths    []string        // file path sources
	SourceContents []SourceContent // anonymous file sources
}

SourcesAndDest represent a collection of sources and a destination

func (*SourcesAndDest) Expand

func (s *SourcesAndDest) Expand(expander SingleWordExpander) error

func (*SourcesAndDest) ExpandRaw

func (s *SourcesAndDest) ExpandRaw(expander SingleWordExpander) error

type Stage

type Stage struct {
	Name       string    // name of the stage
	Commands   []Command // commands contained within the stage
	BaseName   string    // name of the base stage or source
	BaseDigest string    // digest of the base stage or source
	Platform   string    // platform of base source to use

	Comment string // doc-comment directly above the stage

	SourceCode string         // contents of the defining FROM command
	Location   []parser.Range // location of the defining FROM command

	CmdCommand *CmdCommand // CmdCommand of the stage
}

Stage represents a bundled collection of commands.

Each stage begins with a FROM command (which is consumed into the Stage), indicating the source or stage to derive from, and ends either at the end-of-the file, or the start of the next stage.

Stages can be named, and can be additionally configured to use a specific platform, in the case of a multi-arch base image.

func CurrentStage

func CurrentStage(s []Stage) (*Stage, error)

CurrentStage returns the last stage from a list of stages.

func (*Stage) AddCommand

func (s *Stage) AddCommand(cmd Command)

AddCommand appends a command to the stage.

type SupportsSingleWordExpansion

type SupportsSingleWordExpansion = instructions.SupportsSingleWordExpansion

SupportsSingleWordExpansion interface allows a command to support variable.

type SupportsSingleWordExpansionRaw

type SupportsSingleWordExpansionRaw = instructions.SupportsSingleWordExpansionRaw

SupportsSingleWordExpansionRaw interface allows a command to support variable expansion, while ensuring that minimal transformations are applied during expansion, so that quotes and other special characters are preserved.

type UnknownInstructionError

type UnknownInstructionError struct {
	Line        int
	Instruction string
}

UnknownInstructionError represents an error occurring when a command is unresolvable

func (*UnknownInstructionError) Error

func (e *UnknownInstructionError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL