Documentation ¶
Overview ¶
Package provision contains domain concept definitions needed to support Provision service feature, i.e. automate provision process.
Index ¶
Constants ¶
View Source
const (
Active = 1
)
Variables ¶
View Source
var ( ErrFailedToCreateToken = errors.New("failed to create access token") ErrEmptyThingsList = errors.New("things list in configuration empty") ErrThingUpdate = errors.New("failed to update thing") ErrEmptyChannelsList = errors.New("channels list in configuration is empty") ErrFailedChannelCreation = errors.New("failed to create channel") ErrFailedChannelRetrieval = errors.New("failed to retrieve channel") ErrFailedThingCreation = errors.New("failed to create thing") ErrFailedThingRetrieval = errors.New("failed to retrieve thing") ErrMissingCredentials = errors.New("missing credentials") ErrFailedBootstrapRetrieval = errors.New("failed to retrieve bootstrap") ErrFailedCertCreation = errors.New("failed to create certificates") ErrFailedBootstrap = errors.New("failed to create bootstrap config") ErrFailedBootstrapValidate = errors.New("failed to validate bootstrap config creation") ErrGatewayUpdate = errors.New("failed to updated gateway metadata") )
Functions ¶
Types ¶
type Bootstrap ¶
type Bootstrap struct { X509Provision bool `toml:"x509_provision" env:"MG_PROVISION_X509_PROVISIONING" envDefault:"false"` Provision bool `toml:"provision" env:"MG_PROVISION_BS_CONFIG_PROVISIONING" envDefault:"true"` AutoWhiteList bool `toml:"autowhite_list" env:"MG_PROVISION_BS_AUTO_WHITELIST" envDefault:"true"` Content map[string]interface{} `toml:"content"` }
Bootstrap represetns the Bootstrap config.
type Cert ¶
type Cert struct {
TTL string `json:"ttl" toml:"ttl" env:"MG_PROVISION_CERTS_HOURS_VALID" envDefault:"2400h"`
}
Cert represetns the certificate config.
type Config ¶
type Config struct { File string `toml:"file" env:"MG_PROVISION_CONFIG_FILE" envDefault:"config.toml"` Server ServiceConf `toml:"server" mapstructure:"server"` Bootstrap Bootstrap `toml:"bootstrap" mapstructure:"bootstrap"` Things []mgclients.Client `toml:"things" mapstructure:"things"` Channels []groups.Group `toml:"channels" mapstructure:"channels"` Cert Cert `toml:"cert" mapstructure:"cert"` BSContent string `env:"MG_PROVISION_BS_CONTENT" envDefault:""` SendTelemetry bool `env:"MG_SEND_TELEMETRY" envDefault:"true"` InstanceID string `env:"MG_MQTT_ADAPTER_INSTANCE_ID" envDefault:""` }
Config struct of Provision.
type Gateway ¶
type Gateway struct { Type string `toml:"type" json:"type"` ExternalID string `toml:"external_id" json:"external_id"` ExternalKey string `toml:"external_key" json:"external_key"` CtrlChannelID string `toml:"ctrl_channel_id" json:"ctrl_channel_id"` DataChannelID string `toml:"data_channel_id" json:"data_channel_id"` ExportChannelID string `toml:"export_channel_id" json:"export_channel_id"` CfgID string `toml:"cfg_id" json:"cfg_id"` }
Gateway represetns the Gateway config.
type Result ¶
type Result struct { Things []sdk.Thing `json:"things,omitempty"` Channels []sdk.Channel `json:"channels,omitempty"` ClientCert map[string]string `json:"client_cert,omitempty"` ClientKey map[string]string `json:"client_key,omitempty"` CACert string `json:"ca_cert,omitempty"` Whitelisted map[string]bool `json:"whitelisted,omitempty"` Error string `json:"error,omitempty"` }
Result represent what is created with additional info.
type Service ¶
type Service interface { // Provision is the only method this API specifies. Depending on the configuration, // the following actions will can be executed: // - create a Thing based on external_id (eg. MAC address) // - create multiple Channels // - create Bootstrap configuration // - whitelist Thing in Bootstrap configuration == connect Thing to Channels Provision(token, name, externalID, externalKey string) (Result, error) // Mapping returns current configuration used for provision // useful for using in ui to create configuration that matches // one created with Provision method. Mapping(token string) (map[string]interface{}, error) // Certs creates certificate for things that communicate over mTLS // A duration string is a possibly signed sequence of decimal numbers, // each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". Cert(token, thingID, duration string) (string, string, error) }
Service specifies Provision service API.
type ServiceConf ¶
type ServiceConf struct { Port string `toml:"port" env:"MG_PROVISION_HTTP_PORT" envDefault:"9016"` LogLevel string `toml:"log_level" env:"MG_PROVISION_LOG_LEVEL" envDefault:"info"` TLS bool `toml:"tls" env:"MG_PROVISION_ENV_CLIENTS_TLS" envDefault:"false"` ServerCert string `toml:"server_cert" env:"MG_PROVISION_SERVER_CERT" envDefault:""` ServerKey string `toml:"server_key" env:"MG_PROVISION_SERVER_KEY" envDefault:""` ThingsURL string `toml:"things_url" env:"MG_PROVISION_THINGS_LOCATION" envDefault:"http://localhost"` UsersURL string `toml:"users_url" env:"MG_PROVISION_USERS_LOCATION" envDefault:"http://localhost"` HTTPPort string `toml:"http_port" env:"MG_PROVISION_HTTP_PORT" envDefault:"9016"` MgUser string `toml:"mg_user" env:"MG_PROVISION_USER" envDefault:"test@example.com"` MgPass string `toml:"mg_pass" env:"MG_PROVISION_PASS" envDefault:"test"` MgDomainID string `toml:"mg_domain_id" env:"MG_PROVISION_DOMAIN_ID" envDefault:""` MgAPIKey string `toml:"mg_api_key" env:"MG_PROVISION_API_KEY" envDefault:""` MgBSURL string `toml:"mg_bs_url" env:"MG_PROVISION_BS_SVC_URL" envDefault:"http://localhost:9000"` MgCertsURL string `toml:"mg_certs_url" env:"MG_PROVISION_CERTS_SVC_URL" envDefault:"http://localhost:9019"` }
ServiceConf represents service config.
Click to show internal directories.
Click to hide internal directories.