Documentation
¶
Index ¶
- Constants
- func FormatHyperlink(text, url string) string
- func ReadFromPipedStdIn() (string, bool)
- func RecreateFS(embedFS fs.FS, targetDir string) error
- type CLI
- type CommandCmd
- type CommandListCmd
- type CommandSendCmd
- type ConfigCmd
- type ConfigListCmd
- type ConfigSendCmd
- type DeviceApplyCmd
- type DeviceCmd
- type DeviceCreateCmd
- type DeviceDeleteCmd
- type DeviceEditCmd
- type DeviceListCmd
- type DeviceMergeCmd
- type DeviceTemplateCmd
- type DeviceUpdateCmd
- type DownCmd
- type GenerateCmd
- type InfluxCfg
- type InfraCmd
- type InstallCmd
- 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 SurrealCfg
- type SwarmCmd
- type Target
- 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) Run ¶
func (d *CommandListCmd) Run(c CLI) error
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) Run ¶
func (d *CommandSendCmd) Run(c CLI) error
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) Run ¶ added in v0.2.0
func (d *ConfigListCmd) Run(c CLI) error
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"`
Command 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) Run ¶ added in v0.2.0
func (d *ConfigSendCmd) Run(c CLI) error
func (*ConfigSendCmd) Validate ¶ added in v0.2.0
func (d *ConfigSendCmd) Validate() error
type DeviceApplyCmd ¶
type DeviceApplyCmd struct {
Path string `` /* 163-byte string literal not displayed */
}
func (*DeviceApplyCmd) Run ¶
func (d *DeviceApplyCmd) Run(c CLI) error
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"`
}
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) Run ¶
func (d *DeviceCreateCmd) Run(c CLI) error
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) Run ¶
func (d *DeviceDeleteCmd) Run(c CLI) error
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) Run ¶
func (d *DeviceEditCmd) Run(c CLI) error
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) Run ¶
func (d *DeviceListCmd) Run(c CLI) error
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) Run ¶ added in v0.2.0
func (d *DeviceMergeCmd) Run(c CLI) error
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>"`
}
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"`
Desc *string `help:"Set device description"`
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) Run ¶
func (d *DeviceUpdateCmd) Run(c CLI) error
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 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"`
}
type InfraCmd ¶
type InfraCmd struct {
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 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 *core_apiv1.Targets
}
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) Run ¶
func (d *SchemaExploreCmd) Run(c CLI) error
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) Run ¶
func (d *SchemaUploadCmd) Run(c CLI) error
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 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 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"`
RefreshSchema bool `short:"r" help:"Refresh schema from device even if in store" default:"false"`
GrafanaUrl string `short:"g" help:"grafana instance url to point the generated link to" default:"localhost:3000"`
}
func (*TelemetryListCmd) Run ¶
func (d *TelemetryListCmd) Run(c CLI) error
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"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.