datarecv

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 43 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GroupPermissions holds the owner and the permissions of the files
	// and directories installed, and of the root of the head.
	GroupPermissions = keywords.Group{
		ID:    "permissions",
		Name:  "Owner and permissions",
		Text:  keywords.NewText(fs, "text/group/permissions"),
		Order: 44,
	}

	// GroupInstall holds the files and directories installed in the head,
	// and the signals sent when they change. It has the id, name and order
	// of the install group of the tasks.
	GroupInstall = keywords.Group{
		ID:    "install",
		Name:  "Install",
		Text:  keywords.NewText(fs, "text/group/install"),
		Order: 46,
	}

	// Groups are the groups the keywords Keywords returns name.
	Groups = []keywords.Group{
		GroupPermissions,
		GroupInstall,
	}
)

The groups of the keywords Keywords returns, declared once here and added by each driver installing files in its head, the filesystems and the volumes.

The install lines and the configs, secrets and directories keywords they replace are no strategies: an install installs all of them, in order.

Functions

func Environment

func Environment(items []string, namespace string, missing func(error) error) (env []string, secrets map[string]bool, err error)

Environment returns the variables of the items of an environment keyword, NAME=value, in the order they are written, so the last of a name wins, and the names of the ones read from a sec, whose values are secret. A datastore or a key not existing is passed to missing, which says whether it is an error, nil going on without it. A key generated, "source random", not existing is an error: the provision of the object generates it on its leader node, and a variable going without it, or a password made here, would differ from what the other nodes and the data hold.

func EnvironmentDatastores

func EnvironmentDatastores(items []string, namespace string) (naming.Paths, error)

EnvironmentDatastores returns the datastores the items of an environment keyword read, each once.

func EnvironmentHasLocalSource

func EnvironmentHasLocalSource(s string) bool

EnvironmentHasLocalSource reports whether an environment value names a source the server reads locally, as opposed to one it fetches over http or generates, as IsLocalSource tells.

A value the grammar refuses seeds nothing, as the resource refuses it at its action, but is judged all the same, every word following "source" taken for a source: what it means is not for the policy to guess.

func EnvironmentKeySources

func EnvironmentKeySources(value []string, namespace string) ([]keywords.KeySource, error)

EnvironmentKeySources returns the keys the references of an environment value seed from a source, the value evaluated, its relative datastore paths being of the namespace given.

func InstallKeySources

func InstallKeySources(value []string, namespace string) ([]keywords.KeySource, error)

InstallKeySources returns the keys the lines of an install value seed from a source, the value evaluated, its relative datastore paths being of the namespace given. A line installing from the datastores of a pattern seeds the key of each one matching, as its install does.

func InstalledDir

func InstalledDir(p naming.Path) string

InstalledDir returns the directory holding the install records of the resources of the instance of p, a file named after each resource.

func IsLocalSource

func IsLocalSource(s string) bool

IsLocalSource reports whether a source is read from the node: any source but "random", which is generated, and an http or https url, fetched.

It is the test the seeding runs to choose between a generation, a fetch and a local read, so a source it reads locally, as "http:///etc/x" with no host, is never taken for a fetch here, and /dev/urandom is a path.

func Keywords

func Keywords(prefix string) []*keywords.Keyword

func ModeHasSpecialBits

func ModeHasSpecialBits(s string) bool

ModeHasSpecialBits reports whether a perm or dirperm value asks for the setuid or the setgid bit.

A file installed in a volume with one of them, owned by an account of the node, runs as that account for whoever executes it: on the node, where the volume is mounted, or in a container mounting the volume.

func Pop

func Pop(words []string) (string, []string)

Pop returns "a", "b c d" from "a b c d". This function is used in a loop to iterate all words of a line until Pop returns "", "".

func SectionDatastores

func SectionDatastores(get func(option string) []string, namespace string) []string

