Documentation
¶
Overview ¶
Package fileutil writes files the way a tool several administrators run at once has to: completely or not at all, and under a lock when the file is shared.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureDir ¶
EnsureDir creates a directory that only its owner can read, for state that holds host keys, control sockets and certificate pins.
func Lock ¶
Lock takes an exclusive lock for a path and returns the function that releases it. The lock lives in a sibling file, so that the locked file can still be replaced atomically.
func Update ¶
func Update(ctx context.Context, path string, perm os.FileMode, change func([]byte) ([]byte, error)) error
Update reads a file, hands its content to change and writes back whatever comes out, holding an exclusive lock for the whole cycle. A file that does not exist yet is presented as empty.
The known_hosts file is shared and versioned, and ssh appends to it without locking, so every write clusterctl makes to it goes through here.
Types ¶
This section is empty.