Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libcni/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (

var (
CacheDir = "/var/lib/cni"
// slightly awkward wording to preserve anyone matching on error strings
ErrorCheckNotSupp = fmt.Errorf("does not support the CHECK command")
)

const (
Expand Down Expand Up @@ -453,7 +455,7 @@ func (c *CNIConfig) CheckNetworkList(ctx context.Context, list *NetworkConfigLis
if gtet, err := version.GreaterThanOrEqualTo(list.CNIVersion, "0.4.0"); err != nil {
return err
} else if !gtet {
return fmt.Errorf("configuration version %q does not support the CHECK command", list.CNIVersion)
return fmt.Errorf("configuration version %q %w", list.CNIVersion, ErrorCheckNotSupp)
}

if list.DisableCheck {
Expand Down Expand Up @@ -547,7 +549,7 @@ func (c *CNIConfig) CheckNetwork(ctx context.Context, net *NetworkConfig, rt *Ru
if gtet, err := version.GreaterThanOrEqualTo(net.Network.CNIVersion, "0.4.0"); err != nil {
return err
} else if !gtet {
return fmt.Errorf("configuration version %q does not support the CHECK command", net.Network.CNIVersion)
return fmt.Errorf("configuration version %q %w", net.Network.CNIVersion, ErrorCheckNotSupp)
}

cachedResult, err := c.getCachedResult(net.Network.Name, net.Network.CNIVersion, rt)
Expand Down
1 change: 1 addition & 0 deletions libcni/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,7 @@ var _ = Describe("Invoking plugins", func() {
Expect(err).NotTo(HaveOccurred())
err = cniConfig.CheckNetworkList(ctx, netConfigList, runtimeConfig)
Expect(err).To(MatchError("configuration version \"0.3.1\" does not support the CHECK command"))
Expect(errors.Is(err, libcni.ErrorCheckNotSupp)).To(BeTrue())
})
})
})
Expand Down