Skip to content

Commit c307af7

Browse files
authored
commands/.../test/local: move an error check to correct location (#1111)
**Description of the change:** Move error check to correct location **Motivation for the change:** Check error correctly /cc @hasbro17
1 parent 5d00aec commit c307af7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

commands/operator-sdk/cmd/test/local.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,20 @@ func testLocalGoFunc(cmd *cobra.Command, args []string) error {
130130
tlConfig.namespacedManPath = file.Name()
131131
} else {
132132
file, err := ioutil.TempFile("", "empty.yaml")
133+
if err != nil {
134+
return fmt.Errorf("could not create empty manifest file: (%v)", err)
135+
}
133136
tlConfig.namespacedManPath = file.Name()
134137
emptyBytes := []byte{}
135138
if err := file.Chmod(os.FileMode(fileutil.DefaultFileMode)); err != nil {
136139
return fmt.Errorf("could not chown temporary namespaced manifest file: (%v)", err)
137140
}
138141
if _, err := file.Write(emptyBytes); err != nil {
139-
return fmt.Errorf("could not create temporary namespaced manifest file: (%v)", err)
142+
return fmt.Errorf("could not write temporary namespaced manifest file: (%v)", err)
140143
}
141144
if err := file.Close(); err != nil {
142145
return err
143146
}
144-
if err != nil {
145-
return fmt.Errorf("could not create empty manifest file: (%v)", err)
146-
}
147147
}
148148
defer func() {
149149
err := os.Remove(tlConfig.namespacedManPath)

0 commit comments

Comments
 (0)