config

package
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: MIT Imports: 17 Imported by: 8

Documentation

Index

Constants

View Source
const (
	BlockChainNetworkFileName  = "resources/blockchain_network_config.json"
	EthereumJsonRpcEndpointKey = "ethereum_json_rpc_endpoint"
	NetworkId                  = "network_id"
	RegistryAddressKey         = "registry_address_key"
)
View Source
const (
	AllowedUserFlag                = "allowed_user_flag"
	AllowedUserAddresses           = "allowed_user_addresses"
	AuthenticationAddresses        = "authentication_addresses"
	AutoSSLDomainKey               = "auto_ssl_domain"
	AutoSSLCacheDirKey             = "auto_ssl_cache_dir"
	BlockchainEnabledKey           = "blockchain_enabled"
	BlockChainNetworkSelected      = "blockchain_network_selected"
	BurstSize                      = "burst_size"
	ConfigPathKey                  = "config_path"
	DaemonGroupName                = "daemon_group_name"
	DaemonTypeKey                  = "daemon_type"
	DaemonEndPoint                 = "daemon_end_point"
	ExecutablePathKey              = "executable_path"
	IpfsEndPoint                   = "ipfs_end_point"
	IpfsTimeout                    = "ipfs_timeout"
	LogKey                         = "log"
	MaxMessageSizeInMB             = "max_message_size_in_mb"
	MeteringEnabled                = "metering_enabled"
	OrganizationId                 = "organization_id"
	ServiceId                      = "service_id"
	PassthroughEnabledKey          = "passthrough_enabled"
	PassthroughEndpointKey         = "passthrough_endpoint"
	RateLimitPerMinute             = "rate_limit_per_minute"
	SSLCertPathKey                 = "ssl_cert"
	SSLKeyPathKey                  = "ssl_key"
	PaymentChannelCertPath         = "payment_channel_cert_path"
	PaymentChannelCaPath           = "payment_channel_ca_path"
	PaymentChannelKeyPath          = "payment_channel_key_path"
	PaymentChannelStorageTypeKey   = "payment_channel_storage_type"
	PaymentChannelStorageClientKey = "payment_channel_storage_client"
	PaymentChannelStorageServerKey = "payment_channel_storage_server"
	//configs for Daemon Monitoring and Notification
	AlertsEMail                 = "alerts_email"
	HeartbeatServiceEndpoint    = "heartbeat_svc_end_point"
	MeteringEndPoint            = "metering_end_point"
	PvtKeyForMetering           = "pvt_key_for_metering"
	NotificationServiceEndpoint = "notification_svc_end_point"
	ServiceHeartbeatType        = "service_heartbeat_type"
	TokenExpiryInMinutes        = "token_expiry_in_minutes"
	TokenSecretKey              = "token_secret_key"
)
View Source
const DefaultDaemonConfigurationSchema = `` /* 1646-byte string literal not displayed */

Variables

View Source
var DisplayKeys = map[string]bool{
	strings.ToUpper(AllowedUserFlag):                true,
	strings.ToUpper(AllowedUserAddresses):           true,
	strings.ToUpper(AuthenticationAddresses):        true,
	strings.ToUpper(AutoSSLDomainKey):               true,
	strings.ToUpper(AutoSSLCacheDirKey):             true,
	strings.ToUpper(BlockchainEnabledKey):           true,
	strings.ToUpper(BlockChainNetworkSelected):      true,
	strings.ToUpper(BurstSize):                      true,
	strings.ToUpper(ConfigPathKey):                  true,
	strings.ToUpper(DaemonGroupName):                true,
	strings.ToUpper(DaemonTypeKey):                  true,
	strings.ToUpper(DaemonEndPoint):                 true,
	strings.ToUpper(ExecutablePathKey):              true,
	strings.ToUpper(IpfsEndPoint):                   true,
	strings.ToUpper(IpfsTimeout):                    true,
	strings.ToUpper(LogKey):                         true,
	strings.ToUpper(MaxMessageSizeInMB):             true,
	strings.ToUpper(MeteringEnabled):                true,
	strings.ToUpper(OrganizationId):                 true,
	strings.ToUpper(ServiceId):                      true,
	strings.ToUpper(PassthroughEnabledKey):          true,
	strings.ToUpper(PassthroughEndpointKey):         true,
	strings.ToUpper(RateLimitPerMinute):             true,
	strings.ToUpper(SSLCertPathKey):                 true,
	strings.ToUpper(SSLKeyPathKey):                  true,
	strings.ToUpper(PaymentChannelCertPath):         true,
	strings.ToUpper(PaymentChannelCaPath):           true,
	strings.ToUpper(PaymentChannelKeyPath):          true,
	strings.ToUpper(PaymentChannelStorageTypeKey):   true,
	strings.ToUpper(PaymentChannelStorageClientKey): true,
	strings.ToUpper(PaymentChannelStorageServerKey): true,
	strings.ToUpper(AlertsEMail):                    true,
	strings.ToUpper(HeartbeatServiceEndpoint):       true,
	strings.ToUpper(MeteringEndPoint):               true,
	strings.ToUpper(NotificationServiceEndpoint):    true,
	strings.ToUpper(ServiceHeartbeatType):           true,
}

