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} }
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 }