utils

package
v0.0.0-...-7b2af25 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HomePath = ""
)

Functions

func BindFlagsLoadViper

func BindFlagsLoadViper(cmd *cobra.Command, _ []string) error

BindFlagsLoadViper binds all flags and read the config into viper

func GetConfigFilePath

func GetConfigFilePath() string

GetConfigFilePath returns the path to the configuration file given the executable name

func RemoveDuplicates

func RemoveDuplicates(s []string) []string

RemoveDuplicates function removes duplicate values

func ToNullString

func ToNullString(value string) sql.NullString

ToNullString converts to empty string

func WatchMethod

func WatchMethod(method func() error)

WatchMethod allows to watch for a method that returns an error. It executes the given method in a goroutine, logging any error that might raise.

func Write

func Write(cfg Config, path string) error

Write allows to write the given configuration into the file present at the given path

Types

type CobraCmdFunc

type CobraCmdFunc func(cmd *cobra.Command, args []string) error

CobraCmdFunc represents a cobra command function

func ConcatCobraCmdFuncs

func ConcatCobraCmdFuncs(fs ...CobraCmdFunc) CobraCmdFunc

ConcatCobraCmdFuncs returns a single function that calls each argument function in sequence RunE, PreRunE, PersistentPreRunE, etc. all have this same signature

type Config

type Config struct {
	API      apiconfig.Config              `yaml:"api"`
	Database databaseconfig.DatabaseConfig `yaml:"database"`
	Parser   parserconfig.ParserConfig     `yaml:"parser"`
	// contains filtered or unexported fields
}

Config defines all necessary IBCJuno configuration parameters.

var (
	// Cfg represents the configuration used during the execution
	Cfg Config
)

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default Config instance

func DefaultConfigParser

func DefaultConfigParser(configData []byte) (Config, error)

DefaultConfigParser reads and parse IBCJuno config from the given string bytes. An error reading or parsing the config results in a panic.

func NewConfig

func NewConfig(
	api apiconfig.Config,
	dbConfig databaseconfig.DatabaseConfig,
	parserConfig parserconfig.ParserConfig,
) Config

NewConfig builds new Config instance

func Read

func Read(configPath string, parser ConfigParser) (Config, error)

Read takes the path to a configuration file and returns the properly parsed configuration

func (Config) GetBytes

func (c Config) GetBytes() []byte

GetBytes returns slice of byte

type ConfigParser

type ConfigParser = func(fileContents []byte) (Config, error)

ConfigParser represents a function that allows to parse config file contents as a Config object

Jump to

Keyboard shortcuts

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