loader

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2016 License: MIT Imports: 13 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveModule

func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string

ActiveModule returns the active module ID for the given module kind as stored in the given local configuration file.

func BootstrapConfig

func BootstrapConfig(spec ConfigSpec) error

BootstrapConfig can be used to bootstrap SalsaFlow configuration according to the given configuration specification.

func LoadConfig

func LoadConfig(spec ConfigSpec) (err error)

LoadConfig can be used to load SalsaFlow configuration according to the given configuration specification.

The main difference between BootstrapConfig and LoadConfig is that LoadConfig returns an error when the local configuration is not valid. While `repo bootstrap` is using BootstrapConfig, all other modules and commands should be using LoadConfig. The local configuration file is only supposed to be generated once during `repo bootstrap`.

func RegisterBootstrapConfigSpec

func RegisterBootstrapConfigSpec(spec ConfigSpec)

RegisterBootstrapConfigSpec can be used to register a config spec that is run during `repo bootstrap`.

This function is exported for internal use by SalsaFlow packages, it is not supposed to be used by modules.

func RunCommonBootstrapDialog

func RunCommonBootstrapDialog() error

RunCommonBootstrapDialog calls BootstrapConfig for every ConfigSpec registered over RegisterBootstrapConfigSpec().

func RunModuleBootstrapDialog

func RunModuleBootstrapDialog(sections ...*ModuleDialogSection) error

RunModuleBootstrapDialog runs the module bootstrapping dialog for every section specification passed into the function.

func SetActiveModule

func SetActiveModule(
	local *config.LocalConfig,
	moduleKind ModuleKind,
	moduleId string,
) (modified bool, err error)

SetActiveModule can be used to set the active module ID for the given module kind.

Types

type ConfigContainer

type ConfigContainer interface {

	// PromptUserForConfig is triggered when the config section
	// is not valid or it is not possible to unmarshal it.
	PromptUserForConfig() error
}

ConfigContainer represents the global or local configuration section for the given configuration specification. It specified how to generate, marshal, unmarshal and validate the configuration section for the key specified by the config spec.

type ConfigSpec

type ConfigSpec interface {

	// ConfigKey returns the globally unique string representing this config spec.
	ConfigKey() string

	// GlobalConfig returns the spec for the global configuration file.
	// The global config is always handled before the local one,
	// so the local spec can access data from the global one without any worries.
	GlobalConfig() ConfigContainer

	// LocalConfig returns the spec for the local configuration file.
	LocalConfig() ConfigContainer
}

ConfigSpec represents a complete configuration specification. It says how to generate, marshal, unmarshal and validate both local and global configuration sections for the given configuration key.

type Marshaller

type Marshaller interface {
	Marshal() (interface{}, error)
}

A ConfigContainer can implement Marshaller to overwrite the default marshalling mechanism. By default the ConfigContainer is taken as is and marshalled (passed to the encoder).

type Module

type Module interface {

	// Id returns the string globally identifying the module.
	// Module authors are advised to use a reversed URL as seen in Java world,
	// e.g. com.example.codereview.servicename
	Id() string

	// Kind returns the kind of this module.
	Kind() ModuleKind

	// ConfigSpec returns the configuration specification
	// to be used when bootstrapping the module.
	ConfigSpec() ModuleConfigSpec
}

type ModuleConfigSpec

type ModuleConfigSpec interface {
	ConfigSpec

	// ModuleKind returns the module kind for the associated module.
	ModuleKind() ModuleKind
}

ModuleConfigSpec represents a module config spec, which is a config spec that also specified a module kind.

type ModuleDialogSection

type ModuleDialogSection struct {
	AvailableModules []Module
	Optional         bool
}

ModuleDialogSection represents a section in the module bootstrapping dialog.

type ModuleKind

type ModuleKind string
const (
	ModuleKindIssueTracking ModuleKind = "issue_tracking"
	ModuleKindCodeReview    ModuleKind = "code_review"
	ModuleKindReleaseNotes  ModuleKind = "release_notes"
)

type Unmarshaller

type Unmarshaller interface {

	// Unmarshal is passed a function that is to be used to fill
	// an object with the data from the associated config section.
	Unmarshal(unmarshal func(interface{}) error) error
}

A ConfigContainer can implement Unmarshaller to overwrite the default unmarshalling mechanism. By default the ConfigContainer is just filled with the raw data from the associated config section.

type Validator

type Validator interface {
	Validate(sectionPath string) error
}

A ConfigContainer can implement Validator to overwrite the default validating mechanism. By default the ConfigContainer needs to have all exported fields filled to be considered valid.

Jump to

Keyboard shortcuts

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