utils

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 5 Imported by: 0 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

This section is empty.

Functions

func NowRFC3339

func NowRFC3339() string

NowRFC3339 returns the current UTC time formatted as RFC3339. All wire payloads (telemetry and command responses) use this format in their "ts" field, matching the other stone-age.io applications.

func Round

func Round(val float64) float64

Round rounds a float64 value to 2 decimal places Used throughout the agent for metrics to avoid unnecessary precision

func WriteFileAtomic added in v0.5.0

func WriteFileAtomic(path string, data []byte, perm os.FileMode) error

WriteFileAtomic writes data through a temp file in the same directory and renames it into place, so a crash mid-write cannot leave a truncated file.

What that protects is different for each caller, and every one of them matters: an agent that cannot parse its own .creds, platform session or Nebula cache does not come back on its own, and a nats-server handed a half-written nats-leaf.conf on reload or restart refuses it. The rename is what makes a reader see either the old file or the new one, never a mixture.

perm is applied to the temp file before anything is written to it, so the secrets (0600) are never readable by anyone else even for an instant. It is set with Chmod rather than at create time, so the umask does not get a vote: a 0644 config is 0644 on every box. os.CreateTemp alone opens 0600, which is what every caller wanted before the leaf config needed to be world-readable.

It used to be two identical unexported copies, in platform and in nebula, and both were 0600-only.

Types

This section is empty.

Jump to

Keyboard shortcuts

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