Fix several bugs related to format specifiers

This commit is contained in:
Ian Howell 2018-12-07 09:08:59 -06:00
parent 41409ff2f4
commit 6ea57febc5
4 changed files with 8 additions and 12 deletions

View File

@ -33,17 +33,10 @@ var hostname string
// var testClient cli.ClientInterface
func init() {
var err error
testConfigContents = fmt.Sprintf(testConfigContentsFormat, "{{ .HOSTNAME }}")
testTemplatePath = fmt.Sprintf("%s/%s/%s", templatePrefix, testConfigName, testConfigName)
testConfigPath = fmt.Sprintf("%s/%s", testDir, testConfigName)
hostname, err = os.Hostname()
if err != nil {
fmt.Errorf("Could not get hostname", err)
}
}
func setupOsEnvironment() (err error) {
@ -123,6 +116,9 @@ var _ = Describe("Config", func() {
result, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", testDir, testConfigName))
Expect(err).NotTo(HaveOccurred())
hostname, err := os.Hostname()
Expect(err).NotTo(HaveOccurred())
expectedFile := fmt.Sprintf(testConfigContentsFormat, hostname)
readConfig := string(result[:])

View File

@ -18,7 +18,7 @@ func Execute(command []string) (err error) {
env := os.Environ()
err = syscall.Exec(path, command, env)
if err != nil {
logger.Error.Print("Executing command %v failed: %v", command, err)
logger.Error.Printf("Executing command %v failed: %v", command, err)
return
}
return

6
util/env/env.go vendored
View File

@ -58,7 +58,7 @@ func SplitEnvToDeps(env string) (envList []Dependency) {
continue
}
if nameAfterSplit[0] == "" {
logger.Warning.Printf("Invalid format, missing namespace", envVar)
logger.Warning.Printf("Invalid format, missing namespace %s", envVar)
continue
}
@ -88,7 +88,7 @@ func SplitPodEnvToDeps(env string) []PodDependency {
err := json.Unmarshal([]byte(e), &deps)
if err != nil {
logger.Warning.Printf("Invalid format: ", e)
logger.Warning.Printf("Invalid format: %v", e)
return []PodDependency{}
}
@ -116,7 +116,7 @@ func SplitJobEnvToDeps(env string, jsonEnv string) []JobDependency {
}
err := json.Unmarshal([]byte(jsonEnvVal), &deps)
if err != nil {
logger.Warning.Printf("Invalid format: ", jsonEnvVal)
logger.Warning.Printf("Invalid format: %s", jsonEnvVal)
return []JobDependency{}
}

View File

@ -28,7 +28,7 @@ func TestSplitEnvToListWithColon(t *testing.T) {
t.Errorf("Expected: not nil")
}
if len(list1) != 1 {
t.Errorf("Expected len to be 1 not %i", len(list1))
t.Errorf("Expected len to be 1 not %d", len(list1))
}
if list1[0].Name != "foo1" {
t.Errorf("Expected: foo1 got %s", list1[0])