Skip to content

Commit

Permalink
virtcontainers: Initial import
Browse files Browse the repository at this point in the history
This is a virtcontainers 1.0.8 import into Kata Containers runtime.

virtcontainers is a Go library designed to manage hardware virtualized
pods and containers. It is the core Clear Containers framework and will
become the core Kata Containers framework, as discussed at
kata-containers#33

Some more more pointers:

virtcontainers README, including some design and architecure notes:
https://github.com/containers/virtcontainers/blob/master/README.md

virtcontainers 1.0 API:
https://github.com/containers/virtcontainers/blob/master/documentation/api/1.0/api.md

Fixes kata-containers#40

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Samuel Ortiz committed Mar 12, 2018
1 parent ad9cef4 commit 24eff72
Show file tree
Hide file tree
Showing 854 changed files with 441,776 additions and 0 deletions.
46 changes: 46 additions & 0 deletions virtcontainers/.ci/go-lint.sh
@@ -0,0 +1,46 @@
# Copyright (c) 2017 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#

#!/bin/bash

if [ ! $(command -v gometalinter) ]
then
go get github.com/alecthomas/gometalinter
gometalinter --install --vendor
fi

linter_args="--tests --vendor"

# When running the linters in a CI environment we need to disable them all
# by default and then explicitly enable the ones we are care about. This is
# necessary since *if* gometalinter adds a new linter, that linter may cause
# the CI build to fail when it really shouldn't. However, when this script is
# run locally, all linters should be run to allow the developer to review any
# failures (and potentially decide whether we need to explicitly enable a new
# linter in the CI).
if [ "$CI" = true ]; then
linter_args+=" --disable-all"
fi

linter_args+=" --enable=misspell"
linter_args+=" --enable=vet"
linter_args+=" --enable=ineffassign"
linter_args+=" --enable=gofmt"
linter_args+=" --enable=gocyclo"
linter_args+=" --cyclo-over=15"
linter_args+=" --enable=golint"
linter_args+=" --deadline=600s"

eval gometalinter "${linter_args}" ./...
31 changes: 31 additions & 0 deletions virtcontainers/.ci/go-test.sh
@@ -0,0 +1,31 @@
# Copyright (c) 2017 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#

#!/bin/bash

set -e

test_packages=$(go list ./... | grep -v vendor)
test_ldflags="-X github.com/containers/virtcontainers/pkg/mock.DefaultMockCCShimBinPath=$1 \
-X github.com/containers/virtcontainers/pkg/mock.DefaultMockKataShimBinPath=$2 \
-X github.com/containers/virtcontainers/pkg/mock.DefaultMockHookBinPath=$3"
echo "Run go test and generate coverage:"
for pkg in $test_packages; do
if [ "$pkg" = "github.com/containers/virtcontainers" ]; then
sudo env GOPATH=$GOPATH GOROOT=$GOROOT PATH=$PATH go test -ldflags "$test_ldflags" -cover -coverprofile=profile.cov $pkg
else
sudo env GOPATH=$GOPATH GOROOT=$GOROOT PATH=$PATH go test -ldflags "$test_ldflags" -cover $pkg
fi
done
55 changes: 55 additions & 0 deletions virtcontainers/.ci/jenkins_job_build.sh
@@ -0,0 +1,55 @@
#!/bin/bash
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.

set -e

vc_repo="github.com/containers/virtcontainers"

# Export all environment variables needed.
export GOROOT="/usr/local/go"
export GOPATH=${HOME}/go
export PATH=${GOPATH}/bin:/usr/local/go/bin:/usr/sbin:${PATH}
export CI=true

# Download and build goveralls binary in case we need to submit the code
# coverage.
if [ ${COVERALLS_REPO_TOKEN} ]
then
go get github.com/mattn/goveralls
fi

# Get the repository and move HEAD to the appropriate commit.
go get ${vc_repo} || true
cd "${GOPATH}/src/${vc_repo}"
if [ "${ghprbPullId}" ] && [ "${ghprbTargetBranch}" ]
then
git fetch origin "pull/${ghprbPullId}/head" && git checkout master && git reset --hard FETCH_HEAD && git rebase "origin/${ghprbTargetBranch}"

export AUTHOR_REPO_GIT_URL="${ghprbAuthorRepoGitUrl}"
export COMMIT_REVISION="${ghprbActualCommit}"
else
git fetch origin && git checkout master && git reset --hard origin/master
fi

# Setup environment and run the tests
sudo -E PATH=$PATH bash .ci/setup.sh
sudo -E PATH=$PATH bash .ci/run.sh

# Publish the code coverage if needed.
if [ ${COVERALLS_REPO_TOKEN} ]
then
sudo -E PATH=${PATH} bash -c "${GOPATH}/bin/goveralls -repotoken=${COVERALLS_REPO_TOKEN} -coverprofile=profile.cov"
fi
33 changes: 33 additions & 0 deletions virtcontainers/.ci/run.sh
@@ -0,0 +1,33 @@
#!/bin/bash
#
# Copyright (c) 2017 Intel Corporation

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#

set -e

