Documentation ¶
Index ¶
- Constants
- Variables
- func CopyFile(srcPath, destPath string) error
- func CopyFileReplace(srcPath, destPath string, rStrings map[string]string) error
- func Debug(msg string)
- func Error(msg string)
- func HandleEdgeXConfig(service, envJSON string, extraConf map[string]string) error
- func Info(msg string)
- func Init(setDebug bool, snapName string) error
- func Warn(msg string)
- type CtlCli
- type SnapCtl
Constants ¶
const ( // AutostartConfig is a configuration key used indicate that a // service (application or device) should be autostarted on install AutostartConfig = "autostart" // EnvConfig is the prefix used for configure hook keys used for // EdgeX configuration overrides. EnvConfig = "env" // ProfileConfig is a configuration key that specifies a named // configuration profile ProfileConfig = "profile" // ServiceConsul is the service key for Consul. ServiceConsul = "consul" // ServiceRedis is the service key for Redis. ServiceRedis = "redis" // ServiceData is the service key for EdgeX Core Data. ServiceData = "core-data" // ServiceMetadata is the service key for EdgeX Core MetaData. ServiceMetadata = "core-metadata" // ServiceCommand is the service key for EdgeX Core Command. ServiceCommand = "core-command" // ServiceNotify is the service key for EdgeX Support Notifications. ServiceNotify = "support-notifications" // ServiceSched is the service key for EdgeX Support Scheduler. ServiceSched = "support-scheduler" // ServiceAppCfg is the service key for EdgeX App Service Configurable. ServiceAppCfg = "app-service-configurable" // ServiceDevVirt is the service key for EdgeX Device Virtual. ServiceDevVirt = "device-virtual" // ServiceSecStore is the service key for EdgeX Security Secret Store (aka Vault). ServiceSecStore = "security-secret-store" // ServiceProxy is the service key for EdgeX API Gateway (aka Kong). ServiceProxy = "security-proxy" // ServiceSysMgmt is the service key for EdgeX SMA (sys-mgmt-agent). ServiceSysMgmt = "sys-mgmt-agent" // ServiceKuiper is the service key for the Kuiper rules engine. ServiceKuiper = "kuiper" )
Variables ¶
var ( // Snap contains the value of the SNAP environment variable. Snap string // SnapConf contains the expanded path '$SNAP/config'. SnapConf string // SnapCommon contains the value of the SNAP_COMMON environment variable. SnapCommon string // SnapData contains the value of the SNAP_DATA environment variable. SnapData string // SnapDataConf contains the expanded path '$SNAP_DATA/config'. SnapDataConf string // SnapInst contains the value of the SNAP_INSTANCE_NAME environment variable. SnapInst string // SnapName contains the value of the SNAP_NAME environment variable. SnapName string // SnapRev contains the value of the SNAP_REVISION environment variable. SnapRev string )
var ConfToEnv = map[string]string{
"service.boot-timeout": "SERVICE_BOOTTIMEOUT",
"service.check-interval": "SERVICE_CHECKINTERVAL",
"service.host": "SERVICE_HOST",
"service.server-bind-addr": "SERVICE_SERVERBINDADDR",
"service.port": "SERVICE_PORT",
"service.protocol": "SERVICE_PROTOCOL",
"service.max-result-count": "SERVICE_MAXRESULTCOUNT",
"service.read-max-limit": "SERVICE_READMAXLIMIT",
"service.startup-msg": "SERVICE_STARTUPMSG",
"service.timeout": "SERVICE_TIMEOUT",
"clients.command.port": "CLIENTS_COMMAND_PORT",
"clients.coredata.port": "CLIENTS_COREDATA_PORT",
"clients.data.port": "CLIENTS_DATA_PORT",
"clients.metadata.port": "CLIENTS_METADATA_PORT",
"clients.notifications.port": "CLIENTS_NOTIFICATIONS_PORT",
"clients.scheduler.port": "CLIENTS_SCHEDULER_PORT",
"messagequeue.topic": "core-data/MESSAGEQUEUE_TOPIC",
"secretstore.additional-retry-attempts": "SECRETSTORE_ADDITIONALRETRYATTEMPTS",
"secretstore.retry-wait-period": "SECRETSTORE_RETRYWAITPERIOD",
"binding.type": "app/BINDING_TYPE",
"binding.subscribe-topic": "app/BINDING_SUBSCRIBE_TOPIC",
"binding.publish-topic": "app/BINDING_PUBLISH_TOPIC",
"message-bus.subscribe-host.port": "app/MESSAGEBUS_SUBSCRIBEHOST_PORT",
"message-bus.publish-host.port": "app/MESSAGEBUS_PUBLISHHOST_PORT",
"smtp.host": "support-notifications/SMTP_HOST",
"smtp.username": "support-notifications/SMTP_USERNAME",
"smtp.password": "support-notifications/SMTP_PASSWORD",
"smtp.port": "support-notifications/SMTP_PORT",
"smtp.sender": "support-notifications/SMTP_SENDER",
"smtp.enable-self-signed-cert": "support-notifications/SMTP_ENABLE_SELF_SIGNED_CERT",
"add-proxy-route": "security-proxy/ADD_PROXY_ROUTE",
"kongauth.name": "security-proxy/KONGAUTH_NAME",
"add-secretstore-tokens": "security-secret-store/ADD_SECRETSTORE_TOKENS",
}
ConfToEnv defines mappings from snap config keys to EdgeX environment variable names that are used to override individual service configuration values via a .env file read by the snap service wrapper.
The syntax to set a configuration key is:
env.<service name>.<section>.<keyname>
var Services = []string{ ServiceConsul, ServiceRedis, ServiceData, ServiceMetadata, ServiceCommand, ServiceNotify, ServiceSched, ServiceAppCfg, ServiceDevVirt, ServiceSecStore, ServiceProxy, ServiceSysMgmt, ServiceKuiper, }
Services is a string array of all of the edgexfoundry snap services.
Functions ¶
func CopyFileReplace ¶
CopyFileReplace copies a file within the snap and replaces strings using the string/replace values in the rStrings parameter.
func Debug ¶
func Debug(msg string)
Debug writes the given msg to sylog (sev=LOG_DEBUG) if the associated global snap 'debug' configuration flag is set to 'true'.
func HandleEdgeXConfig ¶
HandleEdgeXConfig processes snap configuration which can be used to override edgexfoundry configuration via environment variables sourced by the snap service wrapper script. The parameter service is used to create a new service specific file (named <service>.env) in the $SNAP_DATA/config/res directory of the service. The parameter envJSON is a JSON document holding the service's configuration as returned by snapd. The parameter extraConfig is a map of additional configuration keys supported by the snap. For example the following configuration option:
[Driver] MyDriverOption = "foo"
...would require an entry in extraConf like this:
extraConf["driver.mydriveroption"]"DRIVER_MYDRIVEROPTION"
.. and would be set like this for a device or application service:
``` $ sudo snap set mysnap env.driver.mydriveroption="foo" ```
Types ¶
type CtlCli ¶
type CtlCli struct{}
CtlCli is the test obj for overridding functions
func (*CtlCli) SetConfig ¶
SetConfig uses snapctl to set a config value from a key, or returns error.