config

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 6 Imported by: 39

Documentation

Index

Constants

View Source
const (
	DBKindSqlite   = "sqlite"
	DBKindPostgres = "postgres"
	DBKindMysql    = "mysql"
)

Supported database kinds

Variables

View Source
var (
	ErrUnsupportedDB = errors.New("Unsupported database")
	ErrMissingField  = errors.New("Missing field")
)

Functions

func Parse

func Parse(filename string, output Configurable) error

Parse -

Types

type Config

type Config struct {
	Version     string                `yaml:"version"`
	Database    Database              `yaml:"database"`
	DataSources map[string]DataSource `yaml:"datasources"`
	Contracts   map[string]Contract   `yaml:"contracts"`
	Hasura      Hasura                `yaml:"hasura"`
}

Config

func Load

func Load(filename string) (*Config, error)

Load - load default config from `filename`

func LoadAndValidate

func LoadAndValidate(filename string) (*Config, error)

LoadAndValidate - load config from `filename` and validate it

func (*Config) Substitute

func (c *Config) Substitute() error

Substitute -

func (*Config) Validate

func (c *Config) Validate() error

Validate -

type Configurable

type Configurable interface {
	Validate() error
	Substitute() error
}

Configurable -

type Contract

type Contract struct {
	Address  string `yaml:"address"`
	TypeName string `yaml:"typename"`
}

Contracts -

type DataSource

type DataSource struct {
	Kind string `yaml:"kind"`
	URL  string `yaml:"url"`
}

DataSource -

type Database

type Database struct {
	Path       string `yaml:"path"`
	Kind       string `yaml:"kind"`
	Host       string `yaml:"host"`
	Port       int    `yaml:"port"`
	User       string `yaml:"user"`
	Password   string `yaml:"password"`
	Database   string `yaml:"database"`
	SchemaName string `yaml:"schema_name"`
}

Database

func (*Database) Validate

func (db *Database) Validate() error

Validate -

type Hasura

type Hasura struct {
	URL                string `yaml:"url"`
	Secret             string `yaml:"admin_secret"`
	RowsLimit          uint64 `yaml:"select_limit"`
	EnableAggregations bool   `yaml:"allow_aggregation"`
	Rest               *bool  `yaml:"rest"`
}

Hasura -

Jump to

Keyboard shortcuts

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