Ejemplo n.º 1
0
func NewDatasource(root string) *configDrive {
	variablesMap, err := bashParser.UseShlex(root + "context.sh")
	if err != nil {
		log.Printf("Error during parsing script file.\n")
	}
	return &configDrive{root, ioutil.ReadFile, variablesMap, err}
}
Ejemplo n.º 2
0
func NewVariablesMap(fileName string) (map[string]string, error) {
	variablesMap, err := bashParser.UseShlex(fileName)
	if err != nil {
		log.Printf("Error during parsing script file.")
		return nil, err
	}

	return variablesMap, nil
}
func fetchVariableFromShellScript(fileName string, variableName string) (string, error) {
	variablesMap, err := bashParser.UseShlex(fileName)
	if err != nil {
		return "", err
	}
	ret := variablesMap[variableName]

	// checking and decoding base64
	if variableName == "USER_DATA" && variablesMap["USERDATA_ENCODING"] == "base64" {
		var err error
		ret, err = decodeBase64(ret)
		if err != nil {
			return "", err
		}
	}
	return ret, nil
}