| 1 |
From: Shengjing Zhu <[email protected]> |
| 2 |
Date: Sun, 10 Oct 2021 22:06:27 +0800 |
| 3 |
Subject: Add old interfaces |
| 4 |
|
| 5 |
Forwarded: not-needed |
| 6 |
--- |
| 7 |
pkg/types/020/deprecated.go | 3 +++ |
| 8 |
pkg/types/current/types.go | 31 +++++++++++++++++++++++++++++++ |
| 9 |
2 files changed, 34 insertions(+) |
| 10 |
create mode 100644 pkg/types/020/deprecated.go |
| 11 |
create mode 100644 pkg/types/current/types.go |
| 12 |
|
| 13 |
diff --git a/pkg/types/020/deprecated.go b/pkg/types/020/deprecated.go |
| 14 |
new file mode 100644 |
| 15 |
index 0000000..642b57b |
| 16 |
--- /dev/null |
| 17 |
+++ b/pkg/types/020/deprecated.go |
| 18 |
@@ -0,0 +1,3 @@ |
| 19 |
+package types020 |
| 20 |
+ |
| 21 |
+var SupportedVersions = supportedVersions |
| 22 |
diff --git a/pkg/types/current/types.go b/pkg/types/current/types.go |
| 23 |
new file mode 100644 |
| 24 |
index 0000000..0611e3a |
| 25 |
--- /dev/null |
| 26 |
+++ b/pkg/types/current/types.go |
| 27 |
@@ -0,0 +1,31 @@ |
| 28 |
+package current |
| 29 |
+ |
| 30 |
+import ( |
| 31 |
+ "github.com/containernetworking/cni/pkg/types" |
| 32 |
+ types020 "github.com/containernetworking/cni/pkg/types/020" |
| 33 |
+ types040 "github.com/containernetworking/cni/pkg/types/040" |
| 34 |
+) |
| 35 |
+ |
| 36 |
+const ImplementedSpecVersion = types040.ImplementedSpecVersion |
| 37 |
+ |
| 38 |
+var ( |
| 39 |
+ NewResult = types040.NewResult |
| 40 |
+ GetResult = types040.GetResult |
| 41 |
+ Int = types040.Int |
| 42 |
+) |
| 43 |
+ |
| 44 |
+type ( |
| 45 |
+ Result = types040.Result |
| 46 |
+ Interface = types040.Interface |
| 47 |
+ IPConfig = types040.IPConfig |
| 48 |
+) |
| 49 |
+ |
| 50 |
+func NewResultFromResult(result types.Result) (*Result, error) { |
| 51 |
+ if result.Version() == "" { |
| 52 |
+ switch r := result.(type) { |
| 53 |
+ case *types020.Result: |
| 54 |
+ r.CNIVersion = "0.1.0" |
| 55 |
+ } |
| 56 |
+ } |
| 57 |
+ return types040.NewResultFromResult(result) |
| 58 |
+} |