diff --git a/main.go b/main.go new file mode 100644 index 00000000..2dda38ae --- /dev/null +++ b/main.go @@ -0,0 +1,23 @@ +package main + +import ( + "os" + "path/filepath" + + "github.com/containernetworking/plugins/plugins/ipam/host-local" + "github.com/containernetworking/plugins/plugins/main/bridge" + "github.com/containernetworking/plugins/plugins/main/loopback" + "github.com/containernetworking/plugins/plugins/meta/flannel" + "github.com/containernetworking/plugins/plugins/meta/portmap" + "github.com/docker/docker/pkg/reexec" +) + +func main() { + os.Args[0] = filepath.Base(os.Args[0]) + reexec.Register("host-local", hostlocal.Main) + reexec.Register("bridge", bridge.Main) + reexec.Register("flannel", flannel.Main) + reexec.Register("loopback", loopback.Main) + reexec.Register("portmap", portmap.Main) + reexec.Init() +} diff --git a/plugins/ipam/host-local/dns.go b/plugins/ipam/host-local/dns.go index 1b3975a5..ab056ad8 100644 --- a/plugins/ipam/host-local/dns.go +++ b/plugins/ipam/host-local/dns.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package hostlocal import ( "bufio" diff --git a/plugins/ipam/host-local/dns_test.go b/plugins/ipam/host-local/dns_test.go index 1b870026..837c7d44 100644 --- a/plugins/ipam/host-local/dns_test.go +++ b/plugins/ipam/host-local/dns_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package hostlocal_test import ( "io/ioutil" diff --git a/plugins/ipam/host-local/host_local_suite_test.go b/plugins/ipam/host-local/host_local_suite_test.go index d458f6bd..b368b0e7 100644 --- a/plugins/ipam/host-local/host_local_suite_test.go +++ b/plugins/ipam/host-local/host_local_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package hostlocal_test import ( . "github.com/onsi/ginkgo" diff --git a/plugins/ipam/host-local/host_local_test.go b/plugins/ipam/host-local/host_local_test.go index 6f32c0a3..c840f132 100644 --- a/plugins/ipam/host-local/host_local_test.go +++ b/plugins/ipam/host-local/host_local_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package hostlocal_test import ( "fmt" diff --git a/plugins/ipam/host-local/main.go b/plugins/ipam/host-local/main.go index 79269013..fd93c0f6 100644 --- a/plugins/ipam/host-local/main.go +++ b/plugins/ipam/host-local/main.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package hostlocal import ( "fmt" @@ -29,7 +29,7 @@ import ( "github.com/containernetworking/cni/pkg/version" ) -func main() { +func Main() { skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("host-local")) } diff --git a/plugins/main/bridge/bridge.go b/plugins/main/bridge/bridge.go index c6a0690d..77b5234e 100644 --- a/plugins/main/bridge/bridge.go +++ b/plugins/main/bridge/bridge.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package bridge import ( "encoding/json" @@ -625,7 +625,7 @@ func cmdDel(args *skel.CmdArgs) error { return err } -func main() { +func Main() { skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("bridge")) } diff --git a/plugins/main/bridge/bridge_suite_test.go b/plugins/main/bridge/bridge_suite_test.go index 3e48736b..392098eb 100644 --- a/plugins/main/bridge/bridge_suite_test.go +++ b/plugins/main/bridge/bridge_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package bridge_test import ( . "github.com/onsi/ginkgo" diff --git a/plugins/main/bridge/bridge_test.go b/plugins/main/bridge/bridge_test.go index 513b0dc9..6d1349dd 100644 --- a/plugins/main/bridge/bridge_test.go +++ b/plugins/main/bridge/bridge_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package bridge_test import ( "encoding/json" diff --git a/plugins/main/loopback/loopback.go b/plugins/main/loopback/loopback.go index 2b07f7eb..46a43112 100644 --- a/plugins/main/loopback/loopback.go +++ b/plugins/main/loopback/loopback.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package loopback import ( "encoding/json" @@ -159,7 +159,7 @@ func cmdDel(args *skel.CmdArgs) error { return nil } -func main() { +func Main() { skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("loopback")) } diff --git a/plugins/main/loopback/loopback_suite_test.go b/plugins/main/loopback/loopback_suite_test.go index d252d12b..a2b6ae27 100644 --- a/plugins/main/loopback/loopback_suite_test.go +++ b/plugins/main/loopback/loopback_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main_test +package loopback_test import ( "github.com/onsi/gomega/gexec" diff --git a/plugins/main/loopback/loopback_test.go b/plugins/main/loopback/loopback_test.go index 68cfb15e..59dbb931 100644 --- a/plugins/main/loopback/loopback_test.go +++ b/plugins/main/loopback/loopback_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main_test +package loopback_test import ( "fmt" diff --git a/plugins/meta/flannel/flannel.go b/plugins/meta/flannel/flannel.go index 5d07efaf..c4c6948b 100644 --- a/plugins/meta/flannel/flannel.go +++ b/plugins/meta/flannel/flannel.go @@ -16,7 +16,7 @@ // the data from flannel generated subnet file and then invokes a plugin // like bridge or ipvlan to do the real work. -package main +package flannel import ( "bufio" @@ -266,7 +266,7 @@ func cmdDel(args *skel.CmdArgs) error { return doCmdDel(args, nc) } -func main() { +func Main() { skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("flannel")) } diff --git a/plugins/meta/flannel/flannel_linux.go b/plugins/meta/flannel/flannel_linux.go index 7d1a806e..d5bc26b5 100644 --- a/plugins/meta/flannel/flannel_linux.go +++ b/plugins/meta/flannel/flannel_linux.go @@ -16,7 +16,7 @@ // the data from flannel generated subnet file and then invokes a plugin // like bridge or ipvlan to do the real work. -package main +package flannel import ( "context" diff --git a/plugins/meta/flannel/flannel_linux_test.go b/plugins/meta/flannel/flannel_linux_test.go index a3b68e37..34e7a758 100644 --- a/plugins/meta/flannel/flannel_linux_test.go +++ b/plugins/meta/flannel/flannel_linux_test.go @@ -11,7 +11,7 @@ // 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 main +package flannel_test import ( "encoding/json" diff --git a/plugins/meta/flannel/flannel_suite_test.go b/plugins/meta/flannel/flannel_suite_test.go index d604dbcb..dcc61e41 100644 --- a/plugins/meta/flannel/flannel_suite_test.go +++ b/plugins/meta/flannel/flannel_suite_test.go @@ -11,7 +11,7 @@ // 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 main +package flannel_test import ( . "github.com/onsi/ginkgo" diff --git a/plugins/meta/flannel/flannel_windows.go b/plugins/meta/flannel/flannel_windows.go index 7c0c560b..f34d9068 100644 --- a/plugins/meta/flannel/flannel_windows.go +++ b/plugins/meta/flannel/flannel_windows.go @@ -16,7 +16,7 @@ // the data from flannel generated subnet file and then invokes a plugin // like bridge or ipvlan to do the real work. -package main +package flannel import ( "context" diff --git a/plugins/meta/portmap/chain.go b/plugins/meta/portmap/chain.go index 4875b5e2..0e4c1f17 100644 --- a/plugins/meta/portmap/chain.go +++ b/plugins/meta/portmap/chain.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap import ( "fmt" diff --git a/plugins/meta/portmap/chain_test.go b/plugins/meta/portmap/chain_test.go index c4e41be5..69f547e5 100644 --- a/plugins/meta/portmap/chain_test.go +++ b/plugins/meta/portmap/chain_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap_test import ( "fmt" diff --git a/plugins/meta/portmap/main.go b/plugins/meta/portmap/main.go index bfd11bba..b2c5d3a0 100644 --- a/plugins/meta/portmap/main.go +++ b/plugins/meta/portmap/main.go @@ -23,7 +23,7 @@ // of the actual host port. If there is a service on the host, it will have all // its traffic captured by the container. If another container also claims a given // port, it will caputure the traffic - it is last-write-wins. -package main +package portmap import ( "encoding/json" @@ -135,7 +135,7 @@ func cmdDel(args *skel.CmdArgs) error { return nil } -func main() { +func Main() { skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("portmap")) } diff --git a/plugins/meta/portmap/portmap.go b/plugins/meta/portmap/portmap.go index d35136f0..3c8850cc 100644 --- a/plugins/meta/portmap/portmap.go +++ b/plugins/meta/portmap/portmap.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap import ( "fmt" diff --git a/plugins/meta/portmap/portmap_integ_test.go b/plugins/meta/portmap/portmap_integ_test.go index b4cca147..e7012627 100644 --- a/plugins/meta/portmap/portmap_integ_test.go +++ b/plugins/meta/portmap/portmap_integ_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap_test import ( "bytes" diff --git a/plugins/meta/portmap/portmap_suite_test.go b/plugins/meta/portmap/portmap_suite_test.go index 55aee924..98a2e466 100644 --- a/plugins/meta/portmap/portmap_suite_test.go +++ b/plugins/meta/portmap/portmap_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap_test import ( "math/rand" diff --git a/plugins/meta/portmap/portmap_test.go b/plugins/meta/portmap/portmap_test.go index 12df96c5..d99ee662 100644 --- a/plugins/meta/portmap/portmap_test.go +++ b/plugins/meta/portmap/portmap_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap_test import ( "fmt" diff --git a/plugins/meta/portmap/utils.go b/plugins/meta/portmap/utils.go index a733fdaa..163e7874 100644 --- a/plugins/meta/portmap/utils.go +++ b/plugins/meta/portmap/utils.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package portmap import ( "fmt"