Documentation ¶
Index ¶
- Constants
- func AtomicCopy(srcFilepath, targetDir, targetFilename string) error
- func AtomicWrite(path string, data []byte, mode os.FileMode) (err error)
- func Copy(srcFilepath, targetDir, targetFilename string) error
- func CreateFileWatcher(dir 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 interface{}) (plugin map[string]interface{}, err error)
- func GetPlugins(cniConfigMap map[string]interface{}) (plugins []interface{}, err error)
- func IsDirWriteable(dir string) error
- func MarshalCNIConfig(cniConfigMap map[string]interface{}) ([]byte, error)
- func ReadCNIConfigMap(path string) (map[string]interface{}, 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 ¶
Copies file by reading the file then writing atomically into the target directory
func AtomicWrite ¶
Write atomically by writing to a temporary file in the same directory then renaming
func CreateFileWatcher ¶
func CreateFileWatcher(dir string) (watcher *fsnotify.Watcher, fileModified chan bool, errChan chan error, err error)
Creates a file watcher that watches for any changes to the directory
func GetPlugin ¶
Given the raw plugin interface, return the plugin asserted as a map[string]interface{}
func GetPlugins ¶
Given an unmarshalled CNI config JSON map, return the plugin list asserted as a []interface{}
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 ¶
Marshal the CNI config map and append a new line
func ReadCNIConfigMap ¶
Read CNI config from file and return the unmarshalled JSON as a map
Types ¶
This section is empty.