config

package
v0.51.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 47 Imported by: 15

Documentation

Overview

Package config defines the structures to configure a robot and its connected parts.

Index

Constants

View Source
const (

	// PackagesDirName is where packages go underneath viamDotDir.
	PackagesDirName = "packages"
	// LocalPackagesSuffix is used by the local package manager.
	LocalPackagesSuffix = "-local"
)
View Source
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.

View Source
const DefaultPackageVersionValue = "latest"

DefaultPackageVersionValue default value of the package version used when empty.

View Source
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.

View Source
const FirstRunSuccessSuffix = ".first_run_succeeded"

FirstRunSuccessSuffix is the suffix of the file whose existence denotes that the first run script for a module ran successfully.

Note that we create a new file instead of writing to `.status.json`, which contains various package/module state tracking information. Writing to `.status.json` introduces the risk of corrupting it, which could break or uncoordinate package sync.

Variables

View Source
var (
	Version      = ""
	GitRevision  = ""
	DateCompiled = ""
)

RDK versioning variables which are replaced by LD flags.

SupportedPackageTypes is a list of all of the valid package types.

View Source
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

func ContainsPlaceholder(s string) bool

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 logging.Logger) (rpc.ClientConn, error)

CreateNewGRPCClient creates a new grpc cloud configured to communicate with the robot service based on the cloud config given.

func CreateNewGRPCClientWithAPIKey added in v0.12.0

func CreateNewGRPCClientWithAPIKey(ctx context.Context, cloudCfg *Cloud,
	apiKey, apiKeyID string, logger logging.Logger,
) (rpc.ClientConn, error)

CreateNewGRPCClientWithAPIKey creates a new grpc cloud configured to communicate with the robot service based on the cloud config and API key given.

func CreateTLSWithCert added in v0.47.0

func CreateTLSWithCert(cfg *Config) (*tls.Config, error)

CreateTLSWithCert creates a tls.Config with the TLS certificate to be returned.

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 InitLoggingSettings added in v0.10.0

func InitLoggingSettings(logger logging.Logger, cmdLineDebugFlag bool)

InitLoggingSettings initializes the global logging settings.

func LogConfigFromProto added in v0.33.0

func LogConfigFromProto(proto *pb.LogPatternConfig) (*logging.LoggerPatternConfig, error)

LogConfigFromProto converts a proto LoggerPatternConfig to the rdk version.

func LogConfigToProto added in v0.33.0

func LogConfigToProto(logConfig *logging.LoggerPatternConfig) (*pb.LogPatternConfig, error)

LogConfigToProto converts a LoggerPatternConfig type to its proto equivalent.

func MaintenanceConfigToProto added in v0.46.0

func MaintenanceConfigToProto(maintenanceConfig *MaintenanceConfig) (*pb.MaintenanceConfig, error)

MaintenanceConfigToProto converts MaintenanceConfig from 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.

func UpdateCloudConfigDebug added in v0.10.0

func UpdateCloudConfigDebug(cloudDebug bool)

UpdateCloudConfigDebug is used to update the debug flag whenever a cloud-based viam config is refreshed.

func UpdateFileConfigDebug added in v0.10.0

func UpdateFileConfigDebug(fileDebug bool)

UpdateFileConfigDebug is used to update the debug flag whenever a file-based viam config is refreshed.

func UpdateLoggerRegistryFromConfig added in v0.43.0

func UpdateLoggerRegistryFromConfig(registry *logging.Registry, cfg *Config, warnLogger logging.Logger)

UpdateLoggerRegistryFromConfig will update the passed in registry with all log patterns in `cfg.LogConfig` and each resource's `LogConfiguration` field if present.

Types

type AppValidationStatus added in v0.13.0

type AppValidationStatus struct {
	Error string `json:"error"`
}

AppValidationStatus refers to the.

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. If it exists, updates ExternalAuthConfig's ValidatedKeySet once validated. A sample AuthConfig in JSON form is shown below, where "handlers" contains a list of auth handlers. The only accepted credential type for the RDK in the config is "api-key" currently. An auth handler for utils.CredentialsTypeRobotLocationSecret may be added later by the RDK during processing.

"auth": {
		"handlers": [
			{
				"type": "api-key",
				"config": {
					"API_KEY_ID": "API_KEY",
					"API_KEY_ID_2": "API_KEY_2",
					"keys": ["API_KEY_ID", "API_KEY_ID_2"]
				}
			}
		],
	    "external_auth_config": {}
}

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
	LocationID        string
	PrimaryOrgID      string
	MachineID         string
	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

func (config Cloud) MarshalJSON() ([]byte, error)

