Documentation ¶
Overview ¶
Package util provides generic utility routines used within FSM CNI Plugin.
Index ¶
- Constants
- func AtomicCopy(srcFilepath, targetDir, targetFilename string) error
- func AtomicWrite(path string, data []byte, mode os.FileMode) (err error)
- func CreateFileWatcher(dirs ...string) (watcher *fsnotify.Watcher, fileModified chan bool, errChan chan error, ...)
- func DirEquals(a, b string) (bool, error)
- func Exists(name string) bool
- func GetPlugin(rawPlugin any) (plugin map[string]any, err error)
- func GetPlugins(cniConfigMap map[string]any) (plugins []any, err error)
- func IP2Pointer(ipstr string) (unsafe.Pointer, error)
- func Inode(path string) (uint64, error)
- func IsDirWriteable(dir string) error
- func MarshalCNIConfig(cniConfigMap map[string]any) ([]byte, error)
- func WaitForFileMod(ctx context.Context, fileModified chan bool, errChan chan error) error
Constants ¶
const (
// PrivateFileMode grants owner to read/write a file.
PrivateFileMode = 0o600
)
Variables ¶
This section is empty.
Functions ¶
func AtomicCopy ¶
AtomicCopy copies file by reading the file then writing atomically into the target directory
func AtomicWrite ¶
AtomicWrite atomically by writing to a temporary file in the same directory then renaming
func CreateFileWatcher ¶
func CreateFileWatcher(dirs ...string) (watcher *fsnotify.Watcher, fileModified chan bool, errChan chan error, err error)
CreateFileWatcher creates a file watcher that watches for any changes to the directory
func GetPlugin ¶
GetPlugin given the raw plugin interface, return the plugin asserted as a map[string]interface{}
func GetPlugins ¶
GetPlugins given an unmarshalled CNI config JSON map, return the plugin list asserted as a []interface{}
func IP2Pointer ¶
IP2Pointer returns the pointer of a ip string
func IsDirWriteable ¶
IsDirWriteable checks if dir is writable by writing and removing a file to dir. It returns nil if dir is writable. Inspired by etcd fileutil.
func MarshalCNIConfig ¶
MarshalCNIConfig marshal the CNI config map and append a new line
Types ¶
This section is empty.