Documentation ¶
Overview ¶
Package config defines the structures to configure a robot and its connected parts.
Index ¶
- Constants
- Variables
- func AssociatedResourceConfigFromProto(proto *pb.ResourceLevelServiceConfig) (resource.AssociatedResourceConfig, error)
- func AssociatedResourceConfigToProto(conf resource.AssociatedResourceConfig) (*pb.ResourceLevelServiceConfig, error)
- func AuthConfigToProto(auth *AuthConfig) (*pb.AuthConfig, error)
- func CloudConfigToProto(cloud *Cloud) (*pb.CloudConfig, error)
- func ComponentConfigFromProto(protoConf *pb.ComponentConfig) (*resource.Config, error)
- func ComponentConfigToProto(conf *resource.Config) (*pb.ComponentConfig, error)
- func ContainsPlaceholder(s string) bool
- func CreateNewGRPCClient(ctx context.Context, cloudCfg *Cloud, logger golog.Logger) (rpc.ClientConn, error)
- func FrameConfigFromProto(proto *pb.Frame) (*referenceframe.LinkConfig, error)
- func FrameConfigToProto(frame referenceframe.LinkConfig) (*pb.Frame, error)
- func ModuleConfigToProto(module *Module) (*pb.ModuleConfig, error)
- func NetworkConfigToProto(network *NetworkConfig) (*pb.NetworkConfig, error)
- func PackageConfigToProto(cfg *PackageConfig) (*pb.PackageConfig, error)
- func PackageTypeToProto(t PackageType) (*packagespb.PackageType, error)
- func ProcessConfigFromProto(proto *pb.ProcessConfig) (*pexec.ProcessConfig, error)
- func ProcessConfigToProto(process *pexec.ProcessConfig) (*pb.ProcessConfig, error)
- func RemoteConfigToProto(remote *Remote) (*pb.RemoteConfig, error)
- func ServiceConfigFromProto(protoConf *pb.ServiceConfig) (*resource.Config, error)
- func ServiceConfigToProto(conf *resource.Config) (*pb.ServiceConfig, error)
- type AuthConfig
- type AuthHandlerConfig
- type Cloud
- type Config
- func FromProto(proto *pb.RobotConfig, logger golog.Logger) (*Config, error)
- func FromReader(ctx context.Context, originalPath string, r io.Reader, logger golog.Logger) (*Config, error)
- func ProcessConfig(in *Config, tlsCfg *TLSConfig) (*Config, error)
- func Read(ctx context.Context, filePath string, logger golog.Logger) (*Config, error)
- func ReadLocalConfig(ctx context.Context, filePath string, logger golog.Logger) (*Config, error)
- func (c *Config) CopyOnlyPublicFields() (*Config, error)
- func (c *Config) Ensure(fromCloud bool, logger golog.Logger) error
- func (c Config) FindComponent(name string) *resource.Config
- func (c Config) MarshalJSON() ([]byte, error)
- func (c *Config) ReplacePlaceholders() error
- func (c *Config) UnmarshalJSON(data []byte) error
- type Diff
- type ExternalAuthConfig
- type LocationSecret
- type ModifiedConfigDiff
- type Module
- type NetworkConfig
- type NetworkConfigData
- type PackageConfig
- func (p PackageConfig) Equals(other PackageConfig) bool
- func (p *PackageConfig) LocalDataDirectory(packagesDir string) string
- func (p *PackageConfig) LocalDataParentDirectory(packagesDir string) string
- func (p *PackageConfig) LocalDownloadPath(packagesDir string) string
- func (p *PackageConfig) SanitizedName() string
- func (p *PackageConfig) Validate(path string) error
- type PackageType
- type Remote
- type RemoteAuth
- type SessionsConfig
- type TLSConfig
- type Watcher
Constants ¶
const DefaultBindAddress = "localhost:8080"
DefaultBindAddress is the default address that will be listened on. This default may not be used in managed cases when no bind address is explicitly set. In those cases the server will bind to all interfaces.
const DefaultPackageVersionValue = "latest"
DefaultPackageVersionValue default value of the package version used when empty.
const DefaultSessionHeartbeatWindow = 2 * time.Second
DefaultSessionHeartbeatWindow is the default session heartbeat window to use when not specified. It can be set with network.sessions.heartbeat_window.
Variables ¶
var ( Version = "" GitRevision = "" )
RDK versioning variables which are replaced by LD flags.
var SupportedPackageTypes = []PackageType{PackageTypeMlModel, PackageTypeModule, PackageTypeSlamMap, PackageTypeBoardDefs}
SupportedPackageTypes is a list of all of the valid package types.
var ( // ViamDotDir is the directory for Viam's cached files. ViamDotDir string )
Functions ¶
func AssociatedResourceConfigFromProto ¶ added in v0.2.36
func AssociatedResourceConfigFromProto(proto *pb.ResourceLevelServiceConfig) (resource.AssociatedResourceConfig, error)
AssociatedResourceConfigFromProto creates AssociatedResourceConfig from the proto equivalent.
func AssociatedResourceConfigToProto ¶ added in v0.2.36
func AssociatedResourceConfigToProto(conf resource.AssociatedResourceConfig) (*pb.ResourceLevelServiceConfig, error)
AssociatedResourceConfigToProto converts AssociatedResourceConfig to the proto equivalent.
func AuthConfigToProto ¶ added in v0.0.6
func AuthConfigToProto(auth *AuthConfig) (*pb.AuthConfig, error)
AuthConfigToProto converts AuthConfig to the proto equivalent.
func CloudConfigToProto ¶ added in v0.0.6
func CloudConfigToProto(cloud *Cloud) (*pb.CloudConfig, error)
CloudConfigToProto converts Cloud to the proto equivalent.
func ComponentConfigFromProto ¶ added in v0.0.6
func ComponentConfigFromProto(protoConf *pb.ComponentConfig) (*resource.Config, error)
ComponentConfigFromProto creates Component from the proto equivalent.
func ComponentConfigToProto ¶ added in v0.0.6
func ComponentConfigToProto(conf *resource.Config) (*pb.ComponentConfig, error)
ComponentConfigToProto converts Component to the proto equivalent. Assumes config is valid except for partial names which will be completed.
func ContainsPlaceholder ¶ added in v0.7.2
ContainsPlaceholder returns true if the passed string contains a placeholder.
func CreateNewGRPCClient ¶ added in v0.0.7
func CreateNewGRPCClient(ctx context.Context, cloudCfg *Cloud, logger golog.Logger) (rpc.ClientConn, error)
CreateNewGRPCClient creates a new grpc cloud configured to communicate with the robot service based on the cloud config given.
func FrameConfigFromProto ¶ added in v0.0.6
func FrameConfigFromProto(proto *pb.Frame) (*referenceframe.LinkConfig, error)
FrameConfigFromProto creates Frame from the proto equivalent.
func FrameConfigToProto ¶ added in v0.0.6
func FrameConfigToProto(frame referenceframe.LinkConfig) (*pb.Frame, error)
FrameConfigToProto converts Frame to the proto equivalent.
func ModuleConfigToProto ¶ added in v0.2.8
func ModuleConfigToProto(module *Module) (*pb.ModuleConfig, error)
ModuleConfigToProto converts Module to the proto equivalent.
func NetworkConfigToProto ¶ added in v0.0.6
func NetworkConfigToProto(network *NetworkConfig) (*pb.NetworkConfig, error)
NetworkConfigToProto converts NetworkConfig from the proto equivalent.
func PackageConfigToProto ¶ added in v0.2.14
func PackageConfigToProto(cfg *PackageConfig) (*pb.PackageConfig, error)
PackageConfigToProto converts a rdk package config to the proto version.
func PackageTypeToProto ¶ added in v0.7.2
func PackageTypeToProto(t PackageType) (*packagespb.PackageType, error)
PackageTypeToProto converts a config PackageType to its proto equivalent This is required be because app/packages uses a PackageType enum but app/PackageConfig uses a string Type.
func ProcessConfigFromProto ¶ added in v0.0.6
func ProcessConfigFromProto(proto *pb.ProcessConfig) (*pexec.ProcessConfig, error)
ProcessConfigFromProto creates ProcessConfig from the proto equivalent.
func ProcessConfigToProto ¶ added in v0.0.6
func ProcessConfigToProto(process *pexec.ProcessConfig) (*pb.ProcessConfig, error)
ProcessConfigToProto converts ProcessConfig to proto equivalent.
func RemoteConfigToProto ¶ added in v0.0.6
func RemoteConfigToProto(remote *Remote) (*pb.RemoteConfig, error)
RemoteConfigToProto converts Remote to the proto equivalent.
func ServiceConfigFromProto ¶ added in v0.0.6
func ServiceConfigFromProto(protoConf *pb.ServiceConfig) (*resource.Config, error)
ServiceConfigFromProto creates Service from the proto equivalent shared with Components.
func ServiceConfigToProto ¶ added in v0.0.6
func ServiceConfigToProto(conf *resource.Config) (*pb.ServiceConfig, error)
ServiceConfigToProto converts Service to the proto equivalent. Assumes config is valid except for partial names which will be completed.
Types ¶
type AuthConfig ¶
type AuthConfig struct { Handlers []AuthHandlerConfig `json:"handlers,omitempty"` TLSAuthEntities []string `json:"tls_auth_entities,omitempty"` ExternalAuthConfig *ExternalAuthConfig `json:"external_auth_config,omitempty"` }
AuthConfig describes authentication and authorization settings for the web server.
func AuthConfigFromProto ¶ added in v0.0.6
func AuthConfigFromProto(proto *pb.AuthConfig) (*AuthConfig, error)
AuthConfigFromProto creates AuthConfig from the proto equivalent.
func (*AuthConfig) Validate ¶
func (config *AuthConfig) Validate(path string) error
Validate ensures all parts of the config are valid.
type AuthHandlerConfig ¶
type AuthHandlerConfig struct { Type rpc.CredentialsType `json:"type"` Config rutils.AttributeMap `json:"config"` }
AuthHandlerConfig describes the configuration for a particular auth handler.
func (*AuthHandlerConfig) Validate ¶
func (config *AuthHandlerConfig) Validate(path string) error
Validate ensures all parts of the config are valid.
type Cloud ¶
type Cloud struct { ID string Secret string LocationSecret string // Deprecated: Use LocationSecrets LocationSecrets []LocationSecret ManagedBy string FQDN string LocalFQDN string SignalingAddress string SignalingInsecure bool Path string LogPath string AppAddress string RefreshInterval time.Duration // cached by us and fetched from a non-config endpoint. TLSCertificate string TLSPrivateKey string }
A Cloud describes how to configure a robot controlled by the cloud. The cloud source could be anything that supports http. URL is constructed as $Path?id=ID and secret is put in a http header.
func CloudConfigFromProto ¶ added in v0.0.6
func CloudConfigFromProto(proto *pb.CloudConfig) (*Cloud, error)
CloudConfigFromProto creates Cloud from the proto equivalent.
func (Cloud) MarshalJSON ¶ added in v0.2.5
MarshalJSON marshals out this config.
func (*Cloud) UnmarshalJSON ¶ added in v0.2.5
UnmarshalJSON unmarshals JSON data into this config.
type Config ¶
type Config struct { Cloud *Cloud Modules []Module Remotes []Remote Components []resource.Config Processes []pexec.ProcessConfig Services []resource.Config Packages []PackageConfig Network NetworkConfig Auth AuthConfig Debug bool ConfigFilePath string // AllowInsecureCreds is used to have all connections allow insecure // downgrades and send credentials over plaintext. This is an option // a user must pass via command line arguments. AllowInsecureCreds bool // UntrustedEnv is used to disable Processes and shell for untrusted environments // where a process cannot be trusted. This is an option a user must pass via // command line arguments. UntrustedEnv bool // FromCommand indicates if this config was parsed via the web server command. // If false, it's for creating a robot via the RDK library. This is helpful for // error messages that can indicate flags/config fields to use. FromCommand bool // DisablePartialStart ensures that a robot will only start when all the components, // services, and remotes pass config validation. This value is false by default DisablePartialStart bool // PackagePath sets the directory used to store packages locally. Defaults to ~/.viam/packages PackagePath string }
A Config describes the configuration of a robot.
func FromReader ¶
func FromReader( ctx context.Context, originalPath string, r io.Reader, logger golog.Logger, ) (*Config, error)
FromReader reads a config from the given reader and specifies where, if applicable, the file the reader originated from.
func ProcessConfig ¶
ProcessConfig processes robot configs.
func ReadLocalConfig ¶ added in v0.1.0
ReadLocalConfig reads a config from the given file but does not fetch any config from the remote servers.
func (*Config) CopyOnlyPublicFields ¶ added in v0.0.6
CopyOnlyPublicFields returns a deep-copy of the current config only preserving JSON exported fields.
func (Config) FindComponent ¶
FindComponent finds a particular component by name.
func (Config) MarshalJSON ¶ added in v0.2.36
MarshalJSON marshals JSON from the config.
func (*Config) ReplacePlaceholders ¶ added in v0.7.2
ReplacePlaceholders traverses parts of the config to replace placeholders with their resolved values.
func (*Config) UnmarshalJSON ¶ added in v0.2.36
UnmarshalJSON unmarshals JSON into the config and adjusts some names if they are not fully filled in.
type Diff ¶
type Diff struct {
Left, Right *Config
Added *Config
Modified *ModifiedConfigDiff
Removed *Config
ResourcesEqual bool
NetworkEqual bool
PrettyDiff string
}
A Diff is the difference between two configs, left and right where left is usually old and right is new. So the diff is the changes from left to right.
func DiffConfigs ¶
DiffConfigs returns the difference between the two given configs from left to right.
type ExternalAuthConfig ¶ added in v0.2.27
type ExternalAuthConfig struct { // contains the raw jwks json. JSONKeySet rutils.AttributeMap `json:"jwks"` // on validation the JSONKeySet is validated and parsed into this field and can be used. ValidatedKeySet jwks.KeySet `json:"-"` }
ExternalAuthConfig contains information needed to verify externally authenticated tokens.
func (*ExternalAuthConfig) Validate ¶ added in v0.2.27
func (c *ExternalAuthConfig) Validate(path string) error
Validate returns true if the config is valid. Ensures each key is valid and meets the required constraints.
type LocationSecret ¶ added in v0.1.7
type LocationSecret struct { ID string `json:"id"` // Payload of the secret Secret string `json:"secret"` }
LocationSecret describes a location secret that can be used to authenticate to the rdk.
type ModifiedConfigDiff ¶
type ModifiedConfigDiff struct { Remotes []Remote Components []resource.Config Processes []pexec.ProcessConfig Services []resource.Config Packages []PackageConfig Modules []Module }
ModifiedConfigDiff is the modificative different between two configs.
type Module ¶ added in v0.2.8
type Module struct { // Name is an arbitrary name used to identify the module, and is used to name it's socket as well. Name string `json:"name"` // ExePath is the path (either absolute, or relative to the working directory) to the executable module file. ExePath string `json:"executable_path"` // LogLevel represents the level at which the module should log its messages. It will be passed as a commandline // argument "log-level" (i.e. preceded by "--log-level=") to the module executable. If unset or set to an empty // string, "--log-level=debug" will be passed to the module executable if the server was started with "-debug". // // SDK logger-creation utilities, such as module.NewLoggerFromArgs, will create an "Info" level logger when any // value besides "" or "debug" is used for LogLevel ("log_level" in JSON). In other words, setting a LogLevel // of something like "info" will ignore the debug setting on the server. LogLevel string `json:"log_level"` // contains filtered or unexported fields }
Module represents an external resource module, with a path to the binary module file.
func ModuleConfigFromProto ¶ added in v0.2.8
func ModuleConfigFromProto(proto *pb.ModuleConfig) (*Module, error)
ModuleConfigFromProto creates Module from the proto equivalent.
type NetworkConfig ¶
type NetworkConfig struct {
NetworkConfigData
}
NetworkConfig describes networking settings for the web server.
func NetworkConfigFromProto ¶ added in v0.0.6
func NetworkConfigFromProto(proto *pb.NetworkConfig) (*NetworkConfig, error)
NetworkConfigFromProto creates NetworkConfig from the proto equivalent.
func (NetworkConfig) MarshalJSON ¶
func (nc NetworkConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshals out this config.
func (*NetworkConfig) Validate ¶
func (nc *NetworkConfig) Validate(path string) error
Validate ensures all parts of the config are valid.
type NetworkConfigData ¶
type NetworkConfigData struct { // FQDN is the unique name of this server. FQDN string `json:"fqdn,omitempty"` // Listener is the listener that the web server will use. This is mutually // exclusive with BindAddress. Listener net.Listener `json:"-"` // BindAddress is the address that the web server will bind to. // The default behavior is to bind to localhost:8080. This is mutually // exclusive with Listener. BindAddress string `json:"bind_address,omitempty"` BindAddressDefaultSet bool `json:"-"` // TLSCertFile is used to enable secure communications on the hosted HTTP server. // This is mutually exclusive with TLSCertPEM and TLSKeyPEM. TLSCertFile string `json:"tls_cert_file,omitempty"` // TLSKeyFile is used to enable secure communications on the hosted HTTP server. // This is mutually exclusive with TLSCertPEM and TLSKeyPEM. TLSKeyFile string `json:"tls_key_file,omitempty"` // TLSConfig is used to enable secure communications on the hosted HTTP server. // This is mutually exclusive with TLSCertFile and TLSKeyFile. TLSConfig *tls.Config `json:"-"` // Sessions configures session management. Sessions SessionsConfig `json:"sessions"` }
NetworkConfigData is the network config data that gets marshaled/unmarshaled.
type PackageConfig ¶ added in v0.2.14
type PackageConfig struct { // Name is the local name of the package on the RDK. Must be unique across Packages. Must not be empty. Name string `json:"name"` // Package is the unqiue package name hosted by a remote PackageService. Must not be empty. Package string `json:"package"` // Version of the package ID hosted by a remote PackageService. If not specified "latest" is assumed. Version string `json:"version,omitempty"` // Types of the Package. If not specified it is assumed to be ml_model. Type PackageType `json:"type,omitempty"` // contains filtered or unexported fields }
A PackageConfig describes the configuration of a Package.
func PackageConfigFromProto ¶ added in v0.2.14
func PackageConfigFromProto(proto *pb.PackageConfig) (*PackageConfig, error)
PackageConfigFromProto converts a proto package config to the rdk version.
func (PackageConfig) Equals ¶ added in v0.5.0
func (p PackageConfig) Equals(other PackageConfig) bool
Equals checks if the two configs are deeply equal to each other.
func (*PackageConfig) LocalDataDirectory ¶ added in v0.7.2
func (p *PackageConfig) LocalDataDirectory(packagesDir string) string
LocalDataDirectory returns the folder where the package should be extracted. Ex: /home/user/.viam/packages/.data/ml_model/orgid_ballClassifier_0.1.2.
func (*PackageConfig) LocalDataParentDirectory ¶ added in v0.7.2
func (p *PackageConfig) LocalDataParentDirectory(packagesDir string) string
LocalDataParentDirectory returns the folder that will contain the all packages of this type. Ex: /home/user/.viam/packages/.data/ml_model.
func (*PackageConfig) LocalDownloadPath ¶ added in v0.7.2
func (p *PackageConfig) LocalDownloadPath(packagesDir string) string
LocalDownloadPath returns the file where the archive should be downloaded before extraction.
func (*PackageConfig) SanitizedName ¶ added in v0.7.2
func (p *PackageConfig) SanitizedName() string
SanitizedName returns the package name for the symlink/filepath of the package on the system.
func (*PackageConfig) Validate ¶ added in v0.2.14
func (p *PackageConfig) Validate(path string) error
Validate package config is valid.
type PackageType ¶ added in v0.6.0
type PackageType string
PackageType indicates the type of the package This is used to replace placeholder strings in the config.
const ( // PackageTypeMlModel represents an ML model. PackageTypeMlModel PackageType = "ml_model" // PackageTypeModule represents a module type. PackageTypeModule PackageType = "module" // PackageTypeSlamMap represents a slam internal state. PackageTypeSlamMap PackageType = "slam_map" // PackageTypeBoardDefs represents a linux board definition file. PackageTypeBoardDefs PackageType = "board_defs" )
type Remote ¶
type Remote struct { Name string Address string Frame *referenceframe.LinkConfig Auth RemoteAuth ManagedBy string Insecure bool ConnectionCheckInterval time.Duration ReconnectInterval time.Duration AssociatedResourceConfigs []resource.AssociatedResourceConfig // Secret is a helper for a robot location secret. Secret string // contains filtered or unexported fields }
A Remote describes a remote robot that should be integrated. The Frame field defines how the "world" node of the remote robot should be reconciled with the "world" node of the current robot. All components of the remote robot who have Parent as "world" will be attached to the parent defined in Frame, and with the given offset as well.
func RemoteConfigFromProto ¶ added in v0.0.6
func RemoteConfigFromProto(proto *pb.RemoteConfig) (*Remote, error)
RemoteConfigFromProto creates Remote from the proto equivalent.
func (Remote) Equals ¶ added in v0.2.36
Equals checks if the two configs are deeply equal to each other.
func (Remote) MarshalJSON ¶ added in v0.2.5
MarshalJSON marshals out this config.
func (*Remote) UnmarshalJSON ¶ added in v0.2.5
UnmarshalJSON unmarshals JSON data into this config.
type RemoteAuth ¶
type RemoteAuth struct { Credentials *rpc.Credentials `json:"credentials"` Entity string `json:"entity"` // only used internally right now ExternalAuthAddress string `json:"-"` ExternalAuthInsecure bool `json:"-"` ExternalAuthToEntity string `json:"-"` Managed bool `json:"-"` SignalingServerAddress string `json:"-"` SignalingAuthEntity string `json:"-"` SignalingCreds *rpc.Credentials `json:"-"` }
RemoteAuth specifies how to authenticate against a remote. If no credentials are specified, authentication does not happen. If an entity is specified, the authentication request will specify it.
type SessionsConfig ¶ added in v0.2.5
type SessionsConfig struct { // HeartbeatWindow is the window within which clients must send at least one // heartbeat in order to keep a session alive. HeartbeatWindow time.Duration }
SessionsConfig configures various parameters used in session management.
func (SessionsConfig) MarshalJSON ¶ added in v0.2.5
func (sc SessionsConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshals out this config.
func (*SessionsConfig) UnmarshalJSON ¶ added in v0.2.5
func (sc *SessionsConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON data into this config.
func (*SessionsConfig) Validate ¶ added in v0.2.5
func (sc *SessionsConfig) Validate(path string) error
Validate ensures all parts of the config are valid.
type TLSConfig ¶
TLSConfig stores the TLS config for the robot.
func NewTLSConfig ¶
NewTLSConfig creates a new tls config.
func (*TLSConfig) UpdateCert ¶
UpdateCert updates the TLS certificate to be returned.