cli

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2025 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "mir"
)

Variables

This section is empty.

Functions

func FormatHyperlink(text, url string) string

OSC 8 hyperlink escape sequence Supported by most new terminal

func ReadFromPipedStdIn

func ReadFromPipedStdIn() (string, bool)

func RecreateFS

func RecreateFS(embedFS fs.FS, targetDir string, deleteExisting bool) error

func RecreateFSWithReplacements added in v0.3.7

func RecreateFSWithReplacements(embedFS fs.FS, targetDir string, deleteExisting bool, replacements map[string]string) error

Types

type AddClientCmd added in v0.5.0

type AddClientCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	Name     string `arg:"" help:"Name of client"`
	ReadOnly bool   `help:"Set scope to Read operations only."`
	Swarm    bool   `help:"Set scope for Read and Write operations and Swarm capabilities."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*AddClientCmd) Run added in v0.5.0

func (d *AddClientCmd) Run(ctx ui.Context) error

func (*AddClientCmd) Validate added in v0.5.0

func (d *AddClientCmd) Validate() error

type AddCmd added in v0.5.0

type AddCmd struct {
	Client AddClientCmd `cmd:"" help:"Create a new user with scope for CLI and other operating interface"`
	Module AddModuleCmd `cmd:"" help:"Create a new user with scope for server module"`
	Device AddDeviceCmd `cmd:"" help:"Create a new user with scope for device"`
}

type AddDeviceCmd added in v0.5.0

type AddDeviceCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	Name     string `arg:"" help:"Name of device, should be deviceId"`
	Wildcard bool   `help:"Don't bind scope to deviceId, more flexible, but less secure"`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*AddDeviceCmd) Run added in v0.5.0

func (d *AddDeviceCmd) Run(ctx ui.Context) error

func (*AddDeviceCmd) Validate added in v0.5.0

func (d *AddDeviceCmd) Validate() error

type AddModuleCmd added in v0.5.0

type AddModuleCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	Name     string `arg:"" help:"Name of module"`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*AddModuleCmd) Run added in v0.5.0

func (d *AddModuleCmd) Run(ctx ui.Context) error

func (*AddModuleCmd) Validate added in v0.5.0

func (d *AddModuleCmd) Validate() error

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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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"`
	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) Run added in v0.2.0

func (d *ConfigSendCmd) Run(log zerolog.Logger, m *mir.Mir, cfg ui.Config) error

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) Run added in v0.3.7

func (d *ContextCmd) Run(cfg ui.Config) error

func (*ContextCmd) Validate added in v0.3.7

func (d *ContextCmd) Validate() error

type CoreCfg added in v0.6.1

type CoreCfg struct {
	DeviceOnlineFlush  time.Duration `help:"Device online flush interval" default:"7s" yaml:"deviceOnlineFlush"`
	DeviceOfflineFlush time.Duration `help:"Device offline flush interval" default:"12s" yaml:"deviceOfflineFlush"`
	DeviceOfflineAfter time.Duration `help:"Device offline after" default:"30s" yaml:"deviceOfflineAfter"`
}

type CredsCmd added in v0.5.0

type CredsCmd struct {
	Operator   string `short:"o"  help:"Name of operator. Default to context name."`
	Url        string `short:"u" help:"Url of Mir server. Default to context url."`
	Account    string `short:"a" help:"Name of main account." default:"mir"`
	User       string `arg:"" help:"Name of user"`
	Path       string `short:"p" type:"path"`
	Kubernetes bool   `help:"Create the credentials as a Kubernetes secret (use Kubectl)" default:"false"`
	NoExec     bool   `help:"Print commands instead of executing." default:"false"`
}

func (*CredsCmd) Run added in v0.5.0

func (d *CredsCmd) Run(ctx ui.Context) error

func (*CredsCmd) Validate added in v0.5.0

func (d *CredsCmd) Validate() error

type DeleteCmd added in v0.5.0

type DeleteCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	Name     string `arg:"" help:"Name of user"`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*DeleteCmd) Run added in v0.5.0

func (d *DeleteCmd) Run(ctx ui.Context) error

func (*DeleteCmd) Validate added in v0.5.0

func (d *DeleteCmd) Validate() error

type DeviceApplyCmd

type DeviceApplyCmd struct {
	Path string `` /* 163-byte string literal not displayed */
}

func (*DeviceApplyCmd) Run

func (d *DeviceApplyCmd) Run(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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"`

	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

func (*DeviceCmd) Run

func (d *DeviceCmd) Run(log zerolog.Logger, m *mir.Mir) error

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(log zerolog.Logger, m *mir.Mir) 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(log zerolog.Logger, m *mir.Mir) 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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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."`
	ExcludeEvents bool   `short:"e" help:"Exclude events in each device. Speed up the query." default:"false"`
	Target        `embed:"" prefix:"target."`
}

func (*DeviceListCmd) Run

func (d *DeviceListCmd) Run(log zerolog.Logger, m *mir.Mir) 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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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>"`
	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) Run

func (d *DeviceUpdateCmd) Run(log zerolog.Logger, m *mir.Mir) 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."`
}

func (*DownCmd) Run

func (d *DownCmd) Run(infraCmd *InfraCmd) error

func (*DownCmd) Validate

func (d *DownCmd) Validate() error

type EditCmd added in v0.5.0

type EditCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Url      string `short:"u" help:"Url of Mir server. Default to context url."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*EditCmd) Run added in v0.5.0

func (d *EditCmd) Run(ctx ui.Context) error

func (*EditCmd) Validate added in v0.5.0

func (d *EditCmd) Validate() error

type EnvCmd added in v0.5.0

type EnvCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*EnvCmd) Run added in v0.5.0

func (d *EnvCmd) Run(ctx ui.Context) error

func (*EnvCmd) Validate added in v0.5.0

func (d *EnvCmd) Validate() error

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

func (EventCmd) Run added in v0.3.0

func (d EventCmd) Run(log zerolog.Logger, cfg ui.Config, m *mir.Mir) error

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) Run added in v0.3.0

func (d *EventDeleteCmd) Run(log zerolog.Logger, m *mir.Mir, cfg ui.Config) error

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) Run added in v0.3.0

func (d *EventListCmd) Run(log zerolog.Logger, m *mir.Mir, cfg ui.Config) error

func (*EventListCmd) Validate added in v0.3.0

func (d *EventListCmd) Validate() error

type EventStoreCfg added in v0.6.1

type EventStoreCfg struct {
	FlushInterval time.Duration `help:"Event store flush interval" default:"5s" yaml:"flushInterval"`
}

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 InitCmd added in v0.5.0

type InitCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Url      string `short:"u" help:"Url of Mir server. Default to context url."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*InitCmd) Run added in v0.5.0

func (d *InitCmd) Run(ctx ui.Context) error

func (*InitCmd) Validate added in v0.5.0

func (d *InitCmd) Validate() error

type InstallCmd

type InstallCmd struct {
}

func (*InstallCmd) Run

func (d *InstallCmd) Run() error

func (*InstallCmd) Validate

func (d *InstallCmd) Validate() error

type ListAccountsCmd added in v0.5.0

type ListAccountsCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*ListAccountsCmd) Run added in v0.5.0

func (d *ListAccountsCmd) Run(ctx ui.Context) error

func (*ListAccountsCmd) Validate added in v0.5.0

func (d *ListAccountsCmd) Validate() error

type ListCmd added in v0.5.0

type ListCmd struct {
	Operators ListOperatorsCmd `cmd:"" help:"List operators"`
	Accounts  ListAccountsCmd  `cmd:"" help:"List accounts"`
	Users     ListUsersCmd     `cmd:"" help:"List users"`
}

type ListOperatorsCmd added in v0.5.0

