Switch to github.com/golang/dep for vendoring

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-01-31 16:45:59 -08:00
parent d6ab91be27
commit 8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions

View file

@ -0,0 +1,21 @@
#!/bin/bash
# Run a docker container with network namespace set up by the
# CNI plugins.
# Example usage: ./docker-run.sh --rm busybox /sbin/ifconfig
contid=$(docker run -d --net=none busybox:latest /bin/sleep 10000000)
pid=$(docker inspect -f '{{ .State.Pid }}' $contid)
netnspath=/proc/$pid/ns/net
./exec-plugins.sh add $contid $netnspath
function cleanup() {
./exec-plugins.sh del $contid $netnspath
docker kill $contid >/dev/null
}
trap cleanup EXIT
docker run --net=container:$contid $@

View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
if [[ ${DEBUG} -gt 0 ]]; then set -x; fi
NETCONFPATH=${NETCONFPATH-/etc/cni/net.d}
function exec_plugins() {
i=0
contid=$2
netns=$3
export CNI_COMMAND=$(echo $1 | tr '[:lower:]' '[:upper:]')
export PATH=$CNI_PATH:$PATH
export CNI_CONTAINERID=$contid
export CNI_NETNS=$netns
for netconf in $(echo $NETCONFPATH/*.conf | sort); do
name=$(jq -r '.name' <$netconf)
plugin=$(jq -r '.type' <$netconf)
export CNI_IFNAME=$(printf eth%d $i)
res=$($plugin <$netconf)
if [ $? -ne 0 ]; then
errmsg=$(echo $res | jq -r '.msg')
if [ -z "$errmsg" ]; then
errmsg=$res
fi
echo "${name} : error executing $CNI_COMMAND: $errmsg"
exit 1
elif [[ ${DEBUG} -gt 0 ]]; then
echo ${res} | jq -r .
fi
let "i=i+1"
done
}
if [ $# -ne 3 ]; then
echo "Usage: $0 add|del CONTAINER-ID NETNS-PATH"
echo " Adds or deletes the container specified by NETNS-PATH to the networks"
echo " specified in \$NETCONFPATH directory"
exit 1
fi
exec_plugins $1 $2 $3

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
if [[ ${DEBUG} -gt 0 ]]; then set -x; fi
# Run a command in a private network namespace
# set up by CNI plugins
contid=$(printf '%x%x%x%x' $RANDOM $RANDOM $RANDOM $RANDOM)
netnspath=/var/run/netns/$contid
ip netns add $contid
./exec-plugins.sh add $contid $netnspath
function cleanup() {
./exec-plugins.sh del $contid $netnspath
ip netns delete $contid
}
trap cleanup EXIT
ip netns exec $contid "$@"

View file

@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -xe
SRC_DIR="${SRC_DIR:-$PWD}"
FEDORA_INSTALL="dnf install -y golang tar xz bzip2 gzip sudo iproute wget"
FEDORA_IMAGE="docker://fedora:23"
ACBUILD_URL="https://github.com/appc/acbuild/releases/download/v0.2.2/acbuild.tar.gz"
ACBUILD="acbuild --debug"
BUILDFLAGS="-a --ldflags '-extldflags \"-static\"'"
TAG=$(git describe --exact-match --abbrev=0) || TAG=$(git describe)
RELEASE_DIR=release-${TAG}
OUTPUT_DIR=bin
rm -Rf ${SRC_DIR}/${RELEASE_DIR}
mkdir -p ${SRC_DIR}/${RELEASE_DIR}
sudo -E rkt run \
--volume rslvconf,kind=host,source=/etc/resolv.conf \
--mount volume=rslvconf,target=/etc/resolv.conf \
--volume src-dir,kind=host,source=$SRC_DIR \
--mount volume=src-dir,target=/opt/src \
--interactive \
--insecure-options=image \
${FEDORA_IMAGE} \
--exec /bin/bash \
-- -xe -c "\
${FEDORA_INSTALL}; cd /opt/src; umask 0022;
for arch in amd64 arm arm64 ppc64le; do \
CGO_ENABLED=0 GOARCH=\$arch ./build ${BUILDFLAGS}; \
for format in txz tbz2 tgz; do \
FILENAME=cni-\$arch-${TAG}.\$format; \
FILEPATH=${RELEASE_DIR}/\$FILENAME; \
tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf \$FILEPATH .; \
if [ \"\$arch\" == \"amd64\" ]; then \
cp \$FILEPATH ${RELEASE_DIR}/cni-${TAG}.\$format; \
fi; \
done; \
done; \
wget -O - ${ACBUILD_URL} | tar -C /usr/bin -xzvf -; \
${ACBUILD} begin; \
${ACBUILD} set-name coreos.com/cni; \
${ACBUILD} label add version ${TAG}; \
${ACBUILD} copy --to-dir ${OUTPUT_DIR} /opt/cni/; \
${ACBUILD} write ${RELEASE_DIR}/cni-${TAG}.aci; \
${ACBUILD} end; \
pushd ${RELEASE_DIR}; for f in \$(ls); do sha1sum \$f > \$f.sha1; done; popd; \
chown -R ${UID} ${OUTPUT_DIR} ${RELEASE_DIR}; \
:"