config

package
v0.2.29 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: AGPL-3.0 Imports: 40 Imported by: 15

Documentation

Overview

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

Index

Constants

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.

Variables

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

RDK versioning variables which are replaced by LD flags.

View Source
var ValidNameRegex = regexp.MustCompile(`^[a-zA-Z][-\w]*$`)

ValidNameRegex is the pattern that matches to a valid name. The name must begin with a letter i.e. [a-zA-Z], and the body can only contain 0 or more numbers, letters, dashes and underscores i.e. [-\w]*.

Functions

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 ComponentConfigToProto added in v0.0.6

func ComponentConfigToProto(component *Component) (*pb.ComponentConfig, error)

ComponentConfigToProto converts Component to the proto equivalent.

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 ErrInvalidName added in v0.2.29

func ErrInvalidName(name string) error

ErrInvalidName returns a human-readable error for when ValidNameRegex doesn't match.

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 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 RegisterComponentAttributeConverter

func RegisterComponentAttributeConverter(subtype resource.Subtype, model resource.Model, attr string, conv AttributeConverter)

RegisterComponentAttributeConverter associates a component type and model with a way to convert a particular attribute name.

func RegisterComponentAttributeMapConverter

func RegisterComponentAttributeMapConverter(
	subtype resource.Subtype,
	model resource.Model,
	conv AttributeMapConverter,
	retType interface{},
)

RegisterComponentAttributeMapConverter associates a component type and model with a way to convert all attributes.

func RegisterServiceAttributeMapConverter

func RegisterServiceAttributeMapConverter(
	svcType resource.Subtype,
	model resource.Model,
	conv AttributeMapConverter,
	retType interface{},
)

RegisterServiceAttributeMapConverter associates a service type with a way to convert all attributes.

func RemoteConfigToProto added in v0.0.6

func RemoteConfigToProto(remote *Remote) (*pb.RemoteConfig, error)

RemoteConfigToProto converts Remote to the proto equivalent.

func ResourceLevelServiceConfigToProto added in v0.0.6

func ResourceLevelServiceConfigToProto(service ResourceLevelServiceConfig) (*pb.ResourceLevelServiceConfig, error)

ResourceLevelServiceConfigToProto converts ResourceLevelServiceConfig to the proto equivalent.

func ServiceConfigToProto added in v0.0.6

func ServiceConfigToProto(service *Service) (*pb.ServiceConfig, error)

ServiceConfigToProto converts Service to the proto equivalent.

func ServiceConfigToSharedProto added in v0.2.8

func ServiceConfigToSharedProto(service *Service) (*pb.ComponentConfig, error)

ServiceConfigToSharedProto converts Service to the proto equivalent shared with Components.

func TransformAttributeMapToStruct

func TransformAttributeMapToStruct(to interface{}, attributes AttributeMap) (interface{}, error)

TransformAttributeMapToStruct uses an attribute map to transform attributes to the prescribed format.

Types

type AttributeConverter

type AttributeConverter func(val interface{}) (interface{}, error)

An AttributeConverter converts a single attribute into a possibly different representation.

type AttributeMap

type AttributeMap map[string]interface{}

An AttributeMap is a convenience wrapper for pulling out typed information from a map.

func (AttributeMap) Bool

func (am AttributeMap) Bool(name string, def bool) bool

Bool attempts to return a boolean present in the map with the given name; returns the given default otherwise.

func (AttributeMap) BoolSlice

func (am AttributeMap) BoolSlice(name string, def bool) []bool

BoolSlice attempts to return a slice of bools present in the map with the given name; returns an empty slice otherwise.

func (AttributeMap) Float64

func (am AttributeMap) Float64(name string, def float64) float64

Float64 attempts to return a float64 present in the map with the given name; returns the given default otherwise.

func (AttributeMap) Float64Slice

func (am AttributeMap) Float64Slice(name string) []float64

Float64Slice attempts to return a slice of ints present in the map with the given name; returns an empty slice otherwise.

func (AttributeMap) Has

func (am AttributeMap) Has(name string) bool

Has returns whether or not the given name is in the map.

func (AttributeMap) Int

func (am AttributeMap) Int(name string, def int) int

Int attempts to return an integer present in the map with the given name; returns the given default otherwise.

func (AttributeMap) IntSlice

func (am AttributeMap) IntSlice(name string) []int

IntSlice attempts to return a slice of ints present in the map with the given name; returns an empty slice otherwise.

