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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package hostlocal
import ( import (
"bufio" "bufio"

View File

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

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package hostlocal_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View File

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

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package hostlocal
import ( import (
"fmt" "fmt"
@@ -29,7 +29,7 @@ import (
"github.com/containernetworking/cni/pkg/version" "github.com/containernetworking/cni/pkg/version"
) )
func main() { func Main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("host-local")) 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package bridge
import ( import (
"encoding/json" "encoding/json"
@@ -625,7 +625,7 @@ func cmdDel(args *skel.CmdArgs) error {
return err return err
} }
func main() { func Main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("bridge")) 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package bridge_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View File

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

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package loopback
import ( import (
"encoding/json" "encoding/json"
@@ -159,7 +159,7 @@ func cmdDel(args *skel.CmdArgs) error {
return nil return nil
} }
func main() { func Main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("loopback")) 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main_test package loopback_test
import ( import (
"github.com/onsi/gomega/gexec" "github.com/onsi/gomega/gexec"

View File

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

View File

@@ -16,7 +16,7 @@
// the data from flannel generated subnet file and then invokes a plugin // the data from flannel generated subnet file and then invokes a plugin
// like bridge or ipvlan to do the real work. // like bridge or ipvlan to do the real work.
package main package flannel
import ( import (
"bufio" "bufio"
@@ -266,7 +266,7 @@ func cmdDel(args *skel.CmdArgs) error {
return doCmdDel(args, nc) return doCmdDel(args, nc)
} }
func main() { func Main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("flannel")) 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 // the data from flannel generated subnet file and then invokes a plugin
// like bridge or ipvlan to do the real work. // like bridge or ipvlan to do the real work.
package main package flannel
import ( import (
"context" "context"

View File

@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package flannel_test
import ( import (
"encoding/json" "encoding/json"

View File

@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package flannel_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View File

@@ -16,7 +16,7 @@
// the data from flannel generated subnet file and then invokes a plugin // the data from flannel generated subnet file and then invokes a plugin
// like bridge or ipvlan to do the real work. // like bridge or ipvlan to do the real work.
package main package flannel
import ( import (
"context" "context"

View File

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

View File

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

View File

@@ -23,7 +23,7 @@
// of the actual host port. If there is a service on the host, it will have all // 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 // its traffic captured by the container. If another container also claims a given
// port, it will caputure the traffic - it is last-write-wins. // port, it will caputure the traffic - it is last-write-wins.
package main package portmap
import ( import (
"encoding/json" "encoding/json"
@@ -135,7 +135,7 @@ func cmdDel(args *skel.CmdArgs) error {
return nil return nil
} }
func main() { func Main() {
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("portmap")) 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 // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package main package portmap
import ( import (
"fmt" "fmt"

View File

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

View File

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

View File

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

View File

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