config

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyTypeHex                        KeyType = "hex"        // Hex private key with in memory signer
	KeyTypeGoogleKMS                  KeyType = "google-kms" // Google KMS signer
	KeyTypeShell                      KeyType = "shell"      // Exec out to a shell script
	DefaultEmulatorConfigName                 = "default"
	PrivateKeyField                           = "privateKey"
	KMSContextField                           = "resourceName"
	DefaultEmulatorServiceAccountName         = "emulator-account"
)
View Source
const DefaultPath = "flow.json"

Variables

View Source
var ErrDoesNotExist = errors.New("missing configuration, initialize it: flow init")

ErrDoesNotExist is error to be returned when config file does not exists

View Source
var ErrOutdatedFormat = errors.New("you are using old configuration format")

Functions

func DefaultPaths added in v0.19.0

func DefaultPaths() []string

DefaultPaths determines default paths for configuration

func Exists

func Exists(path string) bool

Exists checks if file exists on the specified path

func GlobalPath added in v0.19.0

func GlobalPath() string

GlobalPath gets global path based on home dir

func ProcessorRun

func ProcessorRun(raw []byte) ([]byte, map[string]string)

ProcessorRun all pre-processors

func StringToAddress added in v0.19.0

func StringToAddress(value string) (*flow.Address, error)

func StringToHexKey added in v0.19.0

func StringToHexKey(key string, sigAlgo string) (crypto.PrivateKey, error)

func StringToKeyIndex added in v0.19.0

func StringToKeyIndex(value string) (int, error)

Types

type Account

type Account struct {
	Name    string
	Address flow.Address
	Keys    []AccountKey
}

Account defines the configuration for a Flow account.

func StringToAccount added in v0.19.0

func StringToAccount(
	name string,
	address string,
	index string,
	sigAlgo string,
	hashAlgo string,
	key string,
) (*Account, error)

StringToAccount converts string values to account

type AccountKey

type AccountKey struct {
	Type     KeyType
	Index    int
	SigAlgo  crypto.SignatureAlgorithm
	HashAlgo crypto.HashAlgorithm
	Context  map[string]string
}

AccountKey defines the configuration for a Flow account key.

type Accounts

type Accounts []Account

func (*Accounts) AddOrUpdate

func (a *Accounts) AddOrUpdate(name string, account Account)

AddOrUpdate add new or update if already present

func (*Accounts) GetByName

func (a *Accounts) GetByName(name string) *Account

AccountByName get account by name

func (*Accounts) Remove added in v0.19.0

func (a *Accounts) Remove(name string) error

Remove remove account by name

type Config