func (AttributeMap) String

func (am AttributeMap) String(name string) string

String attempts to return a string present in the map with the given name; returns an empty string otherwise.

func (AttributeMap) StringSlice

func (am AttributeMap) StringSlice(name string) []string

StringSlice attempts to return a slice of strings present in the map with the given name; returns an empty slice otherwise.

func (AttributeMap) Walk added in v0.2.28

func (am AttributeMap) Walk(visitor Visitor) (interface{}, error)

Walk implements the Walker interface.

type AttributeMapConverter

type AttributeMapConverter func(attributes AttributeMap) (interface{}, error)

An AttributeMapConverter converts an attribute map into a possibly different representation.

func FindMapConverter added in v0.2.25

func FindMapConverter(subtype resource.Subtype, model resource.Model) AttributeMapConverter

FindMapConverter finds the component AttributeMapConverter for the given subtype and model.

func FindServiceMapConverter added in v0.2.25

func FindServiceMapConverter(svcType resource.Subtype, model resource.Model) AttributeMapConverter

FindServiceMapConverter finds the service AttributeMapConverter for the given subtype and model.

type AuthConfig

type AuthConfig struct {
	Handlers        []AuthHandlerConfig `json:"handlers"`
	TLSAuthEntities []string            `json:"tls_auth_entities"`
	// TODO(erd): test
	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 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

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.

type Component

type Component struct {
	Name string `json:"name"`

	Namespace resource.Namespace   `json:"namespace"`
	Type      resource.SubtypeName `json:"type"`
	// TODO(PRODUCT-266): API replaces Type and Namespace when Service/Component merge, so json needs to be enabled.
	API           resource.Subtype             `json:"-"`
	Model         resource.Model               `json:"model"`
	Frame         *referenceframe.LinkConfig   `json:"frame,omitempty"`
	DependsOn     []string                     `json:"depends_on"`
	ServiceConfig []ResourceLevelServiceConfig `json:"service_config"`

	Attributes          AttributeMap `json:"attributes"`
	ConvertedAttributes interface{}  `json:"-"`
	ImplicitDependsOn   []string     `json:"-"`
}

A Component describes the configuration of a component.

func ComponentConfigFromProto added in v0.0.6

func ComponentConfigFromProto(proto *pb.ComponentConfig) (*Component, error)

ComponentConfigFromProto creates Component from the proto equivalent.

func ParseComponentFlag

func ParseComponentFlag(flag string) (Component, error)

ParseComponentFlag parses a component flag from command line arguments.

func ServiceConfigToShared added in v0.2.8

func ServiceConfigToShared(cfg Service) Component

ServiceConfigToShared converts a Service to the common resource config (Component for now.)

func (*Component) Dependencies

func (config *Component) Dependencies() []string

Dependencies returns the deduplicated union of user-defined and implicit dependencies.

func (*Component) Get

func (config *Component) Get() interface{}

Get gets the config itself.

func (*Component) ResourceName

func (config *Component) ResourceName() resource.Name

ResourceName returns the ResourceName for the component.

func (*Component) Set

func (config *Component) Set(val string) error

Set hydrates a config based on a flag like value.

func (*Component) String

func (config *Component) String() string

String returns a verbose representation of the config.

func (*Component) Validate

func (config *Component) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid and returns dependencies.

type ComponentAttributeConverterRegistration

type ComponentAttributeConverterRegistration struct {
	Subtype resource.Subtype
	Model   resource.Model
	Attr    string
	Conv    AttributeConverter
}

A ComponentAttributeConverterRegistration describes how to convert a specific attribute for a model of a type of component.

func RegisteredComponentAttributeConverters

func RegisteredComponentAttributeConverters() []ComponentAttributeConverterRegistration

RegisteredComponentAttributeConverters returns a copy of the registered component attribute converters.

type ComponentAttributeMapConverterRegistration

type ComponentAttributeMapConverterRegistration struct {
	Subtype resource.Subtype
	Model   resource.Model
	Conv    AttributeMapConverter
	RetType interface{} // the shape of what is converted to
}

A ComponentAttributeMapConverterRegistration describes how to convert all attributes for a model of a type of component.

func RegisteredComponentAttributeMapConverters

func RegisteredComponentAttributeMapConverters() []ComponentAttributeMapConverterRegistration

RegisteredComponentAttributeMapConverters returns a copy of the registered component attribute converters.

type ComponentUpdate added in v0.0.9

type ComponentUpdate interface {
	UpdateAction(config *Component) UpdateActionType
}

ComponentUpdate interface that a component can optionally implement. This interface helps the reconfiguration process.

type Config

type Config struct {
	Cloud      *Cloud                `json:"cloud,omitempty"`
	Modules    []Module              `json:"modules,omitempty"`
	Remotes    []Remote              `json:"remotes,omitempty"`
	Components []Component           `json:"components,omitempty"`
	Processes  []pexec.ProcessConfig `json:"processes,omitempty"`
	Services   []Service             `json:"services,omitempty"`
	Packages   []PackageConfig       `json:"packages,omitempty"`
	Network    NetworkConfig         `json:"network"`
	Auth       AuthConfig            `json:"auth"`
	Debug      bool                  `json:"debug,omitempty"`

	ConfigFilePath string `json:"-"`

	// 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 `json:"-"`

	// 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 `json:"-"`

	// LimitConfigurableDirectories is used to limit which directories users can configure for
	// storing data on-robot. This is set via command line arguments.
	LimitConfigurableDirectories bool `json:"-"`

	// 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 `json:"-"`

	// 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 `json:"disable_partial_start"`

	// PackagePath sets the directory used to store packages locally. Defaults to ~/.viam/packages
	PackagePath string `json:"-"`
}

A Config describes the configuration of a robot.

func FromProto added in v0.1.0

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

FromProto converts the RobotConfig to the internal rdk equivalent.

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

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

ProcessConfig processes robot configs.

func Read

func Read(
	ctx context.Context,
	filePath string,
	logger golog.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 golog.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) error

Ensure ensures all parts of the config are valid.

func (Config) FindComponent

func (c Config) FindComponent(name string) *Component

FindComponent finds a particular component by name.

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

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) 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 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
	// Payload of the secret
	Secret string
}

