refactor: unify property function implementations

Rather than reimplementing the property functions in two different languages - and potentially having compatibility issues - standardize on golang for the implementation through the use of a generated binary.

This also implements all the list functions for use with shell-based plugins.

Note that the interface to the prop binary is experimental, and it should not be used directly.
This commit is contained in:
Jose Diaz-Gonzalez
2019-11-27 16:35:52 -05:00
parent 72d480c9dd
commit 4d9e8f5f7d
6 changed files with 328 additions and 103 deletions

View File

@@ -262,6 +262,15 @@ func MustGetEnv(key string) (val string) {
return
}
// GetenvWithDefault returns env variable or defaultValue if it's not set
func GetenvWithDefault(key string, defaultValue string) (val string) {
val = os.Getenv(key)
if val == "" {
val = defaultValue
}
return
}
// ReadFirstLine gets the first line of a file that has contents and returns it
// if there are no contents, an empty string is returned
// will also return an empty string if the file does not exist