Documentation
¶
Index ¶
- Constants
- Variables
- func ChangeServiceConfigState(service_cs *exchange.ServiceConfigState, errorhandler ErrorHandler, ...) (bool, []events.ServiceConfigState)
- func CreateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, ...) (bool, *HorizonDevice, *HorizonDevice)
- func DeleteAgreement(errorhandler ErrorHandler, agreementId string, db *bolt.DB) (bool, *events.ApiAgreementCancelationMessage)
- func DeleteHorizonDevice(removeNode string, deepClean string, block string, ...) bool
- func DeleteNodePolicy(errorhandler DeviceErrorHandler, db *bolt.DB, ...) (bool, []*events.NodePolicyMessage)
- func DeleteNodeUserInput(errorhandler DeviceErrorHandler, db *bolt.DB, getDevice exchange.DeviceHandler, ...) (bool, []*events.NodeUserInputMessage)
- func DeletePublicKey(fileName string, config *config.HorizonConfig, errorhandler ErrorHandler) bool
- func FinalizeAttributesSpecifiedInService(sp *persistence.ServiceSpec, attributes []persistence.Attribute) []persistence.Attribute
- func FindAgreementsForOutput(db *bolt.DB) (map[string]map[string][]persistence.EstablishedAgreement, error)
- func FindAndWrapAttributesForOutput(db *bolt.DB, id string) (map[string][]Attribute, error)
- func FindEventLogsForOutput(db *bolt.DB, all_logs bool, selections map[string][]string, ...) ([]persistence.EventLog, error)
- func FindNodePolicyForOutput(db *bolt.DB) (*externalpolicy.ExternalPolicy, error)
- func FindNodeUserInputForOutput(db *bolt.DB) ([]policy.UserInput, error)
- func FindPublicKeyForOutput(fileName string, config *config.HorizonConfig) (string, error)
- func FindPublicKeysForOutput(config *config.HorizonConfig, verbose bool) (map[string][]interface{}, error)
- func FindServiceConfigForOutput(pm *policy.PolicyManager, db *bolt.DB) (map[string][]MicroserviceConfig, error)
- func FindServiceConfigStateForOutput(errorhandler ErrorHandler, ...) (bool, map[string][]exchange.ServiceConfigState)
- func FindSurfaceLogsForOutput(db *bolt.DB, msgPrinter *message.Printer) ([]persistence.SurfaceError, error)
- func GetMicroserviceContainer(dockerEndpoint string, mURL string, mOrg string, mVersion string, ...) ([]dockerclient.APIContainers, error)
- func GetWorkloadContainers(dockerEndpoint string, agreementId string) ([]dockerclient.APIContainers, error)
- func InputIsIllegal(str string) (string, error)
- func LogDeviceEvent(db *bolt.DB, severity string, message *persistence.MessageMeta, ...)
- func LogServiceEvent(db *bolt.DB, severity string, message *persistence.MessageMeta, ...)
- func MapInputIsIllegal(m map[string]interface{}) (string, string, error)
- func MarkI18nMessages()
- func NoOpStateChange(from string, to string) bool
- func PatchNodePolicy(patchObject interface{}, errorhandler DeviceErrorHandler, ...) (bool, *externalpolicy.ExternalPolicy, []*events.NodePolicyMessage)
- func PatchNodeUserInput(patchObject []policy.UserInput, errorhandler DeviceErrorHandler, ...) (bool, []policy.UserInput, []*events.NodeUserInputMessage)
- func UpdateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, ...) (bool, *HorizonDevice, *HorizonDevice)
- func UpdateNodePolicy(nodePolicy *externalpolicy.ExternalPolicy, errorhandler DeviceErrorHandler, ...) (bool, *externalpolicy.ExternalPolicy, []*events.NodePolicyMessage)
- func UpdateNodeUserInput(userInput []policy.UserInput, errorhandler DeviceErrorHandler, ...) (bool, []policy.UserInput, []*events.NodeUserInputMessage)
- func UploadPublicKey(filename string, inBytes []byte, config *config.HorizonConfig, ...) bool
- func ValidStateChange(from string, to string) bool
- func ValidateAndConvertAPIAttribute(errorhandler ErrorHandler, permitEmpty bool, given Attribute) (persistence.Attribute, bool, error)
- func ValidateUserInput(userInput policy.UserInput, getService exchange.ServiceHandler) (bool, error)
- type API
- func (a *API) GetCSSURL() string
- func (a *API) GetExchangeId() string
- func (a *API) GetExchangeToken() string
- func (a *API) GetExchangeURL() string
- func (a *API) GetHTTPFactory() *config.HTTPClientFactory
- func (a *API) GetName() string
- func (a *API) Messages() chan events.Message
- func (a *API) NewEvent(incoming events.Message)
- type APIMicroserviceConfig
- type APIUserInputError
- type AllMicroservices
- type AllServices
- type AllWorkloads
- type Attribute
- type AttributeVerifier
- type BadRequestError
- type BlockchainState
- type Configstate
- type ConflictError
- type DeviceErrorHandler
- type DuplicateServiceError
- type ErrorHandler
- type EstablishedAgreementsByAgreementCreationTime
- type EstablishedAgreementsByAgreementTerminatedTime
- type EventLogByRecordId
- type HorizonDevice
- type KeyPairSimpleRecord
- type MSMissingVariableConfigError
- type MicroserviceConfig
- type MicroserviceDefById
- type MicroserviceDefByUpgradeStartTime
- type MicroserviceInstanceByCleanupStartTime
- type MicroserviceInstanceByMicroserviceDefId
- type MicroserviceInstanceOutput
- type NotFoundError
- type Service
- type SystemError
Constants ¶
const ( // from api_node.go EL_API_ERR_PARSING_INPUT_FOR_NODE_REG = "Error parsing input for node configuration/registration. Input body couldn't be deserialized to node object: %v, error: %v" EL_API_ERR_PARSING_INPUT_FOR_NODE_UNREG = "" /* 129-byte string literal not displayed */ EL_API_ERR_PARSING_INPUT_FOR_NODE_UPDATE = "Error parsing input for node update. Input body couldn't be deserialized to node object: %v, error: %v" EL_API_ERR_PARSING_INPUT_FOR_NODE_POLICY = "Error parsing input for node policy. Input body could not be deserialized as a policy object: %v, error: %v" EL_API_ERR_PARSING_INPUT_FOR_NODE_POLICY_PATCH = "" /* 140-byte string literal not displayed */ EL_API_ERR_POLICY_PATCH_INPUT_PROPERTY_ERROR = "Error parsing input for node policy patch. Input body did not contain a Constraint Expression or Property List: %v, error: %v" EL_API_ERR_PARSING_INPUT_FOR_NODE_UI = "Error parsing input for node user input. Input body could not be deserialized as a UserInput object: %v, error: %v" EL_API_ERR_IN_NODE_REG = "Error in node configuration/registration for node %v. %v" EL_API_ERR_IN_NODE_UPDATE = "Error in updating node %v. %v" EL_API_ERR_IN_NODE_UNREG = "Error in node unregistration. %v" EL_API_ERR_IN_VERIFY_EXCH_VERSION = "Error verifiying exchange version. error: %v" EL_API_ERR_IN_NODE_POLICY_CREATE = "Error in creating or replacing node policy. %v" EL_API_ERR_IN_NODE_POLICY_PATCH = "Error in patching node policy. %v" EL_API_ERR_IN_NODE_POLICY_DEL = "Error in deleting node policy. %v" EL_API_ERR_IN_NODE_UI_UPDATE = "Error in updating node user input. %v" EL_API_ERR_IN_NODE_UI_PATCH = "Error in patching node user input. %v" EL_API_ERR_IN_NODE_UI_DEL = "Error in deleting node userinput. %v" // from path_node.go EL_API_START_NODE_REG = "Start node configuration/registration for node %v." EL_API_START_NODE_UPDATE = "Start updating node %v." EL_API_COMPLETE_NODE_UPDATE = "Complete node update for %v." EL_API_START_NODE_UNREG = "Start node unregistration." EL_API_COMPLETE_NODE_UNREG = "Node unregistration complete for node %v." EL_API_ERR_NODE_UNREG_NOT_FOUND = "Error unregistring the node. The node is not found from the database." EL_API_ERR_NODE_UNREG_NOT_IN_STATE = "Error unregistring the node. The node must be in 'configured' or 'configuring' state in order to unconfigure it." EL_API_ERR_NODE_UNREG_WRONG_VALUE_FOR_RN = "Input error for node unregistration. %v is an incorrect value for removeNode" EL_API_ERR_NODE_UNREG_WRONG_VALUE_FOR_DC = "Input error for node unregistration. %v is an incorrect value for deepClean" EL_API_ERR_NODE_UNREG_WRONG_VALUE_FOR_BLOCK = "Input error for node unregistration. %v is an incorrect value for block" EL_API_ERR_READ_NODE_FROM_DB = "Unable to read node object from database, error %v" EL_API_ERR_SAVE_NODE_CONF_TO_DB = "Error saving new node config state (unconfiguring) in the database: %v" // from path_node_configstate.go EL_API_ERR_NODE_CONF_NOT_FOUND = "Error in node configuration. The node is not found from the database." EL_API_ERR_NODE_CONF_WRONG_STATE = "Error in node configuration. The node must be in 'configured' or 'configuring' state in order to change the state to %v." EL_API_UNSUP_NODE_STATE_TRANS = "Node state transition from '%v' to '%v' is not supported." EL_API_FAIL_GET_UI_FROM_DB = "Failed get user input from local db. %v" EL_API_FAIL_FIND_SVC_PREF_FROM_UI = "Failed to find preferences for service %v/%v from the local user input, error: %v" EL_API_ERR_SAVE_NODE_CONFSTATE = "Error saving new node config state to database: %v" EL_API_COMPLETE_NODE_REG = "Complete node configuration/registration for node %v." EL_API_ERR_SVC_CONF = "Error in service configuration for %v. %v" EL_API_ERR_GET_SREFS_FOR_PATTERN = "Error getting service references for pattern %v. %v" // from path_node_policy.go EL_API_NEW_NODE_POL = "New node policy: %v" EL_API_NODE_POL_DELETED = "Deleted node policy" // from path_node_userinput.go EL_API_NEW_NODE_UI = "New node user input: %v" EL_API_NO_NODE_UI_TO_DEL = "No node user input to detele" EL_API_DELETED_ALL_NODE_UI = "Deleted all node user input" // from path_service_config.go EL_API_START_SVC_CONFIG = "Start service configuration with user input for %v/%v." EL_API_START_SVC_AUTO_CONFIG = "Start service auto configuration for %v/%v." EL_API_COMPLETE_SVC_CONFIG = "Complete service configuration for %v/%v." EL_API_COMPLETE_SVC_AUTO_CONFIG = "Complete service auto configuration for %v/%v." EL_API_ERR_MISS_VAR_IN_SVC_CONFIG = "" /* 174-byte string literal not displayed */ // from api_service.go EL_API_ERR_CONFIG_SVC = "Error configuring service %v. %v" EL_API_ERR_CHANGE_SVC_CONFIGSTATE = "Error changing service configstate %v, error %v" EL_API_START_CHANGE_SVC_CONFIGSTATE = "Start changing service configuration state to %v for %v for the node." EL_API_COMPLETE_CHANGE_SVC_CONFIGSTATE = "Complete changing service configuration state to %v for %v for the node." )
messages for event logs
Variables ¶
var IllegalInputCharRegex = `[^-*+()?&! _\w\d.@,:/\\]`
var Unconfiguring bool
Global "static" field to remember that unconfig is in progress. We can't tell from the configstate in the node object because it eventually gets deleted at the end of unconfiguration.
Functions ¶
func ChangeServiceConfigState ¶
func ChangeServiceConfigState(service_cs *exchange.ServiceConfigState, errorhandler ErrorHandler, getDevice exchange.DeviceHandler, postDeviceSCS exchange.PostDeviceServicesConfigStateHandler, db *bolt.DB) (bool, []events.ServiceConfigState)
Change the config state for the given service in the exchange and return the services that are just changed to suspended. If the service url and org are both empty string, it applies to all the registered services for the node. If the service url is an empty string but org is not, it applies to all the registered the services for the given org.
func CreateHorizonDevice ¶
func CreateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, getOrg exchange.OrgHandlerWithContext, getPatterns exchange.PatternHandlerWithContext, getExchangeVersion exchange.ExchangeVersionHandler, patchDeviceHandler exchange.PatchDeviceHandler, getDeviceHandler exchange.DeviceHandler, em *events.EventStateManager, db *bolt.DB) (bool, *HorizonDevice, *HorizonDevice)
Given a demarshalled HorizonDevice object, validate it and save it, returning any errors.
func DeleteAgreement ¶
func DeleteAgreement(errorhandler ErrorHandler, agreementId string, db *bolt.DB) (bool, *events.ApiAgreementCancelationMessage)
func DeleteHorizonDevice ¶
func DeleteHorizonDevice(removeNode string, deepClean string, block string, em *events.EventStateManager, msgQueue chan events.Message, errorhandler ErrorHandler, db *bolt.DB) bool
Handles the DELETE verb on this resource.
func DeleteNodePolicy ¶
func DeleteNodePolicy(errorhandler DeviceErrorHandler, db *bolt.DB, nodeGetPolicyHandler exchange.NodePolicyHandler, nodeDeletePolicyHandler exchange.DeleteNodePolicyHandler) (bool, []*events.NodePolicyMessage)
Delete the node policy object.
func DeleteNodeUserInput ¶
func DeleteNodeUserInput(errorhandler DeviceErrorHandler, db *bolt.DB, getDevice exchange.DeviceHandler, patchDevice exchange.PatchDeviceHandler) (bool, []*events.NodeUserInputMessage)
Delete the node policy object.
func DeletePublicKey ¶
func DeletePublicKey(fileName string, config *config.HorizonConfig, errorhandler ErrorHandler) bool
func FinalizeAttributesSpecifiedInService ¶
func FinalizeAttributesSpecifiedInService(sp *persistence.ServiceSpec, attributes []persistence.Attribute) []persistence.Attribute
func FindAgreementsForOutput ¶
func FindAgreementsForOutput(db *bolt.DB) (map[string]map[string][]persistence.EstablishedAgreement, error)
func FindAndWrapAttributesForOutput ¶
serializeAttributeForOutput retrieves attributes by url from the DB and then serializes then as JSON, returning a byte array for convenient writing to an HTTP response.
func FindEventLogsForOutput ¶
func FindEventLogsForOutput(db *bolt.DB, all_logs bool, selections map[string][]string, msgPrinter *message.Printer) ([]persistence.EventLog, error)
This API returns the event logs saved on the db.
func FindNodePolicyForOutput ¶
func FindNodePolicyForOutput(db *bolt.DB) (*externalpolicy.ExternalPolicy, error)
Return an empty policy object or the object that's in the local database.
func FindNodeUserInputForOutput ¶
Return an empty user input object or the object that's in the local database.
func FindPublicKeyForOutput ¶
func FindPublicKeyForOutput(fileName string, config *config.HorizonConfig) (string, error)
func FindPublicKeysForOutput ¶
func FindPublicKeysForOutput(config *config.HorizonConfig, verbose bool) (map[string][]interface{}, error)
func FindServiceConfigForOutput ¶
func FindServiceConfigForOutput(pm *policy.PolicyManager, db *bolt.DB) (map[string][]MicroserviceConfig, error)
func FindServiceConfigStateForOutput ¶
func FindServiceConfigStateForOutput(errorhandler ErrorHandler, getServicesConfigState exchange.ServicesConfigStateHandler, db *bolt.DB) (bool, map[string][]exchange.ServiceConfigState)
get the service configuration state for all the registered services.
func FindSurfaceLogsForOutput ¶
func FindSurfaceLogsForOutput(db *bolt.DB, msgPrinter *message.Printer) ([]persistence.SurfaceError, error)
func GetMicroserviceContainer ¶
func GetMicroserviceContainer(dockerEndpoint string, mURL string, mOrg string, mVersion string, mInstanceId string) ([]dockerclient.APIContainers, error)
Get docker container metadata from the docker API for microservice containers
func GetWorkloadContainers ¶
func GetWorkloadContainers(dockerEndpoint string, agreementId string) ([]dockerclient.APIContainers, error)
Get docker container metadata from the docker API for workload containers
func InputIsIllegal ¶
func LogDeviceEvent ¶
func LogDeviceEvent(db *bolt.DB, severity string, message *persistence.MessageMeta, event_code string, device interface{})
func LogServiceEvent ¶
func LogServiceEvent(db *bolt.DB, severity string, message *persistence.MessageMeta, event_code string, service *Service)
func MapInputIsIllegal ¶
returns: faulty value, msg, error
func MarkI18nMessages ¶
func MarkI18nMessages()
This is does nothing useful at run time. This code is only used in compileing time to make the eventlog messages gets into the catalog so that they can be translated. The event log messages will be saved in English. But the CLI can request them in different languages.
func NoOpStateChange ¶
func PatchNodePolicy ¶
func PatchNodePolicy(patchObject interface{}, errorhandler DeviceErrorHandler, nodeGetPolicyHandler exchange.NodePolicyHandler, nodePatchPolicyHandler exchange.PutNodePolicyHandler, db *bolt.DB) (bool, *externalpolicy.ExternalPolicy, []*events.NodePolicyMessage)
Update a single field of the policy object in the local node db and in the exchange
func PatchNodeUserInput ¶
func PatchNodeUserInput(patchObject []policy.UserInput, errorhandler DeviceErrorHandler, getDevice exchange.DeviceHandler, patchDevice exchange.PatchDeviceHandler, getService exchange.ServiceHandler, db *bolt.DB) (bool, []policy.UserInput, []*events.NodeUserInputMessage)
Update a single field of the UserInput object in the local node db and in the exchange
func UpdateHorizonDevice ¶
func UpdateHorizonDevice(device *HorizonDevice, errorhandler ErrorHandler, getExchangeVersion exchange.ExchangeVersionHandler, db *bolt.DB) (bool, *HorizonDevice, *HorizonDevice)
Handles the PATCH verb on this resource. Only the exchange token is updateable.
func UpdateNodePolicy ¶
func UpdateNodePolicy(nodePolicy *externalpolicy.ExternalPolicy, errorhandler DeviceErrorHandler, nodeGetPolicyHandler exchange.NodePolicyHandler, nodePutPolicyHandler exchange.PutNodePolicyHandler, db *bolt.DB) (bool, *externalpolicy.ExternalPolicy, []*events.NodePolicyMessage)
Update the policy object in the local node database and in the exchange.
func UpdateNodeUserInput ¶
func UpdateNodeUserInput(userInput []policy.UserInput, errorhandler DeviceErrorHandler, getDevice exchange.DeviceHandler, patchDevice exchange.PatchDeviceHandler, getService exchange.ServiceHandler, db *bolt.DB) (bool, []policy.UserInput, []*events.NodeUserInputMessage)
Update the user input object in the local node database and in the exchange.
func UploadPublicKey ¶
func UploadPublicKey(filename string, inBytes []byte, config *config.HorizonConfig, errorhandler ErrorHandler) bool
func ValidStateChange ¶
func ValidateAndConvertAPIAttribute ¶
func ValidateAndConvertAPIAttribute(errorhandler ErrorHandler, permitEmpty bool, given Attribute) (persistence.Attribute, bool, error)
func ValidateUserInput ¶
func ValidateUserInput(userInput policy.UserInput, getService exchange.ServiceHandler) (bool, error)
Validate 1) service exist; 2) variables defined in the service; 3) values have correct type
Types ¶
type API ¶
type API struct { worker.Manager // embedded field EC *worker.BaseExchangeContext // contains filtered or unexported fields }
func NewAPIListener ¶
func NewAPIListener(name string, cfg *config.HorizonConfig, db *bolt.DB, pm *policy.PolicyManager) *API
func (*API) GetExchangeId ¶
A local implementation of the ExchangeContext interface because the API object is not an anax worker.
func (*API) GetExchangeToken ¶
func (*API) GetExchangeURL ¶
func (*API) GetHTTPFactory ¶
func (a *API) GetHTTPFactory() *config.HTTPClientFactory
type APIMicroserviceConfig ¶
type APIMicroserviceConfig struct { SensorUrl string `json:"sensor_url"` // uniquely identifying SensorOrg string `json:"sensor_org"` // The org that holds the ms definition SensorVersion string `json:"sensor_version"` // added for ms split. It is only used for microsevice. If it is omitted, old behavior is assumed. AutoUpgrade bool `json:"auto_upgrade"` // added for ms split. The default is true. If the sensor (microservice) should be automatically upgraded when new versions become available. ActiveUpgrade bool `json:"active_upgrade"` // added for ms split. The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements terminated before making upgrade. Attributes []interface{} `json:"attributes"` }
type APIUserInputError ¶
APIUserInputError is for problems found with input path variables or input bodies. The Input field is flexible; could be a field name or other. Note: the info in this field is intended to be consumed by humans, either API consumers or developers of the UI. Add enum codes if these are to be evaluated in frontend code.
func NewAPIUserInputError ¶
func NewAPIUserInputError(err string, input string) *APIUserInputError
func (APIUserInputError) Error ¶
func (e APIUserInputError) Error() string
type AllMicroservices ¶
type AllMicroservices struct { Config []MicroserviceConfig `json:"config"` // the microservice configurations Instances map[string][]interface{} `json:"instances"` // the microservice instances that are running Definitions map[string][]interface{} `json:"definitions"` // the definitions of microservices from the exchange }
The output format for GET microservice
func NewMicroserviceOutput ¶
func NewMicroserviceOutput() *AllMicroservices
type AllServices ¶
type AllServices struct { Config []MicroserviceConfig `json:"config"` // the service configurations Instances map[string][]interface{} `json:"instances"` // the mservice instances that are running Definitions map[string][]interface{} `json:"definitions"` // the definitions of services from the exchange }
The output format for GET service
func FindServicesForOutput ¶
func FindServicesForOutput(pm *policy.PolicyManager, db *bolt.DB, config *config.HorizonConfig) (*AllServices, error)
This API returns everything we know about services configured to and running on an edge node. It includes service definition metadata that is cached from the exchange, userInput variable config for each service, running containers for each service, and the state of each service as it is being managed by anax.
func NewServiceOutput ¶
func NewServiceOutput() *AllServices
type AllWorkloads ¶
type AllWorkloads struct {
Containers *[]dockerclient.APIContainers `json:"containers"` // the docker info for a running container
}
The output format for GET workload
func NewWorkloadOutput ¶
func NewWorkloadOutput() *AllWorkloads
type Attribute ¶
type Attribute struct { Id *string `json:"id"` Type *string `json:"type"` Label *string `json:"label"` Publishable *bool `json:"publishable"` HostOnly *bool `json:"host_only"` ServiceSpecs *persistence.ServiceSpecs `json:"service_specs,omitempty"` Mappings *map[string]interface{} `json:"mappings"` }
func NewAttribute ¶
type AttributeVerifier ¶
type AttributeVerifier func(attr persistence.Attribute) (bool, error)
AttributeVerifier returns true if there is a handled inputError (one that caused a write to the http responsewriter) and error if there is a system processing problem
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
Bad Requests are expected, since they can occur as the result of incorrect usage of the API.
func NewBadRequestError ¶
func NewBadRequestError(err string) *BadRequestError
func (BadRequestError) Error ¶
func (e BadRequestError) Error() string
type BlockchainState ¶
type BlockchainState struct {
// contains filtered or unexported fields
}
type Configstate ¶
type Configstate struct { State *string `json:"state"` LastUpdateTime *uint64 `json:"last_update_time,omitempty"` }
func FindConfigstateForOutput ¶
func FindConfigstateForOutput(db *bolt.DB) (*Configstate, error)
func UpdateConfigstate ¶
func UpdateConfigstate(cfg *Configstate, errorhandler ErrorHandler, getPatterns exchange.PatternHandler, resolveService exchange.ServiceResolverHandler, getService exchange.ServiceHandler, getDevice exchange.DeviceHandler, patchDevice exchange.PatchDeviceHandler, db *bolt.DB, config *config.HorizonConfig) (bool, *Configstate, []*events.PolicyCreatedMessage)
Given a demarshalled Configstate object, validate it and save, returning any errors.
func (*Configstate) String ¶
func (c *Configstate) String() string
type ConflictError ¶
type ConflictError struct {
// contains filtered or unexported fields
}
Conflict Errors are expected, since they can occur as the result of incorrect usage of the API.
func NewConflictError ¶
func NewConflictError(err string) *ConflictError
func (ConflictError) Error ¶
func (e ConflictError) Error() string
type DeviceErrorHandler ¶
This type is used for the node related the functions
type DuplicateServiceError ¶
type DuplicateServiceError struct { Err string `json:"error"` Input string `json:"input,omitempty"` }
DuplicateServiceError occurs when a microservice configuration is attempted for a service that has already been configured.
func NewDuplicateServiceError ¶
func NewDuplicateServiceError(err string, input string) *DuplicateServiceError
func (DuplicateServiceError) Error ¶
func (e DuplicateServiceError) Error() string
type ErrorHandler ¶
This function type is used to enable plug replaceable error handlers within the API implementation so that business logic can be tested independently from the HTTP transport that is used to access the API.
func GetHTTPErrorHandler ¶
func GetHTTPErrorHandler(w http.ResponseWriter) ErrorHandler
Use this function to obtain an error handler that writes errors to the HTTP response.
func GetPassThroughErrorHandler ¶
func GetPassThroughErrorHandler(passthruErr *error) ErrorHandler
Use this function to obtain an error handler that simply passes the error through itself back to caller. This is done by modifying the error variable passed to this function.
type EstablishedAgreementsByAgreementCreationTime ¶
type EstablishedAgreementsByAgreementCreationTime []persistence.EstablishedAgreement
Functions and types that plug into the go sorting feature
func (EstablishedAgreementsByAgreementCreationTime) Len ¶
func (s EstablishedAgreementsByAgreementCreationTime) Len() int
func (EstablishedAgreementsByAgreementCreationTime) Less ¶
func (s EstablishedAgreementsByAgreementCreationTime) Less(i, j int) bool
func (EstablishedAgreementsByAgreementCreationTime) Swap ¶
func (s EstablishedAgreementsByAgreementCreationTime) Swap(i, j int)
type EstablishedAgreementsByAgreementTerminatedTime ¶
type EstablishedAgreementsByAgreementTerminatedTime []persistence.EstablishedAgreement
func (EstablishedAgreementsByAgreementTerminatedTime) Len ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Len() int
func (EstablishedAgreementsByAgreementTerminatedTime) Less ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Less(i, j int) bool
func (EstablishedAgreementsByAgreementTerminatedTime) Swap ¶
func (s EstablishedAgreementsByAgreementTerminatedTime) Swap(i, j int)
type EventLogByRecordId ¶
type EventLogByRecordId []persistence.EventLog
func (EventLogByRecordId) Len ¶
func (s EventLogByRecordId) Len() int
func (EventLogByRecordId) Less ¶
func (s EventLogByRecordId) Less(i, j int) bool
func (EventLogByRecordId) Swap ¶
func (s EventLogByRecordId) Swap(i, j int)
type HorizonDevice ¶
type HorizonDevice struct { Id *string `json:"id"` Org *string `json:"organization"` Pattern *string `json:"pattern"` // a simple name, not prefixed with the org Name *string `json:"name,omitempty"` Token *string `json:"token,omitempty"` TokenLastValidTime *uint64 `json:"token_last_valid_time,omitempty"` TokenValid *bool `json:"token_valid,omitempty"` HA *bool `json:"ha,omitempty"` Config *Configstate `json:"configstate,omitempty"` }
func ConvertFromPersistentHorizonDevice ¶
func ConvertFromPersistentHorizonDevice(pDevice *persistence.ExchangeDevice) *HorizonDevice
This is a type conversion function but note that the token field within the persistent is explicitly omitted so that it's not exposed in the API.
func FindHorizonDeviceForOutput ¶
func FindHorizonDeviceForOutput(db *bolt.DB) (*HorizonDevice, error)
func (HorizonDevice) String ¶
func (h HorizonDevice) String() string
type KeyPairSimpleRecord ¶
type KeyPairSimpleRecord struct { // embedded listkeys.KeyPairSimple ID string `json:"id"` }
type MSMissingVariableConfigError ¶
type MSMissingVariableConfigError struct { Err string `json:"error"` Input string `json:"input,omitempty"` }
MSMissingVariableConfigError is for problems found with microservice configuration where the microservice definition requires 1 or more input variables to be set but 1 or more of those variables has not been set.
func NewMSMissingVariableConfigError ¶
func NewMSMissingVariableConfigError(err string, input string) *MSMissingVariableConfigError
func (MSMissingVariableConfigError) Error ¶
func (e MSMissingVariableConfigError) Error() string
type MicroserviceConfig ¶
type MicroserviceConfig struct { SensorUrl string `json:"sensor_url"` // uniquely identifying SensorOrg string `json:"sensor_org"` // The org that holds the ms definition SensorVersion string `json:"sensor_version"` // added for ms split. It is only used for microsevice. If it is omitted, old behavior is assumed. AutoUpgrade bool `json:"auto_upgrade"` // added for ms split. The default is true. If the sensor (microservice) should be automatically upgraded when new versions become available. ActiveUpgrade bool `json:"active_upgrade"` // added for ms split. The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements terminated before making upgrade. Attributes []persistence.Attribute `json:"attributes"` }
The output format for microservice config
func NewMicroserviceConfig ¶
func NewMicroserviceConfig(url string, org string, version string) *MicroserviceConfig
type MicroserviceDefById ¶
type MicroserviceDefById []interface{}
func (MicroserviceDefById) Len ¶
func (s MicroserviceDefById) Len() int
func (MicroserviceDefById) Less ¶
func (s MicroserviceDefById) Less(i, j int) bool
func (MicroserviceDefById) Swap ¶
func (s MicroserviceDefById) Swap(i, j int)
type MicroserviceDefByUpgradeStartTime ¶
type MicroserviceDefByUpgradeStartTime []interface{}
func (MicroserviceDefByUpgradeStartTime) Len ¶
func (s MicroserviceDefByUpgradeStartTime) Len() int
func (MicroserviceDefByUpgradeStartTime) Less ¶
func (s MicroserviceDefByUpgradeStartTime) Less(i, j int) bool
func (MicroserviceDefByUpgradeStartTime) Swap ¶
func (s MicroserviceDefByUpgradeStartTime) Swap(i, j int)
type MicroserviceInstanceByCleanupStartTime ¶
type MicroserviceInstanceByCleanupStartTime []interface{}
func (MicroserviceInstanceByCleanupStartTime) Len ¶
func (s MicroserviceInstanceByCleanupStartTime) Len() int
func (MicroserviceInstanceByCleanupStartTime) Less ¶
func (s MicroserviceInstanceByCleanupStartTime) Less(i, j int) bool
func (MicroserviceInstanceByCleanupStartTime) Swap ¶
func (s MicroserviceInstanceByCleanupStartTime) Swap(i, j int)
type MicroserviceInstanceByMicroserviceDefId ¶
type MicroserviceInstanceByMicroserviceDefId []interface{}
func (MicroserviceInstanceByMicroserviceDefId) Len ¶
func (s MicroserviceInstanceByMicroserviceDefId) Len() int
func (MicroserviceInstanceByMicroserviceDefId) Less ¶
func (s MicroserviceInstanceByMicroserviceDefId) Less(i, j int) bool
func (MicroserviceInstanceByMicroserviceDefId) Swap ¶
func (s MicroserviceInstanceByMicroserviceDefId) Swap(i, j int)
type MicroserviceInstanceOutput ¶
type MicroserviceInstanceOutput struct { persistence.MicroserviceInstance // an embedded field Containers *[]dockerclient.APIContainers `json:"containers"` // the docker info for a running container }
The output format for microservice instances
func NewAgreementServiceInstanceOutput ¶
func NewAgreementServiceInstanceOutput(ag *persistence.EstablishedAgreement, containers *[]dockerclient.APIContainers) *MicroserviceInstanceOutput
func NewMicroserviceInstanceOutput ¶
func NewMicroserviceInstanceOutput(mi persistence.MicroserviceInstance, containers *[]dockerclient.APIContainers) *MicroserviceInstanceOutput
type NotFoundError ¶
Not Found errors are expected, since they can occur as the result of incorrect usage of the API.
func NewNotFoundError ¶
func NewNotFoundError(err string, input string) *NotFoundError
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type Service ¶
type Service struct { Url *string `json:"url"` // The URL of the service definition. Org *string `json:"organization"` // The org that holds the service definition. Name *string `json:"name"` // Optional, may not be uniquely identifying. Arch *string `json:"arch"` // The arch of the service to be configured, could be a synonym. VersionRange *string `json:"versionRange"` // The version range that the configuration applies to. The default is [0.0.0,INFINITY) AutoUpgrade *bool `json:"auto_upgrade"` // The default is true. If the service should be automatically upgraded when a new version becomes available. ActiveUpgrade *bool `json:"active_upgrade"` // The default is false. If horizon should actively terminate agreements when new versions become available (active) or wait for all the associated agreements to terminate before upgrading. Attributes *[]Attribute `json:"attributes"` }
uses pointers for members b/c it allows nil-checking at deserialization; !Important!: the json field names here must not change w/out changing the error messages returned from the API, they are not programmatically determined
func CreateService ¶
func CreateService(service *Service, errorhandler ErrorHandler, getPatterns exchange.PatternHandler, resolveService exchange.ServiceResolverHandler, getService exchange.ServiceHandler, getDevice exchange.DeviceHandler, patchDevice exchange.PatchDeviceHandler, mergedUserInput *policy.UserInput, db *bolt.DB, config *config.HorizonConfig, from_user bool) (bool, *Service, *events.PolicyCreatedMessage)
Given a demarshalled Service object, validate it and save it, returning any errors.
func NewService ¶
Constructor used to create service objects for programmatic creation of services.
type SystemError ¶
type SystemError struct {
// contains filtered or unexported fields
}
System Errors are generally unexpected, infrastructural problems that just need to be reported out to the caller.
func NewSystemError ¶
func NewSystemError(err string) *SystemError
func (SystemError) Error ¶
func (e SystemError) Error() string
Source Files
¶
- api.go
- api_agreement.go
- api_attribute.go
- api_eventlog.go
- api_node.go
- api_publickey.go
- api_service.go
- api_status.go
- api_token_random.go
- container.go
- errors.go
- input.go
- input_validation.go
- messages.go
- output.go
- path_agreement.go
- path_attributes.go
- path_eventlog.go
- path_node.go
- path_node_configstate.go
- path_node_policy.go
- path_node_userinput.go
- path_publickey.go
- path_service.go
- path_service_config.go
- path_service_configstate.go