Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigObjToYaml(cfg *AnchorConfig) (string, error)
- func NewManager() *configManagerImpl
- func SetInContext(ctx common.Context, config *AnchorConfig)
- type AnchorConfig
- type Config
- type ConfigManager
- type ConfigViperAdapter
- type Context
- type ContextItem
- type Local
- type Remote
- type Repository
- type TemplateItems
Constants ¶
View Source
const ( DefaultAuthor = "Zachi Nachshon <[email protected]>" DefaultLicense = "Apache" DefaultRemoteBranch = "master" )
View Source
const (
Identifier string = "config-manager"
)
Variables ¶
View Source
var CreateFakeConfigManager = func() *fakeConfigManager {
return &fakeConfigManager{}
}
View Source
var CreateFakeViperConfigAdapter = func() *fakeViperConfigAdapter {
return &fakeViperConfigAdapter{}
}
View Source
var GetCustomTestConfigText = func(items TemplateItems) string { var yamlConfig, err = templates.TemplateToText(configYamlTemplate, &items) if err != nil { logger.Fatalf("Failed to generate config template with substitutions. error: %s", err) } return yamlConfig }
View Source
var GetDefaultTestConfigText = func() string { var yamlConfig, err = templates.TemplateToText(configYamlTemplate, nil) if err != nil { logger.Fatalf("Failed to generate config template. error: %s", err) } return yamlConfig }
Functions ¶
func ConfigObjToYaml ¶
func ConfigObjToYaml(cfg *AnchorConfig) (string, error)
func NewManager ¶
func NewManager() *configManagerImpl
func SetInContext ¶
func SetInContext(ctx common.Context, config *AnchorConfig)
Types ¶
type AnchorConfig ¶
type AnchorConfig struct { Config *Config `yaml:"config"` Author string `yaml:"author"` License string `yaml:"license"` }
func FromContext ¶
func FromContext(ctx common.Context) *AnchorConfig
func YamlToConfigObj ¶
func YamlToConfigObj(yamlText string) (*AnchorConfig, error)
type ConfigManager ¶
type ConfigManager interface { SetupConfigFileLoader() error SetupConfigInMemoryLoader(yaml string) error ListenOnConfigFileChanges(ctx common.Context) OverrideConfig(cfgToUpdate *AnchorConfig) error OverrideConfigEntry(entryName string, value interface{}) error ReadConfig(key string) string SwitchActiveConfigContextByName(cfg *AnchorConfig, cfgCtxName string) error CreateConfigObject(shouldValidateCfgSchema bool) (*AnchorConfig, error) GetConfigFilePath() (string, error) SetDefaultsPostCreation(anchorConfig *AnchorConfig) error }
type ConfigViperAdapter ¶
type ConfigViperAdapter interface { SetConfigPath(dirPath string) error LoadConfigFromFile() error LoadConfigFromText(yaml string) error RegisterConfigChangesListener(callback func(e fsnotify.Event)) UpdateAll(cfgToUpdate *AnchorConfig) error UpdateEntry(entryName string, value interface{}) error GetConfigByKey(key string) string SetDefaults() error SetEnvVars() error AppendConfig(anchorConfig interface{}) error // contains filtered or unexported methods }
func NewAdapter ¶
func NewAdapter() ConfigViperAdapter
type Context ¶
type Context struct { Name string `yaml:"name"` Context *ContextItem `yaml:"context"` }
func AppendEmptyConfigContext ¶ added in v0.2.0
func AppendEmptyConfigContext(cfg *AnchorConfig, name string) *Context
func TryGetConfigContext ¶
type ContextItem ¶
type ContextItem struct {
Repository *Repository `yaml:"repository"`
}
type Repository ¶
type TemplateItems ¶
type TemplateItems struct { Author string License string CurrentContext string FirstContextName string FirstContextClonePath string FirstContextRemoteRepoUrl string FirstContextRemoteRepoRevision string FirstContextRemoteRepoBranch string FirstContextLocalRepoPath string SecondContextName string SecondContextClonePath string SecondContextRemoteRepoUrl string SecondContextRemoteRepoRevision string SecondContextRemoteRepoBranch string SecondContextLocalRepoPath string }
Click to show internal directories.
Click to hide internal directories.