Documentation ¶
Index ¶
- func ActiveModule(local *config.LocalConfig, moduleKind ModuleKind) string
- func BootstrapConfig(spec ConfigSpec) error
- func LoadConfig(spec ConfigSpec) (err error)
- func RegisterBootstrapConfigSpec(spec ConfigSpec)
- func RunCommonBootstrapDialog() error
- func RunModuleBootstrapDialog(sections ...*ModuleDialogSection) error
- func SetActiveModule(local *config.LocalConfig, moduleKind ModuleKind, moduleId string) (modified bool, err error)
- type ConfigContainer
- type ConfigSpec
- type Marshaller
- type Module
- type ModuleConfigSpec
- type ModuleDialogSection
- type ModuleKind
- type Unmarshaller
- type Validator
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 ¶
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.