refactor: replace bash hacks with custom templates (#34)

This commit is contained in:
Daniel Moran
2021-04-19 15:51:53 -04:00
committed by GitHub
parent 4f62e469e9
commit 079f707c21
9 changed files with 1323 additions and 57 deletions

View File

@ -1,5 +1,3 @@
//lint:file-ignore ST1005 Ignore capitalized errors, they're generated
/*
* Subset of Influx API covered by Influx CLI
*
@ -128,7 +126,7 @@ func (c *Configuration) AddDefaultHeader(key string, value string) {
// URL formats template on a index using given variables
func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) {
if index < 0 || len(sc) <= index {
return "", fmt.Errorf("Index %v out of range %v", index, len(sc)-1)
return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1)
}
server := sc[index]
url := server.URL
@ -143,7 +141,7 @@ func (sc ServerConfigurations) URL(index int, variables map[string]string) (stri
}
}
if !found {
return "", fmt.Errorf("The variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues)
}
url = strings.Replace(url, "{"+name+"}", value, -1)
} else {