LocationSecret describes a location secret that can be used to authenticate to the rdk.

type ModifiedConfigDiff

type ModifiedConfigDiff struct {
	Remotes    []Remote
	Components []Component
	Processes  []pexec.ProcessConfig
	Services   []Service
	Packages   []PackageConfig
}

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

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) Validate added in v0.2.8

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

Validate checks if the config is valid.

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

	// 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"`

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

	// 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"`

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

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) Validate added in v0.2.14

func (p *PackageConfig) Validate(path string) error

Validate package config is valid.

type PackageReference added in v0.2.15

type PackageReference struct {
	Package       string
	PathInPackage string
}

PackageReference contains the deconstructed parts of a package reference in the config. Eg: ${packages.some-package}/path/a/b/c -> {"some-package", "/path/a/b/c"}.

func GetPackageReference added in v0.2.15

func GetPackageReference(path string) *PackageReference

GetPackageReference a PackageReference if the given path has a Package reference eg. ${packages.some-package}/path. Returns nil if no package reference is found.

type Remote

type Remote struct {
	Name                    string
	Address                 string
	Frame                   *referenceframe.LinkConfig
	Auth                    RemoteAuth
	ManagedBy               string
	Insecure                bool
	ConnectionCheckInterval time.Duration
	ReconnectInterval       time.Duration
	ServiceConfig           []ResourceLevelServiceConfig

	// Secret is a helper for a robot location secret.
	Secret string
}

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) MarshalJSON added in v0.2.5

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

MarshalJSON marshals out this config.

func (*Remote) UnmarshalJSON added in v0.2.5

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

UnmarshalJSON unmarshals JSON data into this config.

func (*Remote) Validate

