configurator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package configurator provides read / write functionalities to manage application configuration.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigIsDir = errors.New("config file is a directory")

ErrConfigIsDir indicates that the config file is a directory.

Functions

This section is empty.

Types

type Configurator

type Configurator interface {
	Configure() error
	SafeRead() (service.Config, error)
	Read() (service.Config, error)
	Write(cfg service.Config) error
}

Configurator manages application configuration.

type Option

type Option func(c *PromptConfigurator)

Option configures Configurator.

func WithStdio

func WithStdio(stdio terminal.Stdio) Option

WithStdio configures stdio for prompt.

func WithStdioProvider

func WithStdioProvider(p cobra.StdioProvider) Option

WithStdioProvider configures stdio for prompt.

type PromptConfigurator

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

PromptConfigurator manages service.Config.

func New

func New(configFile string, options ...Option) *PromptConfigurator

New creates a new Configurator.

func (*PromptConfigurator) Clean

func (c *PromptConfigurator) Clean(oldCfg service.Config, newCfg service.Config) error

Clean cleans old obsolete from storage.

func (*PromptConfigurator) Configure

func (c *PromptConfigurator) Configure() (err error)

Configure runs the configuration prompt.

func (*PromptConfigurator) Read

func (c *PromptConfigurator) Read() (service.Config, error)

Read reads configuration from config file.

func (*PromptConfigurator) SafeRead

func (c *PromptConfigurator) SafeRead() (service.Config, error)

SafeRead is the same as Read but does not return error if the config file is missing.

func (*PromptConfigurator) Write

func (c *PromptConfigurator) Write(cfg service.Config) error

Write writes configuration to config file and external storage.

Jump to

Keyboard shortcuts

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