config

package
v1.2024.8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ancestor

type Ancestor struct {
	NodeID string
	Title  string
}

Ancestor defines a node in the Ancestors.

type Ancestors

type Ancestors []Ancestor

Ancestors represents a list of ancestors (root is first).

func (Ancestors) MarshalJSON

func (ancestors Ancestors) MarshalJSON() ([]byte, error)

MarshalJSON allows to marshal ancestors chain as an ordered map.

func (*Ancestors) UnmarshalJSON

func (ancestors *Ancestors) UnmarshalJSON(data []byte) error

UnmarshalJSON allows to unmarshal ancestors chain from an ordered map.

type Bundle

type Bundle string

Bundle defines a configuration bundle name.

const ConnectivityWatchdogBundle Bundle = "connectivity_watchdog"

ConnectivityWatchdogBundle defines name for the connectivity watchdog bundle.

const DockerContainersBundle Bundle = "docker_containers"

DockerContainersBundle defines name for the docker containers bundle.

const FileDistributionBundle Bundle = "file_distribution"

FileDistributionBundle defines name for the file distribution bundle.

const FirewallBundle Bundle = "firewall"

FirewallBundle defines name for the firewall bundle.

const NTPBundle Bundle = "ntp"

NTPBundle defines name for the NTP bundle.

const PackageManagementBundle Bundle = "package_management"

PackageManagementBundle defines name for the package management bundle.

const ParametersBundle Bundle = "parameters"

ParametersBundle defines name for the parameters bundle.

const PasswordBundle Bundle = "password"

PasswordBundle defines name for the passwords bundle.

const ProcessWatchBundle Bundle = "proc_watch"

ProcessWatchBundle defines name for the process watch bundle.

const RaucBundle Bundle = "rauc"

RaucBundle defines the name for the RAUC bundle.

const SSHKeysBundle Bundle = "sshkeys"

SSHKeysBundle defines name for the SSH keys management bundle.

const SettingsBundle Bundle = "settings"

SettingsBundle defines name for the agent settings bundle.

const SoftwareManagementBundle Bundle = "software_management"

SoftwareManagementBundle defines name for the software management bundle.

const UsersBundle Bundle = "users"

UsersBundle defines name for the system users management bundle.

type BundleData

type BundleData struct {
	Settings             *Settings             `json:"settings,omitempty"`
	Users                *Users                `json:"users,omitempty"`
	SSHKeys              *SSHKeys              `json:"sshkeys,omitempty"`
	PackageManagement    *PackageManagement    `json:"package_management,omitempty"`
	FileDistribution     *FileDistribution     `json:"file_distribution,omitempty"`
	ConnectivityWatchdog *ConnectivityWatchdog `json:"connectivity_watchdog,omitempty"`
	ProcWatch            *ProcessWatch         `json:"proc_watch,omitempty"`
	NTP                  *NTP                  `json:"ntp,omitempty"`
	Parameters           *Parameters           `json:"parameters,omitempty"`
	SoftwareManagement   *SoftwareManagement   `json:"software_management,omitempty"`
	DockerContainers     *DockerContainers     `json:"docker_containers,omitempty"`
	Password             *Password             `json:"password,omitempty"`
	Firewall             *Firewall             `json:"firewall,omitempty"`
	Rauc                 *Rauc                 `json:"rauc,omitempty"`
}

BundleData combines all configuration bundles into one struct.

type BundleNames

type BundleNames []Bundle

BundleNames is a list of configuration bundle names and order in which they should be applied.

type Config added in v1.2024.8

type Config struct {
	// EntityID is either a nodeID for EntityTypeNode or tag value for EntityTypeTag
	EntityID string `json:"id"`

	// Type defines entity type ID relevant to above EntityID
	Type EntityType `json:"type"`

	// CommitID of the most recent commit affecting the config's contents
	CommitID string `json:"commit_id"`

	// CommitCreated is a creation timestamp of the commit used to determine which Config has the most recent changes
	// in the chain of configs when we calculate an active config for an entity.
	// This is stored in nanosecond resolution.
	CommitCreated int64 `json:"commit_created"`

	// Bundles contains a list of strings representing configuration bundles
	Bundles BundleNames `json:"bundles"`

	// BundleData contain configuration data for bundles in the Bundles list
	BundleData BundleData `json:"bundle_data"`
}

