Documentation ¶
Index ¶
- Variables
- func CommitLastState() error
- func DeviceAuth() string
- func GetLastStates() map[string]LastState
- func GetModifiedTime() time.Time
- func HTTPTransport() http.RoundTripper
- func IsLinked() bool
- func IsRoot() bool
- func IsSocketServicePresent() bool
- func LoadConfig() error
- func ReadFile(name string) ([]byte, error)
- func RunCheckViaHelper(uuid string) (bool, error)
- func RunCommand(name string, arg ...string) (string, error)
- func Sanitize(s string) string
- func SaveConfig() error
- func SelfExe() string
- func SystemDevice() (string, error)
- func SystemSerial() (string, error)
- func SystemUUID() (string, error)
- func UpdateLastState(newState LastState)
- type Broadcaster
- type CheckStatus
- type LastState
- type LinkingDevice
- type ParetoConfig
- type ReportingDevice
Constants ¶
This section is empty.
Variables ¶
var ( //go:embed icon_white.png IconWhite []byte //go:embed icon_black.png IconBlack []byte )
var ( Version = "dev" Commit = "none" Date = "unknown" )
var ReadFileMocks map[string]string
ReadFileMocks is a map that simulates file reading operations by mapping file paths (as keys) to their corresponding file contents (as values). This can be used for testing purposes to mock the behavior of reading files without actually accessing the file system.
var RunCommandMocks map[string]string
RunCommandMocks is a map that stores mock command outputs. The key is the command string, and the value is the corresponding mock output.
var SocketPath = "/var/run/pareto-linux.sock"
Functions ¶
func CommitLastState ¶
func CommitLastState() error
Commit writes the current state map to the TOML file.
func DeviceAuth ¶
func DeviceAuth() string
DeviceAuth decodes a JWT token from the shared configuration's AuthToken, extracts the payload, and returns the token string from the payload. It returns an empty string if there is an error during decoding or unmarshalling.
func GetLastStates ¶
func GetModifiedTime ¶
func HTTPTransport ¶
func HTTPTransport() http.RoundTripper
SafeHTTPTransport is a custom HTTP transport with secure TLS settings and a custom User-Agent.
func IsLinked ¶
func IsLinked() bool
IsLinked checks if the team is linked by verifying that both the TeamID and AuthToken in the shared configuration are not empty strings. It returns true if both values are present, indicating that the team is linked; otherwise, it returns false.
func IsSocketServicePresent ¶
func IsSocketServicePresent() bool
func LoadConfig ¶
func LoadConfig() error
func ReadFile ¶
ReadFile reads the content of the file specified by the given name. If the code is running in a testing environment, it will return the content from the ReadFileMocks map instead of reading from the actual file system. If the file name is not found in the ReadFileMocks map, it returns an error. Otherwise, it reads the file content from the file system.
func RunCheckViaHelper ¶
func RunCommand ¶
RunCommand executes a command with the given name and arguments, and returns the combined standard output and standard error as a string. If testing is enabled, it returns a predefined fixture instead of executing the command.
func Sanitize ¶
Sanitize takes a string and returns a sanitized version containing only ASCII characters. It converts non-ASCII characters to underscores and keeps only alphanumeric characters and select punctuation marks (., !, -, ', ", _, ,).
func SaveConfig ¶
func SaveConfig() error
func SystemDevice ¶
func SystemSerial ¶
func SystemUUID ¶
func UpdateLastState ¶
func UpdateLastState(newState LastState)
UpdateState updates the LastState struct in the in-memory map and commits to the TOML file.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Broadcaster structure
func (*Broadcaster) Register ¶
func (b *Broadcaster) Register() chan string
Register adds a new consumer channel
func (*Broadcaster) Send ¶
func (b *Broadcaster) Send()
Send sends a message to the broadcaster's input channel
func (*Broadcaster) Unregister ¶
func (b *Broadcaster) Unregister(ch chan string)
Unregister removes a consumer channel
type LastState ¶
type LinkingDevice ¶
type LinkingDevice struct { Hostname string `json:"hostname"` OS string `json:"os"` OSVersion string `json:"osVersion"` Kernel string `json:"kernel"` UUID string `json:"uuid"` Ticket string `json:"ticket"` Version string `json:"version"` }
func NewLinkingDevice ¶
func NewLinkingDevice() (*LinkingDevice, error)
NewLinkingDevice creates a new instance of LinkingDevice with system information. It retrieves the system UUID and device ticket, and populates the LinkingDevice struct with the hostname, OS name, OS version, kernel version, UUID, and ticket. Returns a pointer to the LinkingDevice and an error if any occurs during the process.
type ParetoConfig ¶
type ParetoConfig struct { TeamID string AuthToken string Checks map[string]CheckStatus }
var Config ParetoConfig
type ReportingDevice ¶
type ReportingDevice struct { MachineUUID string `json:"machineUUID"` // e.g. 123e4567-e89b-12d3-a456-426614174000 MachineName string `json:"machineName"` // e.g. MacBook-Pro.local Auth string `json:"auth"` OSVersion string `json:"linuxOSVersion"` // e.g. Ubuntu 20.04 ModelName string `json:"modelName"` // e.g. MacBook Pro ModelSerial string `json:"modelSerial"` // e.g. C02C1234 }
func CurrentReportingDevice ¶
func CurrentReportingDevice() ReportingDevice