plan

package
v0.0.0-...-d97b457 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package plan contains the interface about the build plan and the core plan operations.

Package plan is the interface for planners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[T any](value optional.Option[any], caster func(any) (T, error)) optional.Option[T]

Cast casts the value to the given type. If the value is not present or the type assertion fails, it returns None.

func Continue

func Continue() types.PlanMeta

Continue is a pseudo PlanMeta, indicating the planner executor to find the next matched one.

func ToWeakBoolE

func ToWeakBoolE(i interface{}) (bool, error)

ToWeakBoolE enhances ToBoolE to support more string values like "TRUE", "1", "FALSE", "0".

Types

type Identifier

type Identifier interface {
	PlanType() types.PlanType
	Match(afero.Fs) bool
	PlanMeta(NewPlannerOptions) types.PlanMeta
}

Identifier identifies the plan type and how to get the plan meta.

type ImmutableProjectConfiguration

type ImmutableProjectConfiguration interface {
	// Get returns the value of the given key. If the key is not present, it returns None.
	Get(key string) optional.Option[any]
}

ImmutableProjectConfiguration declares the common interface for getting values in project configuration.

type MutableProjectConfiguration

type MutableProjectConfiguration interface {
	// Set sets the value of the given key. The value set here has the highest priority.
	Set(key string, val any)
}

MutableProjectConfiguration declares the common interface for setting values in project configuration.

type NewPlannerOptions

type NewPlannerOptions struct {
	Source             afero.Fs
	Config             ImmutableProjectConfiguration
	SubmoduleName      string
	CustomBuildCommand *string
	CustomStartCommand *string
	OutputDir          *string
}

NewPlannerOptions is the options for NewPlanner.

type Planner

type Planner interface {
	Plan() (types.PlanType, types.PlanMeta)
}

Planner is the interface for planners.

func NewPlanner

func NewPlanner(opt *NewPlannerOptions, identifiers ...Identifier) Planner

NewPlanner creates a new Planner.

type ProjectConfiguration

type ProjectConfiguration interface {
	ImmutableProjectConfiguration
	MutableProjectConfiguration
}

ProjectConfiguration declares the common interface for project configuration.

func NewProjectConfigurationFromFs

func NewProjectConfigurationFromFs(fs afero.Fs, submoduleName string) ProjectConfiguration

NewProjectConfigurationFromFs creates a new ViperProjectConfiguration from fs.

If the configuration file is not found, it will print a warning and return a default configuration.

type ViperProjectConfiguration

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

ViperProjectConfiguration reads the extra configuration from the environment variable "ZBPACK_[CONFIG_KEY]" and "zbpack.toml" in the root directory of a project and turns it to a struct for easy access.

func (*ViperProjectConfiguration) Get

func (vpc *ViperProjectConfiguration) Get(key string) optional.Option[any]

Get returns the value of the given key. If the key is not present, it returns None.

func (*ViperProjectConfiguration) Set

func (vpc *ViperProjectConfiguration) Set(key string, val any)

Set sets the value of the given key. The value set here has the highest priority.

Jump to

Keyboard shortcuts

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