@@ -28,6 +28,7 @@ import (
28
28
"github.com/containers/podman/v5/pkg/inspect"
29
29
. "github.com/containers/podman/v5/test/utils"
30
30
"github.com/containers/podman/v5/utils"
31
+ "github.com/containers/storage/pkg/ioutils"
31
32
"github.com/containers/storage/pkg/lockfile"
32
33
"github.com/containers/storage/pkg/reexec"
33
34
"github.com/containers/storage/pkg/stringid"
@@ -1187,19 +1188,21 @@ func (p *PodmanTestIntegration) makeOptions(args []string, options PodmanExecOpt
1187
1188
}
1188
1189
1189
1190
func writeConf (conf []byte , confPath string ) {
1190
- if _ , err := os .Stat (filepath .Dir (confPath )); os .IsNotExist (err ) {
1191
- if err := os .MkdirAll (filepath .Dir (confPath ), 0o777 ); err != nil {
1192
- GinkgoWriter .Println (err )
1193
- }
1194
- }
1195
- if err := os .WriteFile (confPath , conf , 0o777 ); err != nil {
1196
- GinkgoWriter .Println (err )
1197
- }
1191
+ GinkgoHelper ()
1192
+ err := os .MkdirAll (filepath .Dir (confPath ), 0o755 )
1193
+ Expect (err ).ToNot (HaveOccurred ())
1194
+
1195
+ err = ioutils .AtomicWriteFile (confPath , conf , 0o644 )
1196
+ Expect (err ).ToNot (HaveOccurred ())
1198
1197
}
1199
1198
1200
1199
func removeConf (confPath string ) {
1201
- if err := os .Remove (confPath ); err != nil {
1202
- GinkgoWriter .Println (err )
1200
+ GinkgoHelper ()
1201
+ err := os .Remove (confPath )
1202
+ // Network remove test will remove the config and then this can fail.
1203
+ // If the config does not exists no reason to hard error here.
1204
+ if ! errors .Is (err , os .ErrNotExist ) {
1205
+ Expect (err ).ToNot (HaveOccurred ())
1203
1206
}
1204
1207
}
1205
1208
0 commit comments