Documentation
¶
Index ¶
- Constants
- func FormatHyperlink(text, url string) string
- func ReadFromPipedStdIn() (string, bool)
- func RecreateFS(embedFS fs.FS, targetDir string, deleteExisting bool) error
- func RecreateFSWithReplacements(embedFS fs.FS, targetDir string, deleteExisting bool, ...) error
- type CommandCmd
- type CommandListCmd
- type CommandSendCmd
- type ConfigCmd
- type ConfigListCmd
- type ConfigSendCmd
- type ContextCmd
- type DeviceApplyCmd
- type DeviceCmd
- type DeviceCreateCmd
- type DeviceDeleteCmd
- type DeviceEditCmd
- type DeviceListCmd
- type DeviceMergeCmd
- type DeviceTemplateCmd
- type DeviceUpdateCmd
- type DownCmd
- type EventCmd
- type EventDeleteCmd
- type EventListCmd
- type GenerateCmd
- type InfluxCfg
- type InfraCmd
- type InstallCmd
- type LogCmd
- type MirCfg
- type MirConnectionError
- type MirDeserializationError
- type MirDeviceNotFoundError
- type MirEditError
- type MirHttpError
- type MirInvalidInputError
- type MirProcessError
- type MirRequestError
- type MirResponseError
- type MirSchemaCmd
- type MirSerializationError
- type PrintCmd
- type PsCmd
- type RmCmd
- type SchemaCmd
- type SchemaExploreCmd
- type SchemaUploadCmd
- type ServeCmd
- type ServeConfig
- type SettingsCmd
- type SettingsEditCmd
- type SettingsViewCmd
- type SurrealCfg
- type SwarmCmd
- type Target
- type TargetEvent
- type TelemetryCmd
- type TelemetryListCmd
- type ToolsCmd
- type UpCmd
Constants ¶
View Source
const (
AppName = "mir"
)
Variables ¶
This section is empty.
Functions ¶
func FormatHyperlink ¶
OSC 8 hyperlink escape sequence Supported by most new terminal
func ReadFromPipedStdIn ¶
Types ¶
type CommandCmd ¶
type CommandCmd struct {
List CommandListCmd `cmd:"" aliases:"ls" help:"List all commands belonging to a set of devices"`
Send CommandSendCmd `cmd:"" help:"Send a commands to all targeted devices"`
}
type CommandListCmd ¶
type CommandListCmd struct {
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
FilterLabels map[string]string `help:"Set of labels to filter commands"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
ShowJsonTemplate bool `short:"j" help:"show json template for command"`
}
func (*CommandListCmd) Validate ¶
func (d *CommandListCmd) Validate() error
type CommandSendCmd ¶
type CommandSendCmd struct {
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
Command string `short:"n" help:"command name to send"`
ShowJsonTemplate bool `short:"j" help:"show json template for command"`
Payload string `short:"p" help:"payload to send in json. use single quote for easier writing. e.g. '{\"key\":\"value\"}'"`
Edit bool `short:"e" help:"Interactive edit of command payload" default:"false"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
DryRun bool `help:"dry run command" default:"false"`
NoValidation bool `help:"do not validate command with device's schema. Only for protobuf encoding" default:"false"`
ForcePush bool `short:"f" help:"force send commands even if some devices are in error" default:"false"`
Timeout int `short:"t" help:"timeout in second for command to reach device" default:"10"`
}
func (*CommandSendCmd) Validate ¶
func (d *CommandSendCmd) Validate() error
type ConfigCmd ¶ added in v0.2.0
type ConfigCmd struct {
List ConfigListCmd `cmd:"" aliases:"ls" help:"List all config belonging to a set of devices"`
Send ConfigSendCmd `cmd:"" help:"Send a config to all targeted devices"`
}
type ConfigListCmd ¶ added in v0.2.0
type ConfigListCmd struct {
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
FilterLabels map[string]string `help:"Set of labels to filter config"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
ShowJsonTemplate bool `short:"j" help:"show json template for config"`
ShowCurrentValues bool `short:"c" help:"show current values for config"`
}
func (*ConfigListCmd) Validate ¶ added in v0.2.0
func (d *ConfigListCmd) Validate() error
type ConfigSendCmd ¶ added in v0.2.0
type ConfigSendCmd struct {
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
Config string `short:"n" help:"config name to send"`
ShowJsonTemplate bool `short:"j" help:"show json template for config"`
ShowCurrentValues bool `short:"c" help:"show current values for config"`
Payload string `short:"p" help:"payload to send in json. use single quote for easier writing. e.g. '{\"key\":\"value\"}'"`
Edit bool `short:"e" help:"Interactive edit of config payload" default:"false"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
DryRun bool `help:"dry run command" default:"false"`
ForcePush bool `short:"f" help:"force send commands even if some devices are in error" default:"false"`
}
func (*ConfigSendCmd) Validate ¶ added in v0.2.0
func (d *ConfigSendCmd) Validate() error
type ContextCmd ¶ added in v0.3.7
type ContextCmd struct {
Context string `arg:"" optional:"" help:"Set context"`
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"pretty"`
}
func (*ContextCmd) Validate ¶ added in v0.3.7
func (d *ContextCmd) Validate() error
type DeviceApplyCmd ¶
type DeviceApplyCmd struct {
Path string `` /* 163-byte string literal not displayed */
}
func (*DeviceApplyCmd) Validate ¶
func (d *DeviceApplyCmd) Validate() error
type DeviceCmd ¶
type DeviceCmd struct {
List DeviceListCmd `cmd:"" aliases:"ls" help:"List devices"`
Create DeviceCreateCmd `cmd:"" help:"Create a new device"`
Update DeviceUpdateCmd `cmd:"" help:"Update a device"`
Edit DeviceEditCmd `cmd:"" help:"Interactive editing of devices"`
Apply DeviceApplyCmd `cmd:"" help:"Update a device using a declarative format"`
Merge DeviceMergeCmd `cmd:"" help:"Update a device using a merge operation"`
Delete DeviceDeleteCmd `cmd:"" help:"Delete a device"`
Config ConfigCmd `cmd:"" aliases:"cfg" help:"Explore Mir devices configuration"`
Telemetry TelemetryCmd `cmd:"" aliases:"tlm" help:"Explore Mir devices telemetry"`
Command CommandCmd `cmd:"" aliases:"cmd" help:"Send and explore commands to devices"`
Schema SchemaCmd `cmd:"" aliases:"sch" help:"Upload and explore device proto schema"`
}
TODO get command which is ls but with -o yaml
type DeviceCreateCmd ¶
type DeviceCreateCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"shortcut to set name and namespace"`
ShowJsonTemplate bool `short:"j" help:"Show json template for creating a device"`
Path string `` /* 149-byte string literal not displayed */
RandomId bool `short:"r" help:"Set a random device id"`
Id string `help:"Set device id"`
Name string `help:"Set device name"`
Namespace string `help:"Set device namespace"`
Desc string `help:"Set device description"`
Disabled bool `help:"If disabled, communication is cut"`
Labels map[string]string `help:"Set labels to uniquely tag the device"`
Anno map[string]string `help:"Set annotations to add extra information to the device"`
}
func (*DeviceCreateCmd) Validate ¶
func (d *DeviceCreateCmd) Validate() error
type DeviceDeleteCmd ¶
type DeviceDeleteCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"delete single device."`
Target `embed:"" prefix:"target."`
}
func (*DeviceDeleteCmd) Validate ¶
func (d *DeviceDeleteCmd) Validate() error
type DeviceEditCmd ¶
type DeviceEditCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
Target `embed:"" prefix:"target."`
}
func (*DeviceEditCmd) Validate ¶
func (d *DeviceEditCmd) Validate() error
type DeviceListCmd ¶
type DeviceListCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"pretty"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"list single device."`
Target `embed:"" prefix:"target."`
}
func (*DeviceListCmd) Validate ¶
func (d *DeviceListCmd) Validate() error
type DeviceMergeCmd ¶ added in v0.2.0
type DeviceMergeCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
Target `embed:"" prefix:"target."`
Patch string `` /* 154-byte string literal not displayed */
}
func (*DeviceMergeCmd) Validate ¶ added in v0.2.0
func (d *DeviceMergeCmd) Validate() error
type DeviceTemplateCmd ¶
type DeviceTemplateCmd struct {
ContextPath string `short:"p" help:"Context path to generate schema structure" default:"."`
ModulePath string `arg:"" help:"Go project module path. eg: github.com/<user|org>/<project>"`
Proto string `enum:"protoc,buf" help:"Protofiles management [protoc|buf]. Buf (recommended)." default:"buf"`
IncludeContainer bool `short:"c" help:"Include docker containers to package Mir Device" default:"false"`
}
func (*DeviceTemplateCmd) Run ¶
func (d *DeviceTemplateCmd) Run() error
func (*DeviceTemplateCmd) Validate ¶
func (d *DeviceTemplateCmd) Validate() error
type DeviceUpdateCmd ¶
type DeviceUpdateCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"shortcut to set name and namespace"`
Name *string `help:"Set device name"`
Namespace *string `help:"Set device namespace"`
Id *string `help:"Set device id"`
Disabled *bool `help:"If not enabled, communication is cut"`
Labels map[string]string `help:"Set labels to uniquely tag the device (set to null, none or nil to remove)"`
Anno map[string]string `help:"Set annotations to add extra information to the devie (set to null to remove)"`
}
func (*DeviceUpdateCmd) Validate ¶
func (d *DeviceUpdateCmd) Validate() error
type DownCmd ¶
type DownCmd struct {
Args []string `arg:"" optional:"" help:"Docker compose down arguments. Will be passed on."`
}
type EventCmd ¶ added in v0.3.0
type EventCmd struct {
List EventListCmd `cmd:"" aliases:"ls" help:"List events"`
Delete EventDeleteCmd `cmd:"" help:"Delete events"`
}
TODO get command which is ls but with -o yaml
type EventDeleteCmd ¶ added in v0.3.0
type EventDeleteCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"yaml"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"delete single event."`
TargetEvent `embed:"" prefix:"target."`
From time.Time `help:"Set starting date to filter event. (eg: 2025-05-01T00:00:00.00Z)"`
To time.Time `help:"Set ending date to filter event. Default to now. (eg: 2025-05-02T00:00:00.00Z)"`
}
func (*EventDeleteCmd) Validate ¶ added in v0.3.0
func (d *EventDeleteCmd) Validate() error
type EventListCmd ¶ added in v0.3.0
type EventListCmd struct {
Output string `short:"o" help:"output format for response [pretty|json|yaml]" default:"pretty"`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"list single event."`
TargetEvent `embed:"" prefix:"target."`
Limit int `help:"Limit number of events in the ouput"`
From time.Time `help:"Set starting date to filter event. (eg: 2025-05-01T00:00:00.00Z)"`
To time.Time `help:"Set ending date to filter event. Default to now. (eg: 2025-05-02T00:00:00.00Z)"`
}
func (*EventListCmd) Validate ¶ added in v0.3.0
func (d *EventListCmd) Validate() error
type GenerateCmd ¶
type GenerateCmd struct {
MirSchema MirSchemaCmd `cmd:"" help:"Generate mir schema"`
DeviceTemplate DeviceTemplateCmd `cmd:"" help:"Generate a device template project"`
}
type InfluxCfg ¶
type InfluxCfg struct {
Url string `help:"Influx db connection url" default:"http://localhost:8086/" yaml:"url"`
Token string `help:"Influx db token" default:"mir-operator-token" cfg:"secret" yaml:"token"`
Org string `help:"Influx db organisation" default:"Mir" yaml:"org"`
Bucket string `help:"Influx db telemetry bucket" default:"mir" yaml:"bucket"`
BatchSize uint `help:"Maximum telemetry batch size. Default 1000 datapoints." default:"1000" yaml:"batchSize"`
FlushInterval uint `help:"Maximum telemetry send interval. Default 1 second." default:"1000" yaml:"flushInterval"`
RetryBufferLimit uint `help:"Size of buffer in case of database access failure. Default 1GB." default:"1073741824" yaml:"retryBufferLimit"`
Gzip bool `help:"Use gZip compression" default:"false" yaml:"gzip"`
}
type InfraCmd ¶
type InfraCmd struct {
IncludeMir bool `short:"m" help:"Include Mir server"`
Up UpCmd `cmd:"" passthrough:"" help:"Run infra docker compose up"`
Down DownCmd `cmd:"" passthrough:"" help:"Run infra docker compose down"`
Ps PsCmd `cmd:"" passthrough:"" help:"Run infra docker compose ps"`
Rm RmCmd `cmd:"" passthrough:"" help:"Run infra docker compose rm"`
Print PrintCmd `cmd:"" help:"Write to disk Mir set of docker compose"`
}
type InstallCmd ¶
type InstallCmd struct {
}
func (*InstallCmd) Run ¶
func (d *InstallCmd) Run() error
func (*InstallCmd) Validate ¶
func (d *InstallCmd) Validate() error
type LogCmd ¶ added in v0.3.7
type MirConnectionError ¶
type MirConnectionError struct {
Target string
// contains filtered or unexported fields
}
func (MirConnectionError) Error ¶
func (e MirConnectionError) Error() string
type MirDeserializationError ¶
type MirDeserializationError struct {
Format string
// contains filtered or unexported fields
}
func (MirDeserializationError) Error ¶
func (e MirDeserializationError) Error() string
type MirDeviceNotFoundError ¶
type MirDeviceNotFoundError struct {
Targets *mir_apiv1.DeviceTarget
}
func (MirDeviceNotFoundError) Error ¶
func (e MirDeviceNotFoundError) Error() string
type MirEditError ¶
type MirEditError struct {
Msg string
// contains filtered or unexported fields
}
func (MirEditError) Error ¶
func (e MirEditError) Error() string
type MirHttpError ¶
func (MirHttpError) Error ¶
func (e MirHttpError) Error() string
type MirInvalidInputError ¶
type MirInvalidInputError struct {
Details []string
}
func (MirInvalidInputError) Error ¶
func (e MirInvalidInputError) Error() string
type MirProcessError ¶
type MirProcessError struct {
Msg string
// contains filtered or unexported fields
}
func (MirProcessError) Error ¶
func (e MirProcessError) Error() string
type MirRequestError ¶
type MirRequestError struct {
Route string
// contains filtered or unexported fields
}
func (MirRequestError) Error ¶
func (e MirRequestError) Error() string
type MirResponseError ¶
type MirResponseError struct {
Route string
// contains filtered or unexported fields
}
func (MirResponseError) Error ¶
func (e MirResponseError) Error() string
type MirSchemaCmd ¶
type MirSchemaCmd struct {
ContextPath string `short:"p" help:"Context path to generate schema structure" default:"."`
}
func (*MirSchemaCmd) Run ¶
func (d *MirSchemaCmd) Run() error
func (*MirSchemaCmd) Validate ¶
func (d *MirSchemaCmd) Validate() error
type MirSerializationError ¶
type MirSerializationError struct {
Format string
// contains filtered or unexported fields
}
func (MirSerializationError) Error ¶
func (e MirSerializationError) Error() string
type PrintCmd ¶
type PrintCmd struct {
Path string `short:"p" help:"Write path for compose files" default:"."`
}
type PsCmd ¶
type PsCmd struct {
Args []string `arg:"" optional:"" help:"Docker compose ps arguments. Will be passed on."`
}
type RmCmd ¶
type RmCmd struct {
Args []string `arg:"" optional:"" help:"Docker compose rm arguments. Will be passed on."`
}
type SchemaCmd ¶
type SchemaCmd struct {
Upload SchemaUploadCmd `` /* 147-byte string literal not displayed */
Explore SchemaExploreCmd `cmd:"" help:"Explore a device schema"`
}
TODO maybe add a schema refresh command
type SchemaExploreCmd ¶
type SchemaExploreCmd struct {
Output string `short:"o" help:"output format for response [json|yaml]" default:"yaml"`
IncludeMirImports bool `short:"i" help:"includes Mir proto dependencies" default:"false"`
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
}
func (*SchemaExploreCmd) Validate ¶
func (d *SchemaExploreCmd) Validate() error
type SchemaUploadCmd ¶
type SchemaUploadCmd struct {
Output string `short:"o" help:"output format for response" default:"json"`
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"edit single device"`
// TODO could be an array, I think there is a path type
Path string `type:"path" help:"Path to protobuf schema"`
}
func (*SchemaUploadCmd) Validate ¶
func (d *SchemaUploadCmd) Validate() error
type ServeCmd ¶
type ServeCmd struct {
Core bool `help:"Core module is for device mangement" default:"true"`
Configuration bool `help:"Configuration module is for device properties" default:"true"`
Telemetry bool `help:"Telemetry module is for data ingestion and visualization" default:"true"`
Command bool `help:"Command module if for command and control" default:"true"`
DisplayDefaultCfg bool `` /* 135-byte string literal not displayed */
DisplayLoadedCfg bool `name:"display-cfg" help:"Display loaded configuration. Usefull for debug scenario" default:"false"`
ConfigFile string `name:"server-config" help:"Set path for config path." default:"~/.config/mir/mir.yaml"`
ServeConfig `embed:"" prefix:""`
}
type ServeConfig ¶
type ServeConfig struct {
Mir MirCfg `embed:"" prefix:"mir." yaml:"mir"`
Surreal SurrealCfg `embed:"" prefix:"surreal." yaml:"surreal"`
Influx InfluxCfg `embed:"" prefix:"influx." yaml:"influx"`
}
type SettingsCmd ¶ added in v0.3.7
type SettingsCmd struct {
View SettingsViewCmd `cmd:"" help:"View configuration file"`
Edit SettingsEditCmd `cmd:"" help:"Edit configuration file"`
}
type SettingsEditCmd ¶ added in v0.3.7
type SettingsEditCmd struct {
}
func (*SettingsEditCmd) Validate ¶ added in v0.3.7
func (d *SettingsEditCmd) Validate() error
SettingsEditCmd implementation
type SettingsViewCmd ¶ added in v0.3.7
type SettingsViewCmd struct {
}
func (*SettingsViewCmd) Validate ¶ added in v0.3.7
func (d *SettingsViewCmd) Validate() error
SettingsViewCmd implementation
type SurrealCfg ¶
type SurrealCfg struct {
Url string `help:"Surreal db connection url" default:"ws://127.0.0.1:8000/rpc" yaml:"url"`
Namespace string `help:"Surreal db namespace" default:"global" yaml:"namespace"`
Database string `help:"Surreal db database" default:"mir" yaml:"database"`
User string `help:"Surreal db user" default:"root" yaml:"user"`
Password string `help:"Surreal db password" default:"root" cfg:"secret" yaml:"password"`
}
type SwarmCmd ¶
type SwarmCmd struct {
DeviceIds []string `name:"ids" help:"Unique id for each device"`
}
type TargetEvent ¶ added in v0.3.0
type TelemetryCmd ¶
type TelemetryCmd struct {
List TelemetryListCmd `cmd:"" aliases:"ls" help:"Explore device telemetry"`
}
TODO find how to move output here instead of per command TODO set yaml indent to two spaces TODO check if json to remove key value pair should be NONE or NULL. check json doc
func (*TelemetryCmd) Run ¶
func (d *TelemetryCmd) Run() error
type TelemetryListCmd ¶
type TelemetryListCmd struct {
Target `embed:"" prefix:"target."`
NameNs string `name:"name/namespace" arg:"" optional:"" help:"filter on name and/or namespace"`
Measuremeants []string `short:"m" help:"list of measurements to display. correspond to proto messages of type telemetry"`
Filters map[string]string `short:"f" help:"labels to filter measurements"`
ShowFields bool `short:"s" help:"show fields of the measurements" default:"false"`
PrintQuery bool `short:"q" help:"Print Influx query" default:"false"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
}
func (*TelemetryListCmd) Validate ¶
func (d *TelemetryListCmd) Validate() error
type ToolsCmd ¶
type ToolsCmd struct {
Generate GenerateCmd `cmd:"" help:"Generate project templates"`
Install InstallCmd `cmd:"" help:"Install development tools"`
Log LogCmd `cmd:"" help:"View and follow Mir CLI logs"`
Config SettingsCmd `cmd:"" help:"Manage Mir CLI configuration"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.