type ListOperatorsCmd struct {
	NoExec bool `help:"Print commands instead of executing." default:"false"`
}

func (*ListOperatorsCmd) Run added in v0.5.0

func (d *ListOperatorsCmd) Run(ctx ui.Context) error

func (*ListOperatorsCmd) Validate added in v0.5.0

func (d *ListOperatorsCmd) Validate() error

type ListUsersCmd added in v0.5.0

type ListUsersCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	Account  string `short:"a" help:"Name of main account." default:"mir"`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*ListUsersCmd) Run added in v0.5.0

func (d *ListUsersCmd) Run(ctx ui.Context) error

func (*ListUsersCmd) Validate added in v0.5.0

func (d *ListUsersCmd) Validate() error

type LogCmd added in v0.3.7

type LogCmd struct {
	Lines  int  `short:"n" help:"Number of lines to display (0 for all)" default:"0"`
	Follow bool `short:"f" help:"Follow log output" default:"false"`
}

func (*LogCmd) Run added in v0.3.7

func (d *LogCmd) Run() error

func (*LogCmd) Validate added in v0.3.7

func (d *LogCmd) Validate() error

type MirCfg

type MirCfg struct {
	Url         string `help:"Mir server URL" default:"nats://127.0.0.1:4222" yaml:"url"`
	Credentials string `help:"Mir JWT/NKEY credential file path" default:"" yaml:"credentials"`
	RootCA      string `help:"Mir RootCA for TLS connection" default:"" yaml:"rootCA"`
	TLSCert     string `help:"Mir Certificate for TLS connection" default:"" yaml:"tlsCert"`
	TLSKey      string `help:"Mir Private Key for TLS connection" default:"" yaml:"tlsKey"`
	LogLevel    string `help:"Mir loglevel for each service" default:"info" yaml:"logLevel"`
	HttpPort    int    `help:"Mir http port for api" default:"3015" yaml:"httpPort"`
}

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

type MirHttpError struct {
	Code    uint32
	Message string
	Details []string
}

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 ModuleCfg added in v0.6.1

type ModuleCfg struct {
	Core       CoreCfg       `embed:"" prefix:"core." yaml:"core"`
	EventStore EventStoreCfg `embed:"" prefix:"eventStore." yaml:"eventStore"`
}

type PrintCmd

type PrintCmd struct {
	Path string `short:"p" help:"Write path for compose files" default:"."`
}

func (*PrintCmd) Run

func (d *PrintCmd) Run() error

func (*PrintCmd) Validate

func (d *PrintCmd) Validate() error

type PsCmd

type PsCmd struct {
	Args []string `arg:"" optional:"" help:"Docker compose ps arguments. Will be passed on."`
}

func (*PsCmd) Run

func (d *PsCmd) Run(infraCmd *InfraCmd) error

func (*PsCmd) Validate

func (d *PsCmd) Validate() error

type PullCmd added in v0.5.0

type PullCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*PullCmd) Run added in v0.5.0

func (d *PullCmd) Run(ctx ui.Context) error

func (*PullCmd) Validate added in v0.5.0

func (d *PullCmd) Validate() error

type PushCmd added in v0.5.0

type PushCmd struct {
	Operator string `short:"o"  help:"Name of operator. Default to context name."`
	NoExec   bool   `help:"Print commands instead of executing." default:"false"`
}

func (*PushCmd) Run added in v0.5.0

func (d *PushCmd) Run(ctx ui.Context) error

func (*PushCmd) Validate added in v0.5.0

func (d *PushCmd) Validate() error

type ResolverCmd added in v0.5.0

type ResolverCmd struct {
	Operator   string `short:"o"  help:"Name of operator. Default to context name."`
	Path       string `short:"p" type:"path"`
	Kubernetes bool   `help:"Create the credentials as a Kubernetes secret (use Kubectl)" default:"false"`
	NoExec     bool   `help:"Print commands instead of executing." default:"false"`
}

