cliconfig

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CONFIG_FILE_NAME = "hzn.json"
View Source
const DEFAULT_CONFIG_FILE = "hzn.json"
View Source
const DEV_DEFAULT_DEPENDENCY_DIR = "dependencies"
View Source
const DEV_DEFAULT_WORKING_DIR = "horizon"
View Source
const DEV_SERVICE_DEFINITION_FILE = "service.definition.json"

Variables

View Source
var PACKAGE_CONFIG_FILE string
View Source
var PROJECT_CONFIG_FILE string
View Source
var USER_CONFIG_FILE string

Functions

func FileExists

func FileExists(directory string, fileName string) bool

Check for file existence and return any errors. Treat error as file does not exists because os.Stat() only returns PathError.

func GetConfigFromNonJsonFile

func GetConfigFromNonJsonFile(configFile string) (map[string]string, error)

func GetEnvVars

func GetEnvVars() map[string]string

get all the env vars and convert them to a map for easy referencing later.

func GetProjectConfigFile

func GetProjectConfigFile(dir string) (string, error)

check the project's configuration file, it could be under current directory or the ./horizon directory or ../ directory if current directory is dependecies. it is usually setup by 'hzn dev service create' command

func GetVarsFromConfig

func GetVarsFromConfig(config *HorizonCliConfig) (map[string]string, map[string]string)

returns the hzn level env vars and metadata vars from the config in the map format

func GetVarsFromFile

func GetVarsFromFile(configFile string) (map[string]string, map[string]string, error)

returns the hzn level env vars and metadata vars from the config file

func ReadJsonFileWithLocalConfig

func ReadJsonFileWithLocalConfig(filePath string) []byte

ReadJsonFile reads json from a file or stdin, eliminates comments, setup env vars from local hzn.json configuration file if any, substitutes env vars, and returns it.

func RestoreEnvVars

func RestoreEnvVars(orig_env_vars, hzn_vars, metadata_vars map[string]string) error

restore the env vars to its original state after setting up hzn_vars and metadata_vars

func SetEnvVars

func SetEnvVars(new_env_vars, orig_env_vars map[string]string, override bool) error

func SetEnvVarsFromConfigFile

func SetEnvVarsFromConfigFile(configFile string, orig_env_vars map[string]string, override_env bool) (map[string]string, map[string]string, error)

set up the environment variables from the given config file. skip the ones that's alrady there originally if override_env is false it returns the hzn env vars and metadata env vars from the given file

func SetEnvVarsFromConfigFiles

func SetEnvVarsFromConfigFiles(project_dir string) error

set up the environment variables from the config files. the precedence order is: environmental variables, user config file, package config file

func SetEnvVarsFromNonJsonFile

func SetEnvVarsFromNonJsonFile(configFile string, orig_env_vars map[string]string, override_env bool) (map[string]string, error)

set up the environment variables from the given non-jsonfile. skip the ones that's alrady there originally if override_env is false it returns the hzn env vars from the given file

func SetEnvVarsFromProjectConfigFile

func SetEnvVarsFromProjectConfigFile(project_dir string) error

set up the environment variables from the project config files. the precedence order is: environmental variables, project config file

Types

type HorizonCliConfig

type HorizonCliConfig struct {

	// user usually needs to setup these, or input them with the flags for a hzn command
	HZN_EXCHANGE_USER_AUTH string `json:"HZN_EXCHANGE_USER_AUTH,omitempty"`
	HZN_EXCHANGE_NODE_AUTH string `json:"HZN_EXCHANGE_NODE_AUTH,omitempty"`
	HZN_ORG_ID             string `json:"HZN_ORG_ID,omitempty"`

	// the locale that the hzn cli will run under, for example pt-BR, es, fr, de, it, ja, ko, zh-CN, zh-TW.
	HZN_LANG string `json:"HZN_LANG,omitempty"`

	// the url to the horizon agent, the default is "http://localhost" for linux and "http://localhost:8081" for mac
	HORIZON_URL string `json:"HORIZON_URL,omitempty"`

	// exchange url, the default is shipped with the horizon-cli package
	HZN_EXCHANGE_URL string `json:"HZN_EXCHANGE_URL,omitempty"`

	// the CSS url, the default is shipped with the horizon-cli package
	HZN_FSS_CSSURL string `json:"HZN_FSS_CSSURL,omitempty"`

	// keys to sign the service or pattern, the default is ~/.hzn/keys/service.private.key and ~/.hzn/keys/service.public.pem
	HZN_PRIVATE_KEY_FILE string `json:"HZN_PRIVATE_KEY_FILE,omitempty"`
	HZN_PUBLIC_KEY_FILE  string `json:"HZN_PUBLIC_KEY_FILE,omitempty"`

	// the following are only used by 'hzn dev' commands
	HZN_DEVICE_ID           string `json:"HZN_DEVICE_ID,omitempty"`
	HZN_PATTERN             string `json:"HZN_PATTERN,omitempty"`
	HZN_DEV_FSS_IMAGE_TAG   string `json:"HZN_DEV_FSS_IMAGE_TAG,omitempty"`
	HZN_DEV_FSS_CSS_PORT    string `json:"HZN_DEV_FSS_CSS_PORT,omitempty"`
	HZN_DEV_FSS_MONGO_IMAGE string `json:"HZN_DEV_FSS_MONGO_IMAGE,omitempty"`
	HZN_DEV_FSS_WORKING_DIR string `json:"HZN_DEV_FSS_WORKING_DIR,omitempty"`

	// used to substitute the env variables in a file
	MetadataVars map[string]string `json:"MetadataVars,omitempty"`
}

configuration for hzn command

func GetConfig

func GetConfig(configFile string) (*HorizonCliConfig, error)

get the config from the given file. Assume file exists.

Jump to

Keyboard shortcuts

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