(e *CNIEnv, net *NetworkConfig)
| 60 | } |
| 61 | |
| 62 | func fsWrite(e *CNIEnv, net *NetworkConfig) error { |
| 63 | filename := getConfigPathForNetworkName(e, net.Name) |
| 64 | // FIXME: note that this is still problematic. |
| 65 | // Concurrent access may independently first figure out that a given network is missing, and while the lock |
| 66 | // here will prevent concurrent writes, one of the routines will fail. |
| 67 | // Consuming code MUST account for that scenario. |
| 68 | return filesystem.WithLock(filepath.Join(e.NetconfPath, ".nerdctl.lock"), func() error { |
| 69 | if _, err := os.Stat(filename); err == nil { |
| 70 | return errdefs.ErrAlreadyExists |
| 71 | } |
| 72 | return filesystem.WriteFile(filename, net.Bytes, 0644) |
| 73 | }) |
| 74 | } |
| 75 | |
| 76 | func fsRead(e *CNIEnv) ([]*NetworkConfig, error) { |
| 77 | var nc []*NetworkConfig |
no test coverage detected
searching dependent graphs…