func (*ResolverCmd) Run added in v0.5.0

func (d *ResolverCmd) Run(ctx ui.Context) error

func (*ResolverCmd) Validate added in v0.5.0

func (d *ResolverCmd) Validate() error

type RmCmd

type RmCmd struct {
	Args []string `arg:"" optional:"" help:"Docker compose rm arguments. Will be passed on."`
}

func (*RmCmd) Run

func (d *RmCmd) Run(infraCmd *InfraCmd) error

func (*RmCmd) Validate

func (d *RmCmd) Validate() error

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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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(log zerolog.Logger, m *mir.Mir, cfg ui.Config) error

func (*SchemaUploadCmd) Validate

func (d *SchemaUploadCmd) Validate() error

type SecurityCmd added in v0.5.0

type SecurityCmd struct {
	Init             InitCmd     `cmd:"" help:"Create operator to manage a Mir server"`
	Edit             EditCmd     `cmd:"" help:"Update operator server url"`
	Env              EnvCmd      `cmd:"" help:"Display operator details"`
	Pull             PullCmd     `cmd:"" help:"Pull operator credentials, accounts and users"`
	Push             PushCmd     `cmd:"" help:"Push operator credentials, accounts and users"`
	List             ListCmd     `cmd:"" help:"List assests"`
	Add              AddCmd      `cmd:"" help:"Add new users to the system"`
	Delete           DeleteCmd   `cmd:"" help:"Delete users in the system"`
	GenerateResolver ResolverCmd `cmd:"" help:"Generate security config for nat server startup"`
	GenerateCreds    CredsCmd    `cmd:"" help:"Generate security config for nats users"`
}

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:""`
}

func (*ServeCmd) Run

func (d *ServeCmd) Run(cfg ui.Config) error

func (*ServeCmd) Validate

func (d *ServeCmd) Validate() error

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"`
	Module  ModuleCfg  `embed:"" prefix:"event." yaml:"module"`
}

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) Run added in v0.3.7

func (d *SettingsEditCmd) Run(cfg ui.Config) error

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) Run added in v0.3.7

func (d *SettingsViewCmd) Run(cfg ui.Config) error

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"`
	SwarmFile     string   `` /* 151-byte string literal not displayed */
	SwarmTemplate bool     `short:"j" help:"Swarm file definition with default contents"`
}

func (*SwarmCmd) Run

func (d *SwarmCmd) Run(log zerolog.Logger, m *mSdk.Mir, cfg ui.Config) error

func (*SwarmCmd) Validate

func (c *SwarmCmd) Validate() error

type Target

type Target struct {
	Ids        []string          `help:"List of device to fetch by ids"`
	Names      []string          `help:"List of device to fetch by names"`
	Namespaces []string          `help:"List of device to fetch by namespaces"`
	Labels     map[string]string `help:"Set of labels to filter devices"`
}

type TargetEvent added in v0.3.0

type TargetEvent struct {
	Names      []string          `help:"List of events to fetch by names"`
	Namespaces []string          `help:"List of events to fetch by namespaces"`
	Labels     map[string]string `help:"Set of labels to filter events"`
}

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) Run

func (d *TelemetryListCmd) Run(log zerolog.Logger, m *mir.Mir, cfg ui.Config) 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"`
	Log      LogCmd      `cmd:"" help:"View and follow Mir CLI logs"`
	Config   SettingsCmd `cmd:"" aliases:"cfg" help:"Manage Mir CLI configuration"`
	Security SecurityCmd `` /* 145-byte string literal not displayed */
}

type UpCmd

type UpCmd struct {
	Args []string `arg:"" optional:"" help:"Docker compose up arguments. Will be passed on."`
}

func (*UpCmd) Run

func (d *UpCmd) Run(infraCmd *InfraCmd) error

func (*UpCmd) Validate

func (d *UpCmd) Validate() error

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL