config

package
v0.0.2-dev Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangedSetting

type ChangedSetting struct {
	Name               string
	OldValue           string
	NewValue           string
	AffectedContainers map[ContainerID]bool
}

A setting that has changed

type ContainerID

type ContainerID string

A Docker container name

const (
	ContainerID_Unknown ContainerID = ""
	ContainerID_Daemon  ContainerID = "daemon"
)

Enum to describe the names of Hyperdrive containers

type IParameter

type IParameter interface {
	// Get the parameter's common fields
	GetCommon() *ParameterCommon

	// Get the common fields from each ParameterOption (returns nil if this isn't a choice parameter)
	GetOptions() []*ParameterOptionCommon

	// Set the parameter to the default value
	SetToDefault(network rptypes.Network) error

	// Get the parameter's value as a string
	GetValueAsString() string

	// Deserializes a string into this parameter's value
	Deserialize(serializedParam string, network rptypes.Network) error
}

An interface for typed Parameter structs, to get common fields from them

type IParameterOption

type IParameterOption interface {
	// Get the parameter option's common fields
	Common() *ParameterOptionCommon
	GetValueAsString() string
}

An interface for typed ParameterOption structs, to get common fields from them

type Parameter

type Parameter[Type ParameterType] struct {
	*ParameterCommon
	Default map[rptypes.Network]Type
	Value   Type
	Options []*ParameterOption[Type]
}

A parameter that can be configured by the user

func (*Parameter[Type]) Deserialize

func (p *Parameter[Type]) Deserialize(serializedParam string, network rptypes.Network) error

Deserializes a string into this parameter's value

func (*Parameter[_]) GetCommon

func (p *Parameter[_]) GetCommon() *ParameterCommon

Get the parameter's common fields

func (*Parameter[Type]) GetDefault

func (p *Parameter[Type]) GetDefault(network rptypes.Network) (Type, error)

Get the default value for the provided network

func (*Parameter[_]) GetOptions

func (p *Parameter[_]) GetOptions() []*ParameterOptionCommon

Get the common fields from each ParameterOption (returns nil if this isn't a choice parameter)

func (*Parameter[_]) GetValueAsString

func (p *Parameter[_]) GetValueAsString() string

Get the parameter's value as a string

func (*Parameter[_]) SetToDefault

func (p *Parameter[_]) SetToDefault(network rptypes.Network) error

Set the value to the default for the provided config's network

type ParameterCommon

type ParameterCommon struct {
	// The parameter's ID, used for serialization and deserialization
	ID string

	// The parameter's human-readable name
	Name string

	// A description of this parameter / setting
	Description string

	// Whether or not this is a selection-type parameter with multiple options to choose from
	IsChoice bool

	// The max length of the parameter, in characters, if it's free-form input
	MaxLength int

	// An optional regex used to validate free-form input for the parameter
	Regex string

	// True if this is an advanced parameter and should be hidden unless advanced configuration mode is enabled
	Advanced bool

	// The list of Docker containers affected by changing this parameter
	// (these containers will require a restart for the change to take effect)
	AffectsContainers []ContainerID

	// A list of Docker container environment variables that should be set to this parameter's value
	EnvironmentVariables []string

	// Whether or not the parameter is allowed to be blank
	CanBeBlank bool

	// True to reset the parameter's value to the default option after Hyperdrive is updated
	OverwriteOnUpgrade bool

	// Descriptions of the parameter that change depending on the selected network
	DescriptionsByNetwork map[rptypes.Network]string
}

Common fields across all Parameter instances

type ParameterOption

type ParameterOption[Type ParameterType] struct {
	*ParameterOptionCommon

	// The underlying value for this option
	Value Type
}

A single option in a choice parameter

func (*ParameterOption[_]) Common

func (p *ParameterOption[_]) Common() *ParameterOptionCommon

Get the parameter option's common fields

func (*ParameterOption[_]) GetValueAsString

func (p *ParameterOption[_]) GetValueAsString() string

Get the parameter option's value as a string

type ParameterOptionCommon

type ParameterOptionCommon struct {
	// The option's human-readable name, to be used in config displays
	Name string

	// A description signifying what this option means
	Description string
}

Common fields across all ParameterOption instances

type ParameterType

type ParameterType interface {
	bool | string
}

Legal types for Parameters to use

Jump to

Keyboard shortcuts

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