SectionDatastores returns the datastores a resource section reads keys of, each once, by the values of its keywords get returns, as evaluated for a node: the install lines installing from one, the references of the environment keywords, and the deprecated configs, secrets and environment keywords reading a datastore. Their relative paths are of the namespace given.

A line naming its datastores by a pattern of their name, as "./sec/haproxy-*", is returned as that pattern: it reads the datastores matching it when it runs, a datastore made later as well.

The values are read from the configuration alone, whatever the state of the resource: what an object uses is what its configuration names, which a stopped instance starts with again.

func Split

func Split(text []string) [][]string

func TextHasLocalSource

func TextHasLocalSource(s string) bool

TextHasLocalSource reports whether an install text names a source the server reads locally, as opposed to one it fetches over http or generates.

It lives here, next to the grammar it parses, so the rbac policy that refuses a local source to a user holding no root grant does not have to reimplement that grammar and drift from it.

func TextHasSpecialMode

func TextHasSpecialMode(s string) bool

TextHasSpecialMode reports whether an install text asks for the setuid or the setgid bit on one of the files or directories it installs.

Such a mode is not applied today: the mode word is read as permission bits alone. It is refused anyway, so a mode that would be applied once the grammar honours the bits is not one a user holding no root grant has already written.

func ValidateInstall

func ValidateInstall(value string) error

ValidateInstall says whether the install lines of value are ones the install takes, as far as the lines naming datastores by a pattern go: their pattern, and the * of their destination, the files of the datastores having to be told apart. A line fetching its file from a url is held to fetchLineErr: an https url, a file, and no key nor template.

Types

type DataRecv

type DataRecv struct {
	// Install is the list of files or directories to install in the data receiver.
	Install []string `json:"install"`

	// User is the default owner user of the installed items.
	User string `json:"user"`

	// Group is the default owner group of the installed items.
	Group string `json:"group"`

	// Perm is the default permission of the installed files.
	Perm *os.FileMode `json:"perm"`

	// DirPerm is the default permission of the installed directories.
	// If not set, DirPerm defaults to Perm with execution bit over read bits (e.g. 0640 => 0750).
	DirPerm *os.FileMode `json:"dirperm"`

	// Deprecated by Install
	Configs     []string `json:"configs"`
	Secrets     []string `json:"secrets"`
	Directories []string `json:"directories"`
	Signal      string   `json:"signal"`
	// contains filtered or unexported fields
}

func (*DataRecv) DatastoreList

func (t *DataRecv) DatastoreList(_ context.Context) naming.Paths

DatastoreList returns the datastores the resource installs from, each once, in the order the install lines and references name them first: several lines installing from the same datastore name it once.

func (*DataRecv) Do

func (t *DataRecv) Do(ctx context.Context) error

func (*DataRecv) HasMetadata

func (t *DataRecv) HasMetadata(path naming.Path, k string) bool

HasMetadata returns true if the volume has a configs or secrets reference to <namespace>/<kind>/<name>[/<key>]

func (*DataRecv) InstallDataByKind

func (t *DataRecv) InstallDataByKind(kind naming.Kind) (bool, error)

func (*DataRecv) InstallFromDatastore

func (t *DataRecv) InstallFromDatastore(ctx context.Context, from object.DataStore) (bool, error)

InstallFromDatastore installs the keys of the datastore from, the refresh a write of it runs.

func (*DataRecv) OldSendSignals

func (t *DataRecv) OldSendSignals(ctx context.Context) error

func (*DataRecv) RootDirPerm

func (t *DataRecv) RootDirPerm() *os.FileMode

func (*DataRecv) RunInstall

func (t *DataRecv) RunInstall(ctx context.Context) error

RunInstall installs what the data receiver declares, as a start does, and logs what it leaves as it is too, and why: a directory in place, a file up to date, a key the store does not hold, a store that does not exist.

func (*DataRecv) SendSignals

func (t *DataRecv) SendSignals(ctx context.Context, signals *volsignal.T) error

func (*DataRecv) SetReceiver

func (t *DataRecv) SetReceiver(to receiver)

func (*DataRecv) Status

func (t *DataRecv) Status()

type EnvItem

type EnvItem struct {
	Literal string
	Name    string
	Ref     KeyMeta
}

EnvItem is an item of an environment keyword: a variable with its value, NAME=value, or a variable read from the key of a datastore, NAME from <path> key <key> [source <uri>]. A * in the name of a reference stands for the key: with a key pattern, it names a variable per key matching. The source seeds the key the datastore does not hold.

func ParseEnvironment

func ParseEnvironment(items []string, namespace string) ([]EnvItem, error)

ParseEnvironment parses the items of an environment keyword, as the shell lexer splits it, the relative paths of its references in the namespace.

A word followed by "from" starts a reference, which no literal does: a literal holds an "=", or is a bare name a container engine reads from its own environment.

A reference ends after its key, or after "source <uri>": so a bare name "source" right after a reference, followed by another item, is read as the source of the reference. It is written "source=" or moved before the reference to be a variable. A "source" followed by "from" is the name of the next reference, and one ending the list a bare name.

func (EnvItem) IsRef

func (t EnvItem) IsRef() bool

IsRef says the item reads a datastore.

func (EnvItem) Resolve

func (t EnvItem) Resolve() (env []string, secret bool, err error)

Resolve returns the variables of a reference, NAME=value, read from its datastore, which the namespace reading it is allowed to, and whether they are secret, read from a sec.

func (EnvItem) String

func (t EnvItem) String() string

String returns the item as written.

type ErrEnvSourceMissing

type ErrEnvSourceMissing struct {
	Path naming.Path
	Key  string
}

ErrEnvSourceMissing is a datastore or a key an environment item reads not existing, which a resource may run without.

func (ErrEnvSourceMissing) Error

func (t ErrEnvSourceMissing) Error() string

type Installed

type Installed struct {
	At    time.Time `json:"at"`
	Files []string  `json:"files"`
}

Installed is the record of the last install of a resource that wrote files: the daemon watching it tells the tasks reading them.

func ReadInstalled

func ReadInstalled(filename string) (Installed, error)

ReadInstalled returns the install record of the file filename.

type KeyMeta

type KeyMeta struct {
	Key        string
	Path       naming.Path
	From       string
	Source     string
	IsTemplate bool
}

func ParseKeyMetaRel

func ParseKeyMetaRel(line, namespace string) (KeyMeta, error)

func ParseKeyMetaRelObj

func ParseKeyMetaRelObj(line string, i any) (KeyMeta, error)

func ParseKeyMetaRelSelf

func ParseKeyMetaRelSelf(line string, self naming.Path) (KeyMeta, error)

ParseKeyMetaRelSelf is ParseKeyMetaRel for a reference in the configuration of self: "from ." names self, and a relative path is of the namespace of self.

func ParseKeyMetaRelWithFallback

func ParseKeyMetaRelWithFallback(line, namespace, defaultKey string) (KeyMeta, error)

ParseKeyMetaRelWithFallback parses a key reference in the format "from <path> key <key>" and falls back to the legacy format "<path>" with a default key name for backward compatibility.

func (*KeyMeta) CacheFile

func (t *KeyMeta) CacheFile() (string, error)

func (*KeyMeta) Decode

func (t *KeyMeta) Decode() ([]byte, error)

func (*KeyMeta) RootDecode

func (t *KeyMeta) RootDecode() ([]byte, error)

func (*KeyMeta) SourceIsRandom

func (t *KeyMeta) SourceIsRandom() bool

SourceIsRandom says the key is generated, "source random", rather than read from a source.

func (*KeyMeta) String

func (t *KeyMeta) String() string

type SigRoute

type SigRoute struct {
	Signum syscall.Signal
	RID    string
}

SigRoute is a relation between a signal number and the id of a resource supporting signaling

Jump to

Keyboard shortcuts

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