type Config struct {
	Emulators   Emulators
	Contracts   Contracts
	Networks    Networks
	Accounts    Accounts
	Deployments Deployments
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig gets default configuration

type ConfigParsers

type ConfigParsers []Parser

ConfigParsers is a list of all configuration parsers.

func (*ConfigParsers) FindForFormat

func (c *ConfigParsers) FindForFormat(extension string) Parser

FindForFormat finds a parser that can parse a specific format based on extension

type Contract

type Contract struct {
	Name    string
	Source  string
	Network string
	Alias   string
}

Contract defines the configuration for a Cadence contract.

func StringToContracts added in v0.19.0

func StringToContracts(
	name string,
	source string,
	emulatorAlias string,
	testnetAlias string,
) []Contract

func (*Contract) IsAlias

func (c *Contract) IsAlias() bool

IsAlias checks if contract has an alias

type ContractDeployment added in v0.19.0

type ContractDeployment struct {
	Name string
	Args []cadence.Value
}

ContractDeployment defines the deployment of the contract with possible args

type Contracts

type Contracts []Contract

func (*Contracts) AddOrUpdate

func (c *Contracts) AddOrUpdate(name string, contract Contract)

AddOrUpdate add new or update if already present

func (*Contracts) GetByName

func (c *Contracts) GetByName(name string) *Contract

GetByName get contract by name

func (*Contracts) GetByNameAndNetwork

func (c *Contracts) GetByNameAndNetwork(name string, network string) *Contract

GetByNameAndNetwork get contract array for account and network

func (*Contracts) GetByNetwork

func (c *Contracts) GetByNetwork(network string) Contracts

GetByNetwork returns all contracts for specific network

func (*Contracts) Remove added in v0.19.0

func (c *Contracts) Remove(name string) error

type Deploy

type Deploy struct {
	Network   string               // network name to deploy to
	Account   string               // account name to which to deploy to
	Contracts []ContractDeployment // contracts to deploy
}

Deploy defines the configuration for a contract deployment.

func StringToDeployment added in v0.19.0

func StringToDeployment(network string, account string, contracts []string) Deploy

type Deployments

type Deployments []Deploy

func (*Deployments) AddOrUpdate

func (d *Deployments) AddOrUpdate(deployment Deploy)

AddOrUpdate add new or update if already present

func (*Deployments) GetByAccountAndNetwork

func (d *Deployments) GetByAccountAndNetwork(account string, network string) Deployments

GetByAccountAndNetwork get deploy by account and network

func (*Deployments) GetByNetwork

func (d *Deployments) GetByNetwork(network string) Deployments

GetByNetwork get all deployments by network

func (*Deployments) Remove added in v0.19.0

func (d *Deployments) Remove(account string, network string) error

Remove removes deployment by account and network

type Emulator

type Emulator struct {
	Name           string
	Port           int
	ServiceAccount string
}

Emulator defines the configuration for a Flow Emulator instance.

func DefaultEmulator

func DefaultEmulator() Emulator

DefaultEmulator gets default emulator

type Emulators

type Emulators []Emulator

func DefaultEmulators

func DefaultEmulators() Emulators

DefaultEmulators gets all default emulators

func (*Emulators) AddOrUpdate

func (e *Emulators) AddOrUpdate(name string, emulator Emulator)

AddOrUpdate add new or update if already present

func (*Emulators) Default

func (e *Emulators) Default() *Emulator

Default gets default emulator

type KeyType

type KeyType string

type Loader

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

Loader contains actions for composing and modifying configuration.

func NewLoader

func NewLoader(filesystem afero.Fs) *Loader

NewLoader returns a new loader.

func (*Loader) AddConfigParser

func (l *Loader) AddConfigParser(format Parser)

AddConfigParser adds a new configuration parser.

func (*Loader) Load

func (l *Loader) Load(paths []string) (*Config, error)

Load loads configuration from one or more file paths.

If more than one path is specified, their contents are merged together into on configuration object.

func (*Loader) Save

func (l *Loader) Save(conf *Config, path string) error

Save saves a configuration to a path with correct serializer

type Network

type Network struct {
	Name string
	Host string
}

Network defines the configuration for a Flow network.

func DefaultEmulatorNetwork

func DefaultEmulatorNetwork() Network

DefaultEmulatorNetwork get default emulator network

func DefaultMainnetNetwork

func DefaultMainnetNetwork() Network

DefaultMainnetNetwork get default mainnet network

func DefaultTestnetNetwork

func DefaultTestnetNetwork() Network

DefaultTestnetNetwork get default testnet network

func StringToNetwork added in v0.19.0

func StringToNetwork(name string, host string) Network

type Networks

type Networks []Network

func DefaultNetworks

func DefaultNetworks() Networks

DefaultNetworks gets all default networks

func (*Networks) AddOrUpdate

func (n *Networks) AddOrUpdate(name string, network Network)

AddOrUpdate add new network or update if already present

func (*Networks) GetByName

func (n *Networks) GetByName(name string) *Network

GetByName get network by name

func (*Networks) Remove added in v0.19.0

func (n *Networks) Remove(name string) error

type Parser

type Parser interface {
	Serialize(*Config) ([]byte, error)
	Deserialize([]byte) (*Config, error)
	SupportsFormat(string) bool
}

Parser is interface for any configuration format parser to implement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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