util

package
v0.0.0-...-3479ee1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEnvironmentFile

func AppendEnvironmentFile(filePath string, kv []KeyValuePair, perm os.FileMode) (bool, error)

AppendEnvironmentFile ensures that all given key-value pairs are up to date in the given file. If the file does not exist, it is created. Returns: true if the file is created or updated, false otherwise.

func EnsureDirectory

func EnsureDirectory(dirPath string, perm os.FileMode) error

EnsureDirectory checks if a directory with given path exists and if not creates it. If such a path does exist, it checks if it is a directory, if not an error is returned.

func EnsureDirectoryOf

func EnsureDirectoryOf(filePath string, perm os.FileMode) error

EnsureDirectoryOf checks if the directory of the given file path exists and if not creates it. If such a path does exist, it checks if it is a directory, if not an error is returned.

func UpdateFile

func UpdateFile(log *logging.Logger, filePath string, content []byte, perm os.FileMode) (bool, error)

UpdateFile compares the given content with the context of the file at the given filePath and if the content is different, the file is updated. If the file does not exist, it is created. Returns: true if the file is created or updated, false otherwise.

func WeaveNameFromMachineID

func WeaveNameFromMachineID(machineID string) (string, error)

WeaveNameFromMachineID converts a machine ID into a weave peer name.

Types

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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