Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeZappa87 committed Apr 5, 2024
1 parent 2ada8bb commit d2e28fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
7 changes: 2 additions & 5 deletions cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (c *libcni) Status() error {
plugin := plug.Network.Type

if !FileExistsInDir(dir, plugin) {
return ErrCNINotInitialized
return ErrCNIPluginNotFound
}
}
}
Expand Down Expand Up @@ -329,8 +329,5 @@ func (c *libcni) reset() {
func FileExistsInDir(directory, filename string) bool {
filePath := filepath.Join(directory, filename)
_, err := os.Stat(filePath)
if os.IsNotExist(err) {
return false
}
return true
return os.IsExist(err)
}
14 changes: 8 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (
)

var (
ErrCNINotInitialized = errors.New("cni plugin not initialized")
ErrInvalidConfig = errors.New("invalid cni config")
ErrNotFound = errors.New("not found")
ErrRead = errors.New("failed to read config file")
ErrInvalidResult = errors.New("invalid result")
ErrLoad = errors.New("failed to load cni config")
ErrCNINotInitialized = errors.New("cni plugin not initialized")
ErrInvalidConfig = errors.New("invalid cni config")
ErrNotFound = errors.New("not found")
ErrRead = errors.New("failed to read config file")
ErrInvalidResult = errors.New("invalid result")
ErrLoad = errors.New("failed to load cni config")
ErrCNIPluginNotFound = errors.New("cni plugin not found")
ErrCNIPluginDirNotFound = errors.New("cni plugin directory not found")
)

// IsCNINotInitialized returns true if the error is due to cni config not being initialized
Expand Down

0 comments on commit d2e28fa

Please sign in to comment.