-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Before this change, plugin version 1.0.0 was not being reported as supported after version 1.1.0 became the current version. Signed-off-by: Austin Vazquez <macedonv@amazon.com>
- Loading branch information
1 parent
2d4b7a9
commit a4df25e
Showing
3 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package internal | ||
|
||
import ( | ||
"github.com/containernetworking/cni/pkg/version" | ||
) | ||
|
||
func SupportedVersions() []string { | ||
// support CNI versions that support plugin chaining | ||
supported := []string{} | ||
unsupported := map[string]bool{"0.1.0": true, "0.2.0": true} | ||
|
||
for _, v := range version.All.SupportedVersions() { | ||
if _, ok := unsupported[v]; !ok { | ||
supported = append(supported, v) | ||
} | ||
} | ||
|
||
return supported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package internal | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSupportedVersions(t *testing.T) { | ||
supportedVersions := SupportedVersions() | ||
|
||
contains := func(arr []string, find string) bool { | ||
for _, i := range arr { | ||
if i == find { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
for _, v := range []string{"0.1.0", "0.2.0"} { | ||
if contains(supportedVersions, v) { | ||
t.Errorf("expected %s to not be a supported version", v) | ||
} | ||
} | ||
|
||
for _, v := range []string{"0.3.0", "0.3.1", "0.4.0", "1.0.0", "1.1.0"} { | ||
if !contains(supportedVersions, v) { | ||
t.Errorf("expected %s to be a supported version", v) | ||
} | ||
} | ||
} |