diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index af96603f..d77baf27 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -71,8 +71,9 @@ steps: # To use ${FC_TEST_DATA_PATH} as testdata/, all files in the original directory must be # copied to the new directory. - cp -r testdata/* ${FC_TEST_DATA_PATH} - # Install tc-redirect-tap. - - 'go get github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap' + # Install tc-redirect-tap and portmap + - go get github.com/awslabs/tc-redirect-tap/cmd/tc-redirect-tap + - go get github.com/containernetworking/plugins/plugins/meta/portmap # Copy vmlinux and root-drive.img. - ln -s /var/lib/fc-ci/vmlinux.bin ${FC_TEST_DATA_PATH}/vmlinux - ln -s /var/lib/fc-ci/rootfs.ext4 ${FC_TEST_DATA_PATH}/root-drive.img diff --git a/network.go b/network.go index 346704e9..aa060cd9 100644 --- a/network.go +++ b/network.go @@ -239,6 +239,13 @@ type CNIConfiguration struct { // configuration directory. NetworkConfig *libcni.NetworkConfigList + // CapabilityArgs (optional) is a dictionary of capability-specific + // data passed by the runtime to plugins as top-level keys in the + // 'runtimeConfig' dictionary of the plugin's stdin data. libcni + // will ensure that only keys in this map which match the capabilities + // of the plugin are passed to the plugin. + CapabilityArgs map[string]interface{} + // IfName (optional) corresponds to the CNI_IFNAME parameter as specified // in the CNI spec. It generally specifies the name of the interface to be // created by a CNI plugin being invoked. @@ -316,10 +323,11 @@ func (cniConf *CNIConfiguration) setDefaults() { func (cniConf CNIConfiguration) asCNIRuntimeConf() *libcni.RuntimeConf { return &libcni.RuntimeConf{ - ContainerID: cniConf.containerID, - NetNS: cniConf.netNSPath, - IfName: cniConf.IfName, - Args: cniConf.Args, + ContainerID: cniConf.containerID, + NetNS: cniConf.netNSPath, + IfName: cniConf.IfName, + Args: cniConf.Args, + CapabilityArgs: cniConf.CapabilityArgs, } } diff --git a/network_test.go b/network_test.go index cdff014a..0aadd73a 100644 --- a/network_test.go +++ b/network_test.go @@ -290,6 +290,10 @@ func testNetworkMachineCNI(t *testing.T, useConfFile bool) { }, { "type": "tc-redirect-tap" + }, + { + "type": "portmap", + "capabilities": {"portMappings": true} } ] }`, networkName) @@ -424,6 +428,15 @@ func newCNIMachine(t *testing.T, NetworkConfig: networkConf, IfName: ifName, VMIfName: "eth0", + CapabilityArgs: map[string]interface{}{ + "portMappings": []interface{}{ + map[string]interface{}{ + "hostPort": 8080, + "containerPort": 80, + "protocol": "tcp", + }, + }, + }, }, }}, VMID: vmID,