Create multi-exec binary

This commit is contained in:
Darren Shepherd
2018-06-19 18:31:12 -07:00
committed by Manuel Buil
parent fa48f7515b
commit 6ad65a095d
25 changed files with 52 additions and 29 deletions

23
main.go Normal file
View File

@@ -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()
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package hostlocal
import (
"bufio"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"))
}

View File

@@ -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"))
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"))
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"))
}

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package portmap
import (
"fmt"

View File

@@ -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"

View File

@@ -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"))
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package portmap
import (
"fmt"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package main
package portmap
import (
"fmt"