export CI=true
tests_repo="github.com/clearcontainers/tests"

make check

sudo -E PATH=$PATH sh -c "go test -bench=."

sudo -E PATH=$PATH sh -c "go test -bench=CreateStartStopDeletePodQemuHypervisorNoopAgentNetworkCNI -benchtime=60s"

sudo -E PATH=$PATH sh -c "go test -bench=CreateStartStopDeletePodQemuHypervisorHyperstartAgentNetworkCNI -benchtime=60s"

pushd "${GOPATH}/src/${tests_repo}"
.ci/run.sh
popd
41 changes: 41 additions & 0 deletions virtcontainers/.ci/setup.sh
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#

set -e

cidir=$(dirname "$0")
tests_repo="github.com/clearcontainers/tests"

# Clone Tests repository.
go get "$tests_repo"

tests_repo_dir="${GOPATH}/src/${tests_repo}"

echo "Update proxy and runtime vendoring"
sudo -E PATH=$PATH bash -c "${cidir}/update-vendoring.sh"

pushd "${tests_repo_dir}"
echo "Setup Clear Containers"
sudo -E PATH=$PATH bash -c ".ci/setup.sh"
popd

echo "Setup virtcontainers environment"
chronic sudo -E PATH=$PATH bash -c "${cidir}/../utils/virtcontainers-setup.sh"

echo "Install virtcontainers"
chronic make
chronic sudo make install
89 changes: 89 additions & 0 deletions virtcontainers/.ci/update-vendoring.sh
@@ -0,0 +1,89 @@
#!/bin/bash
#
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#

# This script is used to update the virtcontainers code in the vendor
# directories of the proxy and runtime repositories.

set -e

proxy_repo="github.com/clearcontainers/proxy"
runtime_repo="github.com/clearcontainers/runtime"
virtcontainers_repo="github.com/containers/virtcontainers"

function apply_depends_on(){
pushd "${GOPATH}/src/${virtcontainers_repo}"
label_lines=$(git log --format=%s%b -n 1 | grep "Depends-on:" || true)

if [ "${label_lines}" == "" ]; then
return 0
fi

nb_lines=$(echo ${label_lines} | wc -l)

for i in `seq 1 ${nb_lines}`
do
label_line=$(echo $label_lines | sed "${i}q;d")
label_str=$(echo "${label_line}" | cut -d' ' -f2)
repo=$(echo "${label_str}" | cut -d'#' -f1)
pr_id=$(echo "${label_str}" | cut -d'#' -f2)

if [ ! -d "${GOPATH}/src/${repo}" ]; then
go get -d "$repo" || true
fi

pushd "${GOPATH}/src/${repo}"
git fetch origin "pull/${pr_id}/head" && git checkout FETCH_HEAD && git rebase origin/master
popd
done

popd
}

function install_dep(){
go get -u github.com/golang/dep/cmd/dep
}

function update_repo(){
if [ "${AUTHOR_REPO_GIT_URL}" ] && [ "${COMMIT_REVISION}" ]
then
repo="$1"
if [ ! -d "${GOPATH}/src/${repo}" ]; then
go get -d "$repo" || true
fi

pushd "${GOPATH}/src/${repo}"

# Update Gopkg.toml
cat >> Gopkg.toml <<EOF
[[override]]
name = "${virtcontainers_repo}"
source = "${AUTHOR_REPO_GIT_URL}"
revision = "${COMMIT_REVISION}"
EOF

# Update the whole vendoring
dep ensure && dep ensure -update "${virtcontainers_repo}" && dep prune

popd
fi
}

apply_depends_on
install_dep
update_repo "${proxy_repo}"
update_repo "${runtime_repo}"
10 changes: 10 additions & 0 deletions virtcontainers/.gitignore
@@ -0,0 +1,10 @@
*.patch
*.o
*.swp
/hack/virtc/virtc
/hook/mock/hook
/shim/mock/shim
/shim/mock/cc-shim/cc-shim
/shim/mock/kata-shim/kata-shim
/utils/supportfiles
profile.cov
52 changes: 52 additions & 0 deletions virtcontainers/.pullapprove.yml
@@ -0,0 +1,52 @@
version: 2

requirements:
signed_off_by:
required: true

# Disallow approval of PRs still under development
always_pending:
title_regex: 'WIP'
labels:
- do-not-merge
- wip
explanation: 'Work in progress - do not merge'

group_defaults:
approve_by_comment:
enabled: true
approve_regex: '^(LGTM|lgtm|Approved|\+1|:\+1:)'
reject_regex: '^(Rejected|-1|:-1:)'
reset_on_push:
enabled: false
reset_on_reopened:
enabled: false
author_approval:
ignored: true

groups:
networking:
conditions:
files:
- pkg/cni/*
- cni*
- cnm*
required: 1
users:
- mcastelino
- sboeuf

approvers:
required: 1
users:
- sameo
- sboeuf
- amshinde
- jodh-intel

reviewers:
required: 1
teams:
- virtcontainers-maintainers
users:
- amshinde

0 comments on commit 24eff72

Please sign in to comment.