Functions

func CheckVersionOfDaemon added in v1.0.0

func CheckVersionOfDaemon() (message string, err error)

This function is called to see if the current daemon is on the latest version , if it is not, indicate this to the user when the daemon starts.

func ConvertStructToJSON added in v1.1.0

func ConvertStructToJSON(payLoad interface{}) ([]byte, error)

ConvertStructToJSON converts the passed datastructure to a JSON

func GetBigInt added in v0.1.2

func GetBigInt(key string) *big.Int

func GetBigIntFromViper added in v0.1.2

func GetBigIntFromViper(config *viper.Viper, key string) (value *big.Int, err error)

func GetBlockChainEndPoint added in v1.0.0

func GetBlockChainEndPoint() string

Get the block chain end point associated with the Network selected

func GetBool

func GetBool(key string) bool

func GetBuildTime added in v0.1.9

func GetBuildTime() string

func GetDuration

func GetDuration(key string) time.Duration

func GetInt

func GetInt(key string) int

func GetLatestDaemonVersion added in v1.0.0

func GetLatestDaemonVersion() (version string, err error)

func GetNetworkId added in v1.0.0

func GetNetworkId() string

Get the Network ID associated with the network selected

func GetRegistryAddress added in v1.0.0

func GetRegistryAddress() string

Get the Registry address of the contract

func GetSha1Revision added in v0.1.9

func GetSha1Revision() string

func GetString

func GetString(key string) string

func GetVersionTag added in v0.1.9

func GetVersionTag() string

func IsAllowedUser

func IsAllowedUser(address *common.Address) bool

func IsValidUrl added in v0.1.5

func IsValidUrl(urlToTest string) bool

isValidUrl tests a string to determine if it is a url or not.

func LoadConfig added in v0.1.2

func LoadConfig(configFile string) error

func LogConfig added in v0.1.2

func LogConfig()

func ReadConfigFromJsonString added in v0.1.2

func ReadConfigFromJsonString(config *viper.Viper, json string) error

ReadConfigFromJsonString function reads settigs from json string to the config instance. String should contain valid JSON config.

func ReadFromFile added in v1.0.0

func ReadFromFile(filename string) ([]byte, error)

Read the file given file, if the file is not found ,then return back an error

func SetAllowedUsers

func SetAllowedUsers() (err error)

Set the list of allowed users

func SetDefaultFromConfig added in v0.1.2

func SetDefaultFromConfig(config *viper.Viper, defaults *viper.Viper)

SetDefaultFromConfig sets all settings from defaults as default values to the config.

func SubWithDefault added in v0.1.2

func SubWithDefault(config *viper.Viper, key string) *viper.Viper

SubWithDefault returns sub-config by keys including configuration defaults values. It returns nil if no such key. It is analog of the viper.Sub() function. This is workaround for the issue https://github.com/spf13/viper/issues/559

func Validate

func Validate() error

func ValidateEmail added in v0.1.5

func ValidateEmail(email string) bool

validates in input URL

func ValidateEndpoints added in v0.1.10

func ValidateEndpoints(daemonEndpoint string, passthroughEndpoint string) error

func Vip

func Vip() *viper.Viper

func WriteConfig added in v0.1.2

func WriteConfig(configFile string) error

Types

type ConfigurationDetails added in v1.1.0

type ConfigurationDetails struct {
	Name          string //the key of the attribute becomes the Value of the Name
	Mandatory     bool   `json:"mandatory"`
	DefaultValue  string `json:"value"`
	Description   string `json:"description"`
	Type          string `json:"type"`
	Editable      bool   `json:"editable"`
	RestartDaemon bool   `json:"restart_daemon"`
	Section       string `json:"section"`
}

Used to map the attribute values to a struct

func GetConfigurationSchema added in v1.1.0

func GetConfigurationSchema() ([]ConfigurationDetails, error)

type GitTags added in v1.0.0

type GitTags struct {
	Tag_name string `json:"tag_name"`
}

type NetworkSelected added in v1.0.0

type NetworkSelected struct {
	NetworkName             string
	EthereumJSONRPCEndpoint string
	NetworkId               string
	RegistryAddressKey      string
}

Jump to

Keyboard shortcuts

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