func (config *Remote) Validate(path 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 ResourceConfig

type ResourceConfig interface {
	String() string
	ResourceName() resource.Name
	Get() interface{}
	Set(val string) error
	// contains filtered or unexported methods
}

A ResourceConfig represents an implmentation of a config for any type of resource.

type ResourceLevelServiceConfig

type ResourceLevelServiceConfig struct {
	Type                resource.SubtypeName `json:"type"`
	Attributes          AttributeMap         `json:"attributes"`
	ConvertedAttributes interface{}          `json:"-"`
}

A ResourceLevelServiceConfig describes component or remote configuration for a service.

func ResourceLevelServiceConfigFromProto added in v0.0.6

func ResourceLevelServiceConfigFromProto(proto *pb.ResourceLevelServiceConfig) (ResourceLevelServiceConfig, error)

ResourceLevelServiceConfigFromProto creates ResourceLevelServiceConfig from the proto equivalent.

func (*ResourceLevelServiceConfig) ResourceName

func (config *ResourceLevelServiceConfig) ResourceName() resource.Name

ResourceName returns the ResourceName for the component within a service_config.

type Service

type Service struct {
	Name string `json:"name"`

	Namespace resource.Namespace   `json:"namespace"`
	Type      resource.SubtypeName `json:"type"`
	Model     resource.Model       `json:"model"`
	DependsOn []string             `json:"depends_on"`

	Attributes          AttributeMap `json:"attributes"`
	ConvertedAttributes interface{}  `json:"-"`
	ImplicitDependsOn   []string     `json:"-"`
}

A Service describes the configuration of a service.

func ParseServiceFlag

func ParseServiceFlag(flag string) (Service, error)

ParseServiceFlag parses a service flag from command line arguments.

func ServiceConfigFromProto added in v0.0.6

func ServiceConfigFromProto(proto *pb.ServiceConfig) (*Service, error)

ServiceConfigFromProto creates Service from the proto equivalent shared with Components.

func ServiceConfigFromShared added in v0.2.8

func ServiceConfigFromShared(cfg Component) Service

ServiceConfigFromShared converts a common resource config (Component for now) to a Service.

func ServiceConfigFromSharedProto added in v0.2.8

func ServiceConfigFromSharedProto(proto *pb.ComponentConfig) (*Service, error)

ServiceConfigFromSharedProto creates a Service from the proto equivalent.

func (*Service) Dependencies added in v0.2.0

func (config *Service) Dependencies() []string

Dependencies returns the deduplicated union of user-defined and implicit dependencies.

func (*Service) Get

func (config *Service) Get() interface{}

Get gets the config itself.

func (*Service) ResourceName

func (config *Service) ResourceName() resource.Name

ResourceName returns the ResourceName for the component.

func (*Service) Set

func (config *Service) Set(val string) error

Set hydrates a config based on a flag like value.

func (*Service) String

func (config *Service) String() string

String returns a verbose representation of the config.

func (*Service) Validate

func (config *Service) Validate(path string) ([]string, error)

Validate ensures all parts of the config are valid.

type ServiceAttributeMapConverterRegistration

type ServiceAttributeMapConverterRegistration struct {
	SvcType resource.Subtype
	Model   resource.Model
	Conv    AttributeMapConverter
	RetType interface{} // the shape of what is converted to
}

A ServiceAttributeMapConverterRegistration describes how to convert all attributes for a model of a type of service.

func RegisteredServiceAttributeMapConverters

func RegisteredServiceAttributeMapConverters() []ServiceAttributeMapConverterRegistration

RegisteredServiceAttributeMapConverters returns a copy of the registered component attribute converters.

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

type TLSConfig struct {
	*tls.Config
	// contains filtered or unexported fields
}

TLSConfig stores the TLS config for the robot.

func NewTLSConfig

func NewTLSConfig(cfg *Config) *TLSConfig

NewTLSConfig creates a new tls config.

func (*TLSConfig) UpdateCert

func (t *TLSConfig) UpdateCert(cfg *Config) error

UpdateCert updates the TLS certificate to be returned.

type UpdateActionType

type UpdateActionType int

UpdateActionType help hint the reconfigure process on whether one should reconfigure a resource or rebuild it.

const (
	// None is returned when the new configuration doesn't change the resource.
	None UpdateActionType = iota
	// Reconfigure is returned when the resource should be updated without recreating its proxies.
	// Note that two instances (old&new) will coexist, all dependencies will be destroyed and recreated.
	Reconfigure
	// Rebuild is returned when the resource and it's proxies should be destroyed and recreated,
	// all dependencies will be destroyed and recreated.
	Rebuild
)

type Updateable

type Updateable interface {
	// Update updates the resource
	Update(context.Context, *Config) error
}

Updateable is implemented when component/service of a robot should be updated with the config.

type Visitor added in v0.2.28

type Visitor interface {
	// Visit visits a node and returns a new node, with or without modifications.
	Visit(interface{}) (interface{}, error)
}

Visitor defines an interface for visiting and potentially modifying portions of the config.

type Walker added in v0.2.28

type Walker interface {
	// Walk walks a structure and returns a new structure, with or without modifications.
	Walk(Visitor) (interface{}, error)
}

Walker is a portion of the config that can be walked.

type Watcher

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

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 golog.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