Skip to content

Commit

Permalink
libcni: handle empty version when parsing version
Browse files Browse the repository at this point in the history
Without this Delete failed for empty-version configs.

Update the tests to catch this case.

Signed-off-by: Casey Callendrello <cdc@redhat.com>
  • Loading branch information
squeed committed Apr 27, 2022
1 parent f32e3df commit 62ad6fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions libcni/backwards_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ var _ = Describe("Backwards compatibility", func() {

Expect(result).To(Equal(legacy_examples.ExpectedResult))

err = cniConfig.DelNetwork(context.TODO(), netConf, runtimeConf)
Expect(err).NotTo(HaveOccurred())

Expect(os.RemoveAll(pluginPath)).To(Succeed())
})

Expand Down
4 changes: 2 additions & 2 deletions pkg/version/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (*PluginDecoder) Decode(jsonBytes []byte) (PluginInfo, error) {
// minor, and micro numbers or returns an error
func ParseVersion(version string) (int, int, int, error) {
var major, minor, micro int
if version == "" {
return -1, -1, -1, fmt.Errorf("invalid version %q: the version is empty", version)
if version == "" { // special case: no version declared == v0.1.0
return 0, 1, 0, nil
}

parts := strings.Split(version, ".")
Expand Down

0 comments on commit 62ad6fb

Please sign in to comment.