Config contains entity's configuration bundles

type ConfigurationFile

type ConfigurationFile struct {
	// ConfigTemplate defines a source template file from file manager.
	ConfigTemplate string `json:"config_template,omitempty"`

	// ConfigLocation defines an absolute path in the system where file will be created.
	ConfigLocation string `json:"config_location,omitempty"`
}

ConfigurationFile definition.

type ConfigurationFileParameter

type ConfigurationFileParameter struct {
	// Key defines parameters name.
	Key string `json:"key,omitempty"`

	// Value defines parameters value.
	Value string `json:"value,omitempty"`
}

ConfigurationFileParameter defines parameter to be used in ConfigurationFile.

type ConnectivityWatchdog

type ConnectivityWatchdog struct {
	Metadata

	// Threshold defines how many consecutive failed pings are allowed before the watchdog triggers a reboot.
	Threshold string `json:"threshold"`
}

ConnectivityWatchdog when enabled, will count failed connection attempts to the device hub and reboot the device if the threshold is reached.

Example payload:

{
  "threshold": "3"
}

type DockerContainer

type DockerContainer struct {
	// Name used by the container.
	Name string `json:"name"`

	// Image used by the container.
	Image string `json:"image"`

	// DockerArgs defines command line arguments for "docker run".
	DockerArgs string `json:"docker_args"`

	// EnvFile defines an env file (from file manager) to be used inside container.
	EnvFile string `json:"env_file"`

	// Command to be executed in the container.
	Command string `json:"command"`
}

DockerContainer defines a docker container instance.

type DockerContainers

type DockerContainers struct {
	Metadata

	// Containers to be running in the system.
	Containers []DockerContainer `json:"items,omitempty"`

	// RegistryAuths contains credentials to private docker registries.
	RegistryAuths []RegistryAuth `json:"registry_auths,omitempty"`
}

DockerContainers controls docker containers running in the system.

Example payload:

{
	"items": [
	  {
     "name": "container-a",
     "image": "debian:stable",
     "docker_args": "-v /path/to/data-volume:/data --hostname my-hostname",
     "env_file": "/my-directory/my-envfile",
     "command": "echo 'hello world!'"
	  }
	],
 "registry_auths": [
   {
      "server": "gcr.io",
      "username": "user",
      "password": "seCre7"
   }
 ]
}

type EntityConfigScope added in v1.2024.8

type EntityConfigScope string

EntityConfigScope is used to distinguish between different scopes of config.

const (
	// EntityConfigScopeAll returns final calculated config (incl. ancestors and tags)
	EntityConfigScopeAll EntityConfigScope = "all"

	// EntityConfigScopeOwn returns only config for the entity itself (no ancestors or tags)
	EntityConfigScopeOwn EntityConfigScope = "own"
)

type EntityType added in v1.2024.8

type EntityType string

EntityType is used to distinguish between node and tag config.

const (
	// EntityTypeNode represents a node entity.
	EntityTypeNode EntityType = "node"

	// EntityTypeTag represents a tag entity.
	EntityTypeTag EntityType = "tag"
)

type File

type File struct {
	// Source full file path from the file manager.
	Source string `json:"source,omitempty"`

	// Destination defines absolute path of the file in the filesystem.
	Destination string `json:"destination,omitempty"`

	// IsTemplate defines whether the file should be processed by the templating engine.
	IsTemplate bool `json:"is_template"`
}

File defines a single file parameters.

type FileDistribution

type FileDistribution struct {
	Metadata

	FileSets []FileSet `json:"files,omitempty"`
}

FileDistribution controls files in the system.

Example payload:

{
 "files": [
   {
     "pre_condition": "/tmp/test.sh",
     "templates": [
       {
         "source": "demo_file.json",
         "destination": "/tmp/demo_file.json",
         "is_template": true
       }
     ],
     "parameters": [
       {
         "key": "VAR1",
         "value": "VAL1"
       }
     ],
     "command": "echo \"it worked!\""
   }
 ]
}

type FileSet

type FileSet struct {
	// Files defines files to be created in the filesystem.
	Files []File `json:"templates,omitempty"`

	// Parameters define values to be used for template files.
	TemplateParameters []TemplateParameter `json:"parameters,omitempty"`

	// AfterCommand defines a command to be executed after files are saved on the filesystem.
	AfterCommand string `json:"command,omitempty"`

	// PreCondition defines an optional command which needs to return 0 in order for the FileSet to be executed.
	PreCondition string `json:"pre_condition,omitempty"`
}

FileSet defines a file set to be maintained in the system.

type Firewall

type Firewall struct {
	Metadata

	// Tables defines a map of firewall tables to be modified.
	Tables map[FirewallTableName]FirewallTable `json:"tables,omitempty"`
}

Firewall configures system firewall.

Example payload:

{
 "tables": {
   "filter": {
     "INPUT": {
       "policy": "ACCEPT",
       "rules": [
         {
           "srcIp": "192.168.1.1",
           "dstPort": "80",
           "proto": "tcp",
           "target": "ACCEPT"
         }
       ]
     }
   }
 }
}

type FirewallChain

type FirewallChain struct {
	// Policy defines a default policy (if no rule can be matched).
	Policy Target `json:"policy"`

	// Rules defines a list of firewall rules for a chain.
	Rules []FirewallRule `json:"rules,omitempty"`
}

FirewallChain contains rules definition for a firewall chain.

type FirewallChainName

type FirewallChainName string

FirewallChainName defines firewall table's chain name.

const Input FirewallChainName = "INPUT"

Input defines INPUT chain name.

type FirewallRule

type FirewallRule struct {
	// SourceIP matches packets by source IP.
	SourceIP string `json:"srcIp"`

	// DestinationPort matches packets by destination port.
	DestinationPort string `json:"dstPort"`

	// Protocol matches packets by network protocol.
	Protocol Protocol `json:"proto"`

	// Target defines what to do extender a packet when matched.
	Target Target `json:"target"`
}

FirewallRule defines a single firewall rule.

type FirewallTable

type FirewallTable map[FirewallChainName]FirewallChain

FirewallTable defines chains configuration for a firewall table.

type FirewallTableName

type FirewallTableName string

FirewallTableName defines which firewall table name.

const Filter FirewallTableName = "filter"

Filter defines filter table name.

type Metadata

type Metadata struct {
	// Enabled indicates whether the bundle is enabled.
	Enabled bool `json:"enabled"`

	// Extend indicates whether the bundle extends the configuration of its parent.
	Extend bool `json:"extend,omitempty"`

	// Version is the version of the bundle.
	// Currently, it's always set to v1.
	Version string `json:"version,omitempty"`

	// CommitID is the commit ID of the bundle.
	// This field is populated by the API.
	CommitID string `json:"bundle_commit_id,omitempty"`

	// Inherited indicates whether the bundle inherits from its parent.
	// DEPRECATED: This field is only used for backwards compatibility.
	Inherited bool `json:"inherited,omitempty"`

	// Inherits contains the complete inheritance information.
	// It starts with the node from which the bundle is inherited,
	// and ends with the node ID for which the configuration is rendered.
	// DEPRECATED: This field is only used for backwards compatibility.
	Inherits Ancestors `json:"inherits,omitempty"`

	// Reset instructs the system to reset the bundle configuration.
	Reset bool `json:"reset_to_group,omitempty"`
}

Metadata for a configuration bundle.

type NTP

type NTP struct {
	Metadata

	Servers []string `json:"servers,omitempty"`
}

NTP configures NTP servers.

Example payload:

{
  "servers": [
   "pool1.ntp.org"
 ]
}

DEPRECATED: use file distribution or software management to configure NTP instead.

type Package

type Package struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

Package defines a package to be maintained in the system.

type PackageManagement

type PackageManagement struct {
	Metadata

	// PreCondition if set will be executed before package maintenance.
	// If the command returns a non-zero exit code, the package maintenance will be skipped.
	PreCondition string `json:"pre_condition,omitempty"`

	// RebootMode defines whether system should be rebooted after package maintenance or not.
	RebootMode RebootMode `json:"reboot_mode"`

	// FullUpgrade if set to true will perform a full system upgrade.
	FullUpgrade bool `json:"full_upgrade"`

	// Packages defines a list of packages to be maintained.
	Packages []Package `json:"items,omitempty"`
}

PackageManagement controls system packages.

Example payload:

{
 "pre_condition": "test command",
 "items": [
   {
     "name": "httpd2",
     "version": "1.2.3"
   }
 ],
 "reboot_mode": "always",
 "full_upgrade": false
}

type Parameter

type Parameter struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Parameter defines a key/value pair.

type Parameters

type Parameters struct {
	Metadata

	// Parameters is a list of key/value pairs.
	Parameters []Parameter `json:"parameters,omitempty"`

	// Secrets is a list of key/value pairs where value is write-only.
	// After being set, the API returns a secret reference instead of the actual value.
	// Setting a new value for the same key will invalidate the previous secret reference.
	// Secret values are redacted from audit and device logs.
	Secrets []Parameter `json:"secrets,omitempty"`
}

Parameters sets global configuration parameters.

Example payload:

	{
	 "parameters": [
	   {
	     "key": "placeholder",
	     "value": "value"
	   }
	 ],
  "secrets": [
    {
      "key": "placeholder",
      "value": "value"
	  }
	 ]
	}

type Password

type Password struct {
	Metadata

	Users []UserPassword `json:"users,omitempty"`
}

Password bundle sets passwords for existing users.

Example payload:

{
 "users": [
   {
     "username": "piotr",
     "passwordhash": "$6$EMNbdq1ZkOAZSpFt$t6Ei4J11Ybip1A51sbBPTtQEVcFPPPUs.Q9nle4FenvrId4fLr8douwE3lbgWZGK.LIPeVmmFrTxYJ0QoYkFT."
   }
 ]
}

type ProcessPolicy

type ProcessPolicy string

ProcessPolicy defines a policy for a process.

const (
	// ProcessPresent ensures that the process is running.
	ProcessPresent ProcessPolicy = "Present"

	// ProcessAbsent ensures that the process is not running.
	ProcessAbsent ProcessPolicy = "Absent"
)

type ProcessWatch

type ProcessWatch struct {
	Metadata

	// Processes to watch.
	Processes []ProcessWatcher `json:"processes,omitempty"`
}

ProcessWatch ensures running process are running (or not).

Example payload:

{
  "processes": [
   {
     "name": "presentProcess",
     "policy": "Present",
     "command": "start.sh"
   },
   {
     "name": "absentProcess",
     "policy": "Absent",
     "command": "stop.sh"
   }
 ]
}

type ProcessWatcher

type ProcessWatcher struct {
	// Name of the process to watch.
	Name string `json:"name,omitempty"`

	// Policy for the process.
	Policy ProcessPolicy `json:"policy,omitempty"`

	// Command to use to get the process in the expected state.
	// For:
	// - ProcessPresent it should be a start command,
	// - ProcessAbsent it should be a stop command.
	Command string `json:"command,omitempty"`
}

ProcessWatcher defines a watcher for a process.

type Protocol

type Protocol string

Protocol defines network protocol in use.

const (
	TCP  Protocol = "tcp"
	UDP  Protocol = "udp"
	ICMP Protocol = "icmp"
)

Network protocols supported by the firewall.

type Pushed

type Pushed struct {
	// CommitID represents commit ID of the mose recent commit affecting the device.
	CommitID string `json:"commit_id"`

	// Bundles contains a list of strings representing configuration bundles
	Bundles BundleNames `json:"bundles"`

	// BundleData contain configuration data for bundles in the Bundles list
	BundleData BundleData `json:"bundle_data"`
}

Pushed is a struct that represents the pushed configuration.

type Rauc added in v1.2024.8

type Rauc struct {
	Metadata

	// PreCondition defines an optional command which needs to return 0 in order for RAUC bundle to be installed.
	PreCondition string `json:"pre_condition,omitempty"`

	// RaucBundle defines the rauc bundle to be installed.
	RaucBundle string `json:"rauc_bundle"`
}

Rauc configures an A/B system update using RAUC.

example payload

{
  "pre_condition": "true",
  "rauc_bundle": "/path/to/bundle.raucb",
}

type RebootMode

type RebootMode string

RebootMode defines whether system should be rebooted after package maintenance or not.

const (
	RebootNever  RebootMode = "never"
	RebootAlways RebootMode = "always"
)

Supported reboot modes.

type RegistryAuth

type RegistryAuth struct {
	// Server hostname of the registry.
	Server string `json:"server"`

	// Username for the registry.
	Username string `json:"username"`

	// Password for the Username.
	Password string `json:"password"`
}

RegistryAuth defines credentials for docker registry authentication.

type SSHKey

type SSHKey struct {
	// Username of the user for which the SSH key is added.
	Username string `json:"username"`

	// UserKeys are SSH keys to be added to the user.
	Keys []string `json:"userkeys"`
}

SSHKey defines an SSH key to be added to a user.

type SSHKeys

type SSHKeys struct {
	Metadata

	// Users to add or remove SSH keys for.
	Users []SSHKey `json:"users,omitempty"`
}

SSHKeys adds or removes authorized SSH keys for users.

Example payload:

{
 "users": [
   {
     "username": "test",
     "userkeys": [
       "key1",
       "key2"
     ]
   }
 ]
}

type Settings

type Settings struct {
	Metadata

	// Metrics collection enabled.
	Metrics bool `json:"metrics"`

	// Reports collection enabled.
	Reports bool `json:"reports"`

	// RemoteConsole access enabled.
	RemoteConsole bool `json:"remoteconsole"`

	// SoftwareInventory collection enabled.
	SoftwareInventory bool `json:"software_inventory"`

	// ProcessInventory collection enabled.
	ProcessInventory bool `json:"process_inventory"`

	// AgentInterval defines how often agent reports back to the device hub (in minutes).
	AgentInterval int `json:"agentinterval"`
}

Settings defines agent settings.

Example payload:

"settings": {
  "metrics": true,
  "reports": true,
  "remoteconsole": true,
  "software_inventory": true,
  "process_inventory": true,
  "agentinterval": 10
}

type SoftwareManagement

type SoftwareManagement struct {
	Metadata

	// Items to be installed.
	Items []SoftwarePackage `json:"items,omitempty"`
}

SoftwareManagement controls software in the system.

Example payload:

{
 "items": [
   {
     "package": "pkg1",
     "service_name": "serviceName",
     "config_files": [
       {
         "config_template": "configFileTemplate",
         "config_location": "configFileLocation"
       }
     ],
     "parameters": [
       {
         "key": "configKey",
         "value": "configValue"
       }
     ]
   }
 ]
}

type SoftwarePackage

type SoftwarePackage struct {
	// Package defines a package name to install.
	Package string `json:"package,omitempty"`

	// ServiceName defines an optional service name (if empty, Package is used).
	ServiceName string `json:"service_name,omitempty"`

	// PreCondition defines an optional command which needs to return 0 in order for the SoftwarePackage to be installed.
	PreCondition string `json:"pre_condition,omitempty"`

	// ConfigFiles to be created for the software.
	ConfigFiles []ConfigurationFile `json:"config_files,omitempty"`

	// Parameters for the ConfigFiles templating.
	Parameters []ConfigurationFileParameter `json:"parameters,omitempty"`
}

SoftwarePackage defines software package to be maintained in the system.

type Target

type Target string

Target defines what to do extender matching packets.

const (
	Accept Target = "ACCEPT"
	Drop   Target = "DROP"
	Reject Target = "REJECT"
)

Targets supported by the firewall.

type TemplateParameter

type TemplateParameter struct {
	// Key of the parameter used in files.
	Key string `json:"key,omitempty"`

	// Value of the parameter which will replace Key placeholders.
	Value string `json:"value,omitempty"`
}

TemplateParameter defines a single parameter used to replace placeholder in a template.

type User

type User struct {
	// Username of the user to be added or removed.
	Username string `json:"username"`

	// Action defines what to do with the user.
	Action UserAction `json:"action"`
}

User defines a user to be modified in the system.

type UserAction

type UserAction string

UserAction defines what to do with a user.

const (
	UserAdd    UserAction = "add"
	UserRemove UserAction = "remove"
)

Supported user actions.

type UserPassword

type UserPassword struct {
	// Username of the user for which the password hash is set.
	Username string `json:"username"`

	// PasswordHash is a password hash for the user.
	// See https://qbee.io/docs/qbee-password.html for more information.
	PasswordHash string `json:"passwordhash"`
}

UserPassword defines a user and password hash.

type Users

type Users struct {
	Metadata

	// Users is a list of users to be added or removed.
	Users []User `json:"items,omitempty"`
}

Users adds or removes users.

Example payload:

{
 "items": [
   {
     "username": "test",
     "action": "remove"
   }
 ]
}

Jump to

Keyboard shortcuts

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