MarshalJSON marshals out this config.

func (*Cloud) UnmarshalJSON added in v0.2.5

func (config *Cloud) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into this config.

func (*Cloud) Validate

func (config *Cloud) Validate(path string, fromCloud bool) error

Validate ensures all parts of the config are valid. Adds default for RefreshInterval if not set.

func (*Cloud) ValidateTLS added in v0.21.1

func (config *Cloud) ValidateTLS(path string) error

ValidateTLS ensures TLS fields are valid.

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
	LogConfig         []logging.LoggerPatternConfig
	MaintenanceConfig *MaintenanceConfig

	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

	// EnableWebProfile turns pprof http server in localhost. Defaults to false.
	EnableWebProfile bool

	// Revision contains the current revision of the config.
	Revision string
	// contains filtered or unexported fields
}

A Config describes the configuration of a robot.

func FromProto added in v0.1.0

func FromProto(proto *pb.RobotConfig, logger logging.Logger) (*Config, error)

FromProto converts the RobotConfig to the internal rdk equivalent.

func FromReader

func FromReader(
	ctx context.Context,
	originalPath string,
	r io.Reader,
	logger logging.Logger,
) (*Config, error)

FromReader reads a config from the given reader and specifies where, if applicable, the file the reader originated from.

func ProcessConfig

func ProcessConfig(in *Config) (*Config, error)

ProcessConfig processes robot configs.

func Read

func Read(
	ctx context.Context,
	filePath string,
	logger logging.Logger,
) (*Config, error)

Read reads a config from the given file.

func ReadLocalConfig added in v0.1.0

func ReadLocalConfig(
	ctx context.Context,
	filePath string,
	logger logging.Logger,
) (*Config, error)

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

func (c *Config) CopyOnlyPublicFields() (*Config, error)

CopyOnlyPublicFields returns a deep-copy of the current config only preserving JSON exported fields.

func (*Config) Ensure

func (c *Config) Ensure(fromCloud bool, logger logging.Logger) error

Ensure ensures all parts of the config are valid, which may include updating it. Only returns an error if c.DisablePartialStart is true (default: false).

func (Config) FindComponent

func (c Config) FindComponent(name string) *resource.Config

FindComponent finds a particular component by name.

func (Config) MarshalJSON added in v0.2.36

func (c Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals JSON from the config.

func (*Config) ProcessLocal added in v0.31.0

func (c *Config) ProcessLocal(logger logging.Logger) error

ProcessLocal validates the current config assuming it came from a local file and updates it with all derived fields. Returns an error if the unprocessedConfig is non-valid.

func (*Config) ReplacePlaceholders added in v0.7.2

func (c *Config) ReplacePlaceholders() error

ReplacePlaceholders traverses parts of the config to replace placeholders with their resolved values.

func (*Config) SetToCache added in v0.41.0

func (c *Config) SetToCache(cfg *Config) error

SetToCache sets toCache with a marshalled copy of the config passed in.

func (*Config) StoreToCache added in v0.41.0

func (c *Config) StoreToCache() error

StoreToCache caches the toCache.

func (*Config) UnmarshalJSON added in v0.2.36

func (c *Config) UnmarshalJSON(data []byte) error

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
	LogEqual            bool
	PrettyDiff          string
	UnmodifiedResources []resource.Config
}

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

func DiffConfigs(left, right Config, revealSensitiveConfigDiffs bool) (_ *Diff, err error)

DiffConfigs returns the difference between the two given configs from left to right.

func (Diff) NewRevision added in v0.36.0

func (diff Diff) NewRevision() string

NewRevision returns the revision from the new config if available.

func (*Diff) String

func (diff *Diff) String() string

String returns a pretty version of the diff.

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. Updates ValidatedKeySet once validated. A sample ExternalAuthConfig in JSON form is shown below, where "keys" contains a list of JSON Web Keys as defined in https://datatracker.ietf.org/doc/html/rfc7517.

"external_auth_config": {
	"jwks": {
		"keys": [
			{
				"alg": "XXXX",
				"e": "XXXX",
				"kid": "XXXX",
				"kty": "XXXX",
				"n": "XXXX"
			}
		]
	}
}

type JSONManifest added in v0.28.0

type JSONManifest struct {
	Entrypoint string `json:"entrypoint"`
	FirstRun   string `json:"first_run"`
}

JSONManifest contains meta.json fields that are used by both RDK and CLI.

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 MaintenanceConfig added in v0.46.0

type MaintenanceConfig struct {
	SensorName            string `json:"sensor_name"`
	MaintenanceAllowedKey string `json:"maintenance_allowed_key"`
}

MaintenanceConfig specifies a sensor that the machine will check to determine if the machine should reconfigure. This Config is not validated during config processing but it will be validated during reconfiguration.

func MaintenanceConfigFromProto added in v0.46.0

func MaintenanceConfigFromProto(proto *pb.MaintenanceConfig) (*MaintenanceConfig, error)

MaintenanceConfigFromProto creates a MaintenanceConfig from the proto equivalent.

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"`
	// Type indicates whether this is a local or registry module.
	Type ModuleType `json:"type"`
	// ModuleID is the id of the module in the registry. It is empty on non-registry modules.
	ModuleID string `json:"module_id,omitempty"`
	// Environment contains additional variables that are passed to the module process when it is started.
	// They overwrite existing environment variables.
	Environment map[string]string `json:"env,omitempty"`

	// FirstRunTimeout is the timeout duration for the first run script.
	// This field will only be applied if it is a positive value. Supplying a
	// non-positive will set the first run timeout to the default value of 1 hour,
	// which is equivalent to leaving this field unset. If you wish to set an
	// immediate timeout you should set this field to a very small positive value
	// such as "1ns".
	FirstRunTimeout goutils.Duration `json:"first_run_timeout,omitempty"`

	// Status refers to the validations done in the APP to make sure a module is configured correctly
	Status *AppValidationStatus `json:"status"`

	// LocalVersion is an in-process fake version used for local module change management.
	LocalVersion string
	// 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.

func (Module) Equals added in v0.5.0

func (m Module) Equals(other Module) bool

Equals checks if the two modules are deeply equal to each other.

func (Module) EvaluateExePath added in v0.28.0

func (m Module) EvaluateExePath(packagesDir string) (string, error)

EvaluateExePath returns absolute ExePath from one of three sources (in order of precedence): 1. if there is a meta.json in the exe dir, use that, except in local non-tarball case. 2. if this is a local tarball and there's a meta.json next to the tarball, use that. 3. otherwise use the exe path from config, or fail if this is a local tarball. Note: the working directory must be the unpacked tarball directory or local exec directory.

func (*Module) FirstRun added in v0.50.0

func (m *Module) FirstRun(
	ctx context.Context,
	localPackagesDir,
	dataDir string,
	env map[string]string,
	logger logging.Logger,
) error

FirstRun executes a module-specific setup script.

func (Module) NeedsSyntheticPackage added in v0.28.0

func (m Module) NeedsSyntheticPackage() bool

NeedsSyntheticPackage returns true if this is a local module pointing at a tarball.

func (Module) SyntheticPackage added in v0.28.0

func (m Module) SyntheticPackage() (PackageConfig, error)

SyntheticPackage creates a fake package for a module which can be used to access some package logic.

func (*Module) Validate added in v0.2.8

func (m *Module) Validate(path string) error

Validate checks if the config is valid.

type ModuleType added in v0.11.0

type ModuleType string

ModuleType indicates where a module comes from.

const (
	// ModuleTypeLocal is a module that resides on the host system.
	ModuleTypeLocal ModuleType = "local"
	// ModuleTypeRegistry is a module from our registry that is distributed in a package and is downloaded at runtime.
	ModuleTypeRegistry ModuleType = "registry"
)

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. Adds default BindAddress and HeartbeatWindow if not set.

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.
	Type PackageType `json:"type"`

	Status *AppValidationStatus `json:"status,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"
)

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

func (conf Remote) Equals(other Remote) bool

Equals checks if the two configs are deeply equal to each other.

func (Remote) MarshalJSON added in v0.2.5

func (conf Remote) MarshalJSON() ([]byte, error)

MarshalJSON marshals out this config.

func (*Remote) UnmarshalJSON added in v0.2.5

func (conf *Remote) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into this config.

func (*Remote) Validate

func (conf *Remote) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid.

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 Revision added in v0.36.0

type Revision struct {
	Revision    string
	LastUpdated time.Time
}

Revision encapsulates the revision of the latest config ingested by the robot along with a timestamp.

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. Sets default HeartbeatWindow if not set.

type Watcher

type Watcher interface {
	Config() <-chan *Config
	Close() error
}

A Watcher is responsible for watching for changes to a config from some source and delivering those changes to some destination.

func NewWatcher

func NewWatcher(ctx context.Context, config *Config, logger logging.Logger) (Watcher, error)

NewWatcher returns an optimally selected Watcher based on the given config.

Directories

Path Synopsis
Package testutils helpers for testing the config retrievial.
Package testutils helpers for testing the config retrievial.

Jump to

Keyboard shortcuts

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