Documentation
¶
Index ¶
- Constants
- Variables
- func DKey(key string) string
- func HttpRequest(client *http.Client, uri, method, user, pwd string, resultCode int) ([]byte, error)
- func Key(iType, name string) string
- func Retry(attempts int, sleep time.Duration, f func(input interface{}) error, ...) error
- func SaveInfo(f multipart.File) (string, error)
- func SyncPath() string
- func SyncTemp() string
- type API
- func (r *API) AdmitRegistered(macAddress, hostUUID string) error
- func (r *API) Augment(events *Events) (*Events, error)
- func (r *API) AuthenticateActivationSvc(request http.Request) (*h.UserPrincipal, error)
- func (r *API) AuthenticatePilot(token string) (*h.UserPrincipal, error)
- func (r *API) AuthenticateUser(request http.Request) (*h.UserPrincipal, error)
- func (r *API) CompleteJob(status *JobResult) error
- func (r *API) CreateJobBatch(info JobBatchInfo) (int64, error)
- func (r *API) DecommissionHost(hostUUID string) error
- func (r *API) DeleteCommand(cmdName string) (string, error)
- func (r *API) DeleteDictionary(key string) (string, error)
- func (r *API) GetAllCommands() ([]Cmd, error)
- func (r *API) GetAreas(orgGroup string) ([]Area, error)
- func (r *API) GetCVEBaseline(score float64, label []string) ([]CvePackage, error)
- func (r *API) GetCommand(cmdName string) (*Cmd, error)
- func (r *API) GetCommandValue(fxKey string) (*CmdInfo, error)
- func (r *API) GetDictionaries(values bool) ([]*Dictionary, error)
- func (r *API) GetDictionary(key string) (*Dictionary, error)
- func (r *API) GetHost(uuid string) (*Host, error)
- func (r *API) GetHosts(oGroup, or, ar, loc string, label []string) ([]Host, error)
- func (r *API) GetHostsAtLocations(locations []string) ([]Host, error)
- func (r *API) GetJobBatches(name, owner *string, from, to *time.Time, label *[]string) ([]JobBatch, error)
- func (r *API) GetJobs(oGroup, or, ar, loc string, batchId *int64) ([]Job, error)
- func (r *API) GetLocations(area string) ([]Location, error)
- func (r *API) GetOrgGroups() ([]Org, error)
- func (r *API) GetOrgs(orgGroup string) ([]Org, error)
- func (r *API) GetPackageAPI(name string) ([]*data.FxInfo, error)
- func (r *API) GetPackages() ([]PackageInfo, error)
- func (r *API) Login(username string) (h.Controls, error)
- func (r *API) Ping() (jobId int64, fxKey string, fxVersion int64, err error)
- func (r *API) PingInterval() time.Duration
- func (r *API) PutCommand(cmd *Cmd) error
- func (r *API) Register(reg *RegistrationRequest) (*RegistrationResponse, error)
- func (r *API) SetAdmission(admission Admission) error
- func (r *API) SetDictionary(dictionary Dictionary) (string, error)
- func (r *API) SetRegistration(registration Registration) error
- func (r *API) SubmitLogs(channel string, content []byte) ConnResult
- func (r *API) SubmitMetrics(channel string, content []byte) ConnResult
- func (r *API) UndoRegistration(mac string) error
- func (r *API) UpsertCVE(hostUUID string, rep *CveReport) error
- type Client
- func (c *Client) Delete(url string, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) Get(url string, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) MakeRequest(method string, url string, payload Serializable, ...) (*http.Response, error)
- func (c *Client) Post(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
- func (c *Client) Put(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
- type ClientConf
- type Conf
- func (c *Conf) GetActivationPwd() string
- func (c *Conf) GetActivationURI() string
- func (c *Conf) GetActivationUser() string
- func (c *Conf) GetArtRegPackageFilter() string
- func (c *Conf) GetCorsHeaders() string
- func (c *Conf) GetCorsOrigin() string
- func (c *Conf) GetTenant() string
- func (c *Conf) PingIntervalSecs() time.Duration
- type ConfKey
- type ConnResult
- type DataPoint
- type Db
- type Diff
- type DiffLinkReport
- type DiffReport
- type EventPublisher
- type HttpRequestProcessor
- type Logger
- type MetricValueType
- type OtelDataPointConverter
- type Result
- type Row
- type Serializable
- type StopRetry
- type Table
Constants ¶
const ( DELETE = "DELETE" PUT = "PUT" GET = "GET" POST = "POST" )
const ( MetricHistogramBoundKeyV2 = "le" MetricHistogramCountSuffix = "_count" MetricHistogramSumSuffix = "_sum" MetricHistogramBucketSuffix = "_bucket" MetricSummaryQuantileKeyV2 = "quantile" MetricSummaryCountSuffix = "_count" MetricSummarySumSuffix = "_sum" AttributeInstrumentationLibraryName = "otel.library.name" AttributeInstrumentationLibraryVersion = "otel.library.version" )
Variables ¶
var Version = "0.0.0.0"
Version placeholder variable for the version number displayed on cli this value gets overridden at build time with the correct version in the build file
Functions ¶
func HttpRequest ¶
func Retry ¶
func Retry(attempts int, sleep time.Duration, f func(input interface{}) error, input interface{}) error
Retry the execution of a function if an error is returned to provide an easy way to increase resiliency. This is especially useful when making HTTP requests or doing anything else that has to reach out across the network. There are two options for stopping the retry loop before all the attempts are made:
- return nil; or
- return a wrapped error: stop{err}
Choose option #2 when an error occurs where retrying would be futile. Consider most 4XX HTTP status codes. They indicate that the client has done something wrong and subsequent retries, without any modification to the request will result in the same response. In this case we still want to return an error, so we wrap the error in the stop type. The actual error that is returned by the retry function will be the original non-wrapped error. This allows for later checks like err == ErrUnauthorized.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API backend services API
func (*API) AdmitRegistered ¶
AdmitRegistered admits a host that has been registered with a mac-address after confirmation of activation
func (*API) AuthenticateActivationSvc ¶
func (*API) AuthenticatePilot ¶
func (r *API) AuthenticatePilot(token string) (*h.UserPrincipal, error)
AuthenticatePilot authenticates pilot requests
func (*API) AuthenticateUser ¶
AuthenticateUser authenticate user requests
func (*API) CompleteJob ¶
func (*API) CreateJobBatch ¶
func (*API) DecommissionHost ¶
func (*API) GetAllCommands ¶
func (*API) GetCVEBaseline ¶
func (*API) GetCommand ¶
func (*API) GetCommandValue ¶
func (*API) GetDictionaries ¶
func (*API) GetDictionary ¶
func (*API) GetHosts ¶
GetHosts get a list of hosts filtered by oGroup: organisation group key or: organisation key ar: area key loc: location key
func (*API) GetHostsAtLocations ¶
func (*API) GetJobBatches ¶
func (*API) GetLocations ¶
func (*API) GetOrgGroups ¶
func (*API) GetPackages ¶
GetPackages get a list of packages in the backing Artisan registry
func (*API) Login ¶
Login if the user is authenticated returns a list of access controls otherwise an error is returned
func (*API) PingInterval ¶
func (*API) PutCommand ¶
PutCommand put the command in the Onix database
func (*API) SetAdmission ¶
func (*API) SetDictionary ¶
func (*API) SetRegistration ¶
func (*API) SubmitLogs ¶
func (r *API) SubmitLogs(channel string, content []byte) ConnResult
SubmitLogs post the logs to a backend using a connector TODO: use file buffer to pass logs to connector as done in SubmitMetrics
func (*API) SubmitMetrics ¶
func (r *API) SubmitMetrics(channel string, content []byte) ConnResult
SubmitMetrics post the metrics to a backend using a connector
func (*API) UndoRegistration ¶
type Client ¶
Client REM HTTP client
func NewClient ¶
func NewClient(conf *ClientConf) (*Client, error)
NewClient creates a new Onix Web API client
func (*Client) MakeRequest ¶
func (c *Client) MakeRequest(method string, url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
MakeRequest Make a generic HTTP request
func (*Client) Post ¶
func (c *Client) Post(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
Post Make a POST HTTP request to the specified URL
func (*Client) Put ¶
func (c *Client) Put(url string, payload Serializable, processor HttpRequestProcessor) (*http.Response, error)
Put Make a PUT HTTP request to the specified URL
type ClientConf ¶
type ClientConf struct { // the base URI for the service BaseURI string // disables TLS certificate verification InsecureSkipVerify bool // the user username for Basic and OpenId user authentication Username string // the user password for Basic and OpenId user authentication Password string // time out Timeout time.Duration // client proxy Proxy func(*http.Request) (*url.URL, error) }
ClientConf client configuration information
type Conf ¶
type Conf struct { }
func (*Conf) GetActivationPwd ¶
func (*Conf) GetActivationURI ¶
func (*Conf) GetActivationUser ¶
func (*Conf) GetArtRegPackageFilter ¶
func (*Conf) GetCorsHeaders ¶
func (*Conf) GetCorsOrigin ¶
func (*Conf) PingIntervalSecs ¶
PingIntervalSecs the pilot ping interval
type ConfKey ¶
type ConfKey string
const ( ConfDbName ConfKey = "PILOT_CTL_DB_NAME" ConfDbHost ConfKey = "PILOT_CTL_DB_HOST" ConfDbPort ConfKey = "PILOT_CTL_DB_PORT" ConfDbUser ConfKey = "PILOT_CTL_DB_USER" ConfDbPwd ConfKey = "PILOT_CTL_DB_PWD" ConfPingIntervalSecs ConfKey = "PILOT_CTL_PING_INTERVAL_SECS" ConfILinkUri ConfKey = "PILOT_CTL_ILINK_URI" ConfILinkUser ConfKey = "PILOT_CTL_ILINK_USER" ConfILinkPwd ConfKey = "PILOT_CTL_ILINK_PWD" ConfILinkInsecureSkipVerify ConfKey = "PILOT_CTL_ILINK_INSECURE_SKIP_VERIFY" ConfArtRegURI ConfKey = "PILOT_CTL_ART_REG_URI" ConfArtRegUser ConfKey = "PILOT_CTL_ART_REG_USER" ConfArtRegPwd ConfKey = "PILOT_CTL_ART_REG_PWD" ConfArtRegPackageFilter ConfKey = "PILOT_CTL_ART_REG_PACKAGE_FILTER" ConfActURI ConfKey = "PILOT_CTL_ACTIVATION_URI" ConfActUser ConfKey = "PILOT_CTL_ACTIVATION_USER" ConfActPwd ConfKey = "PILOT_CTL_ACTIVATION_PWD" ConfTenant ConfKey = "PILOT_CTL_TENANT" ConfDbMaxConn ConfKey = "PILOT_CTL_DB_MAXCONN" ConfCorsOrigin ConfKey = "PILOT_CTL_CORS_ORIGIN" ConfCorsHeaders ConfKey = "PILOT_CTL_CORS_HEADERS" ConfSyncPath ConfKey = "PILOT_CTL_SYNC_PATH" ConfTelemBufferPath ConfKey = "PILOT_CTL_TELEM_BUFFER_PATH" ConfTelemConnectors ConfKey = "PILOT_CTL_TELEM_CONN" )
type ConnResult ¶
type ConnResult struct { Error string `json:"e,omitempty"` TotalEntries int `json:"t,omitempty"` SuccessfulEntries int `json:"s,omitempty"` }
ConnResult the result of the connector execution
type Diff ¶
type Diff struct { OG *DiffReport `json:"org_groups" yaml:"org_groups"` OR *DiffReport `json:"orgs" yaml:"orgs"` AR *DiffReport `json:"areas" yaml:"areas"` LO *DiffReport `json:"locations" yaml:"locations"` LINKS *DiffLinkReport `json:"links" yaml:"links"` }
type DiffLinkReport ¶
type DiffLinkReport struct { Added []linkInfo `json:"added,omitempty" yaml:"added,omitempty"` Removed []linkInfo `json:"removed" yaml:"removed,omitempty"` }
type DiffReport ¶
type DiffReport struct { Added *infoList `json:"added,omitempty" yaml:"added,omitempty"` Removed *infoList `json:"removed" yaml:"removed,omitempty"` Updated *infoList `json:"updated" yaml:"updated,omitempty"` }
type EventPublisher ¶
type EventPublisher struct {
// contains filtered or unexported fields
}
func NewEventPublisher ¶
func NewEventPublisher() *EventPublisher
func (*EventPublisher) Publish ¶
func (p *EventPublisher) Publish(payload *types.Events)
type HttpRequestProcessor ¶
type HttpRequestProcessor func(req *http.Request, payload Serializable) error
HttpRequestProcessor modify the http request for example by adding any relevant http headers payload is provided for example, in case a Content-MD5 header has to be added to the request
type MetricValueType ¶
type MetricValueType uint8
const ( MetricValueTypeUntyped MetricValueType = iota MetricValueTypeGauge MetricValueTypeSum MetricValueTypeHistogram MetricValueTypeSummary )
func (MetricValueType) String ¶
func (vType MetricValueType) String() string
type OtelDataPointConverter ¶
type OtelDataPointConverter struct {
// contains filtered or unexported fields
}
func NewOtelDataPointConverter ¶
func NewOtelDataPointConverter() OtelDataPointConverter
type Serializable ¶
Serializable all entities interface for payload serialisation