buildscript

package
v0.0.0-...-b6fc690 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFunctionMarshaler

func RegisterFunctionMarshaler(name string, marshalJSON MarshalerFunc)

RegisterFunctionMarshaler registers a buildexpression marshaler for a buildscript function. Marshalers accept a buildscript Value, and marshals it to buildexpression JSON (e.g. an object).

func RegisterFunctionPreUnmarshaler

func RegisterFunctionPreUnmarshaler(name string, preUnmarshal PreUnmarshalerFunc)

RegisterFunctionPreUnmarshaler registers a buildscript pre-unmarshaler for a buildexpression function. Pre-unmarshalers accept a JSON object of function arguments, transform those arguments as necessary, and return a JSON object for final unmarshaling to buildscript.

Types

type Assignment

type Assignment struct {
	Key   string `parser:"@Ident '='"`
	Value *Value `parser:"@@"`
}

func (*Assignment) MarshalJSON

func (a *Assignment) MarshalJSON() ([]byte, error)

type BuildScript

type BuildScript struct {
	// contains filtered or unexported fields
}

BuildScript is what we want consuming code to work with. This specifically makes the raw presentation private as no consuming code should ever be looking at the raw representation. Instead this package should facilitate the use-case of the consuming code through convenience methods that are easy to understand and work with.

func New

func New() (*BuildScript, error)

func Unmarshal

func Unmarshal(data []byte) (*BuildScript, error)

Unmarshal returns a structured form of the given AScript (on-disk format).

func UnmarshalBuildExpression

func UnmarshalBuildExpression(data []byte, atTime *time.Time) (*BuildScript, error)

UnmarshalBuildExpression returns a BuildScript constructed from the given build expression in JSON format. Build scripts and build expressions are almost identical, with the exception of the atTime field. Build expressions ALWAYS set at_time to `$at_time`, which refers to the timestamp on the commit, while buildscripts encode this timestamp as part of their definition. For this reason we have to supply the timestamp as a separate argument.

func (*BuildScript) AtTime

func (b *BuildScript) AtTime() *time.Time

func (*BuildScript) Clone

func (b *BuildScript) Clone() (*BuildScript, error)

func (*BuildScript) Equals

func (b *BuildScript) Equals(other *BuildScript) (bool, error)

func (*BuildScript) Marshal

func (b *BuildScript) Marshal() ([]byte, error)

Marshal returns this structure in AScript, suitable for writing to disk.

func (*BuildScript) MarshalBuildExpression

func (b *BuildScript) MarshalBuildExpression() ([]byte, error)

MarshalJSON returns this structure as a build expression in JSON format, suitable for sending to the Platform.

func (*BuildScript) MarshalJSON

func (b *BuildScript) MarshalJSON() ([]byte, error)

MarshalJSON returns this structure as a build expression in JSON format, suitable for sending to the Platform.

func (*BuildScript) Merge

func (b *BuildScript) Merge(other *BuildScript, strategies *mono_models.MergeStrategies) error

Merge merges the requirements from another BuildScript into this one, according to the given merge strategy. BuildScript merges are only possible if the scripts differ ONLY in requirements AND/OR at times.

func (*BuildScript) Platforms

func (b *BuildScript) Platforms() ([]strfmt.UUID, error)

func (*BuildScript) Requirements

func (b *BuildScript) Requirements() ([]Requirement, error)

func (*BuildScript) SetAtTime

func (b *BuildScript) SetAtTime(t time.Time)

func (*BuildScript) UpdatePlatform

func (b *BuildScript) UpdatePlatform(operation types.Operation, platformID strfmt.UUID) error

func (*BuildScript) UpdateRequirement

func (b *BuildScript) UpdateRequirement(operation types.Operation, requirement types.Requirement) error

type DependencyRequirement

type DependencyRequirement struct {
	types.Requirement
}

func (DependencyRequirement) IsRequirement

func (r DependencyRequirement) IsRequirement()

type FuncCall

type FuncCall struct {
	Name      string   `parser:"@Ident"`
	Arguments []*Value `parser:"'(' @@ (',' @@)* ','? ')'"`
}

func (*FuncCall) MarshalJSON

func (f *FuncCall) MarshalJSON() ([]byte, error)

type MarshalerFunc

type MarshalerFunc func([]*Value) ([]byte, error)

type Null

type Null struct {
	Null string `parser:"'null'"`
}

type PlatformNotFoundError

type PlatformNotFoundError struct {
	Id                     strfmt.UUID
	*locale.LocalizedError // for legacy non-user-facing error usages
}

type PreUnmarshalerFunc

type PreUnmarshalerFunc func(map[string]interface{}) (map[string]interface{}, error)

type Requirement

type Requirement interface {
	IsRequirement()
}

type RequirementNotFoundError

type RequirementNotFoundError struct {
	Name                   string
	*locale.LocalizedError // for legacy non-user-facing error usages
}

type RevisionRequirement

type RevisionRequirement struct {
	Name       string      `json:"name"`
	RevisionID strfmt.UUID `json:"revision_id"`
}

func (RevisionRequirement) IsRequirement

func (r RevisionRequirement) IsRequirement()

type UnknownRequirement

type UnknownRequirement struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

func (UnknownRequirement) IsRequirement

func (r UnknownRequirement) IsRequirement()

type Value

type Value struct {
	FuncCall *FuncCall `parser:"@@"`
	List     *[]*Value `parser:"| '[' (@@ (',' @@)* ','?)? ']'"`
	Str      *string   `parser:"| @String"` // note: this value is ALWAYS quoted
	Number   *float64  `parser:"| (@Float | @Int)"`
	Null     *Null     `parser:"| @@"`

	Assignment *Assignment    `parser:"| @@"`                        // only in FuncCall
	Object     *[]*Assignment `parser:"| '{' @@ (',' @@)* ','? '}'"` // only in List
	Ident      *string        `parser:"| @Ident"`                    // only in FuncCall or Assignment
}

func (*Value) MarshalJSON

func (v *Value) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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