receiver

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package receiver handles secure file receicing and validation for the nstance-agent.

Index

Constants

This section is empty.

Variables

View Source
var DefaultValidators = map[string]ValidatorFunc{
	".env":  validateEnvFile,
	".crt":  validatePEMCertificate,
	".pub":  validatePEMPublicKey,
	".key":  validatePEMPrivateKey,
	".json": validateJSONFile,
}

DefaultValidators defines the default validation rules keyed by file extension (lowercase).

Functions

This section is empty.

Types

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver processes streamed files and writes them to disk.

func NewReceiver

func NewReceiver(logger *slog.Logger, cfg ReceiverConfig) *Receiver

func (*Receiver) ReceiveConfigHash

func (r *Receiver) ReceiveConfigHash(configHash string) error

ReceiveConfigHash updates the config.hash file in the identity directory

func (*Receiver) ReceiveFiles

func (r *Receiver) ReceiveFiles(payload map[string][]byte) error

ReceiveFiles processes a map of filenames to file data, validates the file contents based on the filename extension (e.g. `.crt`), and writes each file to the receive directory.

type ReceiverConfig

type ReceiverConfig struct {
	RecvDir     string
	IdentityDir string      // Path to identity directory for writing config.hash
	FileMode    os.FileMode // permissions used when writing files; default 0640.
}

ReceiverConfig holds runtime options for the file receiver.

type ValidatorFunc

type ValidatorFunc func(filename string, content []byte) error

ValidatorFunc validates a received file's contents.

Jump to

Keyboard shortcuts

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