kubetestgen: improve errors handling
- don't proceed when a file creation has been failed - handle a possible error from WriteString()
This commit is contained in:
parent
e7eed1ad2c
commit
02885845ff
@ -131,6 +131,7 @@ func printYAML(fileName string, areaO Area) {
|
|||||||
f, err := os.Create(fileName + ".yaml")
|
f, err := os.Create(fileName + ".yaml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: %s\n", err.Error())
|
fmt.Printf("ERROR: %s\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
y, err := yaml.Marshal(areaO)
|
y, err := yaml.Marshal(areaO)
|
||||||
@ -139,7 +140,11 @@ func printYAML(fileName string, areaO Area) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.WriteString(string(y))
|
_, err = f.WriteString(string(y))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("ERROR: %s\n", err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func countFields(suites []Suite) {
|
func countFields(suites []Suite) {
|
||||||
|
Loading…
Reference in New Issue
Block a user