Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from AkihiroSuda/dev
Browse files Browse the repository at this point in the history
update CNI library to v1.0.1, Go to v1.17
  • Loading branch information
AkihiroSuda authored Sep 27, 2021
2 parents 30b5a60 + 34e1ae3 commit a703d96
Show file tree
Hide file tree
Showing 7 changed files with 905 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.17.x
- uses: actions/checkout@v2
- name: "Compile binaries"
run: make artifacts
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.17.x
- uses: actions/checkout@v2
with:
fetch-depth: 1
Expand All @@ -40,7 +40,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.17.x
- uses: actions/checkout@v2
with:
fetch-depth: 1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This plugin is mostly expected to be used by the following projects:
- BuildKit
- [Podman](https://github.com/containers/podman/issues/5805)

This plugin is being proposed to the CNI upstream: https://github.com/containernetworking/plugins/issues/573
This plugin is being proposed to be merged into the CNI upstream `firewall` plugin: https://github.com/containernetworking/plugins/pull/584

## Install

Expand Down
24 changes: 18 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
module github.com/AkihiroSuda/cni-isolation

go 1.15
go 1.17

require (
github.com/containernetworking/cni v0.8.0
github.com/containernetworking/plugins v0.9.0
github.com/coreos/go-iptables v0.4.5
github.com/onsi/ginkgo v1.12.1
github.com/onsi/gomega v1.10.3
github.com/containernetworking/cni v1.0.1
github.com/containernetworking/plugins v1.0.1
github.com/coreos/go-iptables v0.6.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.16.0
)

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5 // indirect
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 // indirect
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
894 changes: 875 additions & 19 deletions go.sum

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions plugins/meta/isolation/isolation_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"strings"

"github.com/containernetworking/cni/libcni"
"github.com/containernetworking/cni/pkg/types/current"
types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/plugins/pkg/ns"
"github.com/containernetworking/plugins/pkg/testutils"
. "github.com/onsi/ginkgo"
Expand Down Expand Up @@ -120,7 +120,7 @@ var _ = Describe("isolation integration tests", func() {

Describe("Testing with network foo and bar", func() {
It("should isolate foo from bar", func() {
var results [nsCount]*current.Result
var results [nsCount]*types100.Result
for i := 0; i < nsCount; i++ {
runtimeConfig := libcni.RuntimeConf{
ContainerID: fmt.Sprintf("test-cni-isolation-%d", i),
Expand Down Expand Up @@ -154,7 +154,7 @@ var _ = Describe("isolation integration tests", func() {
// nolint: errcheck
defer deleteNetwork()

results[i], err = current.NewResultFromResult(res)
results[i], err = types100.NewResultFromResult(res)
Expect(err).NotTo(HaveOccurred())
fmt.Fprintf(GinkgoWriter, "results[%d]: %+v\n", i, results[i])
}
Expand All @@ -168,9 +168,8 @@ var _ = Describe("isolation integration tests", func() {

fmt.Fprintf(GinkgoWriter, "ping %s (ns%d@%s) -> %s (ns%d@%s)...",
saddr, src, srcNetName, daddr, dst, dstNetName)
v6 := results[dst].IPs[0].Version == "6"
timeoutSec := 1
if err := testutils.Ping(saddr, daddr, v6, timeoutSec); err != nil {
if err := testutils.Ping(saddr, daddr, timeoutSec); err != nil {
fmt.Fprintln(GinkgoWriter, "unpingable")
return err
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/meta/isolation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/containernetworking/cni/pkg/skel"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
types100 "github.com/containernetworking/cni/pkg/types/100"
"github.com/containernetworking/cni/pkg/version"
"github.com/coreos/go-iptables/iptables"

Expand All @@ -37,7 +37,7 @@ type PluginConf struct {

// Chained prev results
RawPrevResult *map[string]interface{} `json:"prevResult"`
PrevResult *current.Result `json:"-"`
PrevResult *types100.Result `json:"-"`

// Internal states
bridgeName string
Expand All @@ -61,7 +61,7 @@ func parseConfig(stdin []byte) (*PluginConf, error) {
return nil, fmt.Errorf("could not parse prevResult: %v", err)
}
conf.RawPrevResult = nil
conf.PrevResult, err = current.NewResultFromResult(res)
conf.PrevResult, err = types100.NewResultFromResult(res)
if err != nil {
return nil, fmt.Errorf("could not convert result to current version: %v", err)
}
Expand All @@ -86,7 +86,7 @@ func parseConfig(stdin []byte) (*PluginConf, error) {

func hasV6(conf *PluginConf) bool {
for _, f := range conf.PrevResult.IPs {
if f != nil && f.Version == "6" {
if f != nil && f.Address.IP.To4() == nil {
return true
}
}
Expand Down

0 comments on commit a703d96